Skip to content

Commit 2a78869

Browse files
authored
[FEATURE] Docker: support for setting accounts and config option directly in compose.yaml, auto creation of files (#477)
* docker config and accounts support #Docker quality of life updates: automatic account/config generation ## summary - a valid accounts.json and config.json are now auto-generated on first run locally into ./config/ based on current example.files - Accounts set via ACCOUNT_1_* / ACCOUNT_2_* vars in .env or compose.yaml - Added env.example as credentials template - All config options exposed as CONFIG_* env vars in compose.yaml; overrides apply on every startup and take precedence over config.json - headless always forced true in Docker - new config handling: warns in logs if a new image adds config keys missing from existing config.json - If there is an updated, users can delete the local config.json, and a fresh one will be generated respecting the user's env overrides in the compose file. ## Files changed - Dockerfile, scripts/docker/entrypoint.sh, compose.yaml, env.example (new) ## Todo - Testing (builds and runs on my system with 2 accounts, etc.) - Tidy up over-documentation in the compose (all config options are listed for dev testing, but likely only a few are necessary like clusters, search delay, and webhook * Update entrypoint.sh Fix incorrectly identifying an existing config as new, if an array value was changed. * Tidy up compose and readme Only commonly changed config values are included in the sample compose. All available config values added to the readme. * add config update note Adds a note how to easily update the config file if the example config is updated (i.e., new features added) * Update compose.yaml Tidied up the compose file: - re-enabled latest image vs., local build - for accounts, removed env_file block to simplify using a .env or adding credentials directly in the compose per user preference. - removed extra comments
1 parent 5861eed commit 2a78869

6 files changed

Lines changed: 529 additions & 104 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ accounts.main.json
1414
bun.lock
1515
logs/
1616
.stfolder/
17+
.env

Dockerfile

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,12 @@ ENV NODE_ENV=production \
3939
PLAYWRIGHT_BROWSERS_PATH=0 \
4040
FORCE_HEADLESS=1
4141

42-
# Install minimal system libraries required for Chromium headless to run
42+
# Install minimal system libraries required for Chromium headless to run,
43+
# plus jq (for config generation/patching) and gettext-base (for envsubst)
4344
RUN apt-get update && apt-get install -y --no-install-recommends \
4445
cron \
4546
gettext-base \
47+
jq \
4648
tzdata \
4749
ca-certificates \
4850
libglib2.0-0 \
@@ -79,11 +81,23 @@ COPY --from=builder /usr/src/microsoft-rewards-script/dist ./dist
7981
COPY --from=builder /usr/src/microsoft-rewards-script/package*.json ./
8082
COPY --from=builder /usr/src/microsoft-rewards-script/node_modules ./node_modules
8183

84+
# Copy config example into the image so entrypoint can use it as a fallback
85+
# when the user hasn't mounted their own config.json
86+
COPY src/config.example.json ./src/config.example.json
87+
88+
# Create the config directory and symlink config.json and accounts.json into
89+
# dist/ so the app finds them at its expected paths, while the entrypoint
90+
# writes to dist/config/ which maps to the user-facing ./config/ volume mount
91+
RUN mkdir -p ./dist/config \
92+
&& ln -s /usr/src/microsoft-rewards-script/dist/config/config.json ./dist/config.json \
93+
&& ln -s /usr/src/microsoft-rewards-script/dist/config/accounts.json ./dist/accounts.json
94+
8295
# Copy runtime scripts with proper permissions from the start
8396
COPY --chmod=755 scripts/docker/run_daily.sh ./scripts/docker/run_daily.sh
8497
COPY --chmod=644 src/crontab.template /etc/cron.d/microsoft-rewards-cron.template
8598
COPY --chmod=755 scripts/docker/entrypoint.sh /usr/local/bin/entrypoint.sh
8699

87-
# Entrypoint handles TZ, initial run toggle, cron templating & launch
100+
# Entrypoint handles TZ, accounts/config generation, initial run toggle,
101+
# cron templating & launch
88102
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
89-
CMD ["sh", "-c", "echo 'Container started; cron is running.'"]
103+
CMD ["sh", "-c", "echo 'Container started; cron is running.'"]

0 commit comments

Comments
 (0)