mirror of
https://github.com/TheNetsky/Microsoft-Rewards-Script.git
synced 2026-01-10 18:36:17 +00:00
* Optimizations of dockerfile
Massive test optimizations with drop in image size to about 256mb from about 1.2 gb. Drawback is that I currently have to keep the dockerfile playwright version matched to the package.json version
* further optimizations
Removed redundant (hopefully) sessions directory creation during build
* Fix docker cron dependencies
Small fix that should make cron run properly
* Major docker update!
- **Dockerfile rewritten as a multi-stage build**
- Split into a “builder” stage (`node:18-slim`) to install dependencies and compile TypeScript, and a “runtime” stage (official Playwright image) to run the script.
- This keeps build tools and dependencies out of the final image, making it smaller, faster to pull, and more secure.
- **Entrypoint script (`entrypoint.sh`)**
- Introduced an entrypoint that runs inside the container at startup to:
1. Set the container’s timezone (`TZ`) correctly, based on the environment or defaulting to UTC.
2. Validate that the user provided a `CRON_SCHEDULE` (exiting early with an error if missing).
3. Optionally perform an initial run of the script immediately (when `RUN_ON_START=true`), without any random sleep.
- Centralizing setup in an entrypoint keeps the Dockerfile simpler and ensures proper signal handling.
- **`run_daily.sh` improvements**
- Removed custom browser-path override so Playwright uses bundled browsers in the official image.
- Added a lock using `flock` to prevent overlapping runs if a previous run is still in progress.
- Retained the random sleep between 5 and 50 minutes before each run.
- Logs are timestamped and clearly report success or failure.
- **Cron template tweaks**
- Updated `src/crontab.template` so that each job line redirects both stdout and stderr into Docker’s stdout (`>> /proc/1/fd/1 2>&1`), making it easy to view logs via `docker logs`.
- **Initial-run logic**
- The entrypoint checks `RUN_ON_START=true` and, if set, invokes `npm start` immediately (without random sleep). This provides an immediate first execution on container startup.
- Scheduled runs via cron still go through the normal `run_daily.sh` (with sleep and locking).
- **Cron logging and visibility**
- By redirecting cron job output to the container’s stdout, all logs (initial run and scheduled runs) appear in `docker logs`, avoiding the need to tail log files manually.
- **Error handling and validation**
- Entry point exits early if `CRON_SCHEDULE` is missing, preventing silent misconfiguration.
- If the initial run fails, it logs a warning but still starts cron so future scheduled runs can proceed.
- `run_daily.sh` will exit early if a previous run is still active (locking), avoiding overlapping executions.
* Docker (multi-stage) improvements
- added cron logging in entrypoint and fixed timezone support for cron-invoked script runs
- further optimized multi-stage dockerfile
- bumped playwright version to 1.52.0 in dockerfile and package.json
- added customization and enable/disable randomization for cron start times
- optionally add container health monitor and resource limits in compose.yaml
52 lines
1.5 KiB
JSON
52 lines
1.5 KiB
JSON
{
|
|
"name": "microsoft-rewards-script",
|
|
"version": "1.5.3",
|
|
"description": "Automatically do tasks for Microsoft Rewards but in TS!",
|
|
"main": "index.js",
|
|
"engines": {
|
|
"node": ">=18.0.0"
|
|
},
|
|
"scripts": {
|
|
"pre-build": "npm i && rimraf dist && npx playwright install chromium",
|
|
"build": "tsc",
|
|
"start": "node ./dist/index.js",
|
|
"ts-start": "ts-node ./src/index.ts",
|
|
"dev": "ts-node ./src/index.ts -dev",
|
|
"kill-chrome-win": "powershell -Command \"Get-Process | Where-Object { $_.MainModule.FileVersionInfo.FileDescription -eq 'Google Chrome for Testing' } | ForEach-Object { Stop-Process -Id $_.Id -Force }\"",
|
|
"create-docker": "docker build -t microsoft-rewards-script-docker ."
|
|
},
|
|
"keywords": [
|
|
"Bing Rewards",
|
|
"Microsoft Rewards",
|
|
"Bot",
|
|
"Script",
|
|
"TypeScript",
|
|
"Playwright",
|
|
"Cheerio"
|
|
],
|
|
"author": "Netsky",
|
|
"license": "ISC",
|
|
"devDependencies": {
|
|
"@types/ms": "^0.7.34",
|
|
"@typescript-eslint/eslint-plugin": "^7.17.0",
|
|
"eslint": "^8.57.0",
|
|
"eslint-plugin-modules-newline": "^0.0.6",
|
|
"rimraf": "^6.0.1",
|
|
"typescript": "^5.5.4"
|
|
},
|
|
"dependencies": {
|
|
"axios": "^1.8.4",
|
|
"chalk": "^4.1.2",
|
|
"cheerio": "^1.0.0",
|
|
"fingerprint-generator": "^2.1.66",
|
|
"fingerprint-injector": "^2.1.66",
|
|
"http-proxy-agent": "^7.0.2",
|
|
"https-proxy-agent": "^7.0.6",
|
|
"ms": "^2.1.3",
|
|
"playwright": "1.52.0",
|
|
"rebrowser-playwright": "1.52.0",
|
|
"socks-proxy-agent": "^8.0.5",
|
|
"ts-node": "^10.9.2"
|
|
}
|
|
}
|