mirror of
https://github.com/LightZirconite/Microsoft-Rewards-Bot.git
synced 2026-01-10 17:26:17 +00:00
fix: Update Docker configuration and documentation for improved deployment process
This commit is contained in:
@@ -56,8 +56,9 @@ setup/
|
|||||||
docker/
|
docker/
|
||||||
.dockerignore
|
.dockerignore
|
||||||
|
|
||||||
# Scripts (organized in scripts/ folder - not needed in Docker)
|
# Scripts installer (not needed in Docker, but keep docker/ folder)
|
||||||
scripts/
|
scripts/installer/
|
||||||
|
scripts/README.md
|
||||||
|
|
||||||
# Asset files (not needed for runtime)
|
# Asset files (not needed for runtime)
|
||||||
assets/
|
assets/
|
||||||
|
|||||||
11
README.md
11
README.md
@@ -221,13 +221,16 @@ For containerized deployment with built-in scheduling:
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Ensure accounts.jsonc and config.jsonc exist in src/
|
# Ensure accounts.jsonc and config.jsonc exist in src/
|
||||||
docker compose up -d
|
npm run docker:compose
|
||||||
|
|
||||||
|
# Or use docker compose directly
|
||||||
|
docker compose -f docker/compose.yaml up -d
|
||||||
|
|
||||||
# View logs
|
# View logs
|
||||||
docker logs -f microsoft-rewards-script
|
docker logs -f microsoft-rewards-bot
|
||||||
|
|
||||||
# Check status
|
# Check status
|
||||||
docker compose ps
|
docker compose -f docker/compose.yaml ps
|
||||||
```
|
```
|
||||||
|
|
||||||
Container includes:
|
Container includes:
|
||||||
@@ -236,7 +239,7 @@ Container includes:
|
|||||||
- ✅ Random execution delays (anti-detection)
|
- ✅ Random execution delays (anti-detection)
|
||||||
- ✅ Health checks
|
- ✅ Health checks
|
||||||
|
|
||||||
**📖 [Full Docker Guide](docs/docker.md)**
|
**📖 [Complete Docker Guide →](docs/docker-deployment.md)**
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
services:
|
services:
|
||||||
microsoft-rewards-script:
|
microsoft-rewards-script:
|
||||||
build: .
|
build:
|
||||||
|
context: ..
|
||||||
|
dockerfile: docker/Dockerfile
|
||||||
container_name: microsoft-rewards-bot
|
container_name: microsoft-rewards-bot
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
@@ -20,7 +22,6 @@ services:
|
|||||||
#MIN_SLEEP_MINUTES: "5"
|
#MIN_SLEEP_MINUTES: "5"
|
||||||
#MAX_SLEEP_MINUTES: "50"
|
#MAX_SLEEP_MINUTES: "50"
|
||||||
SKIP_RANDOM_SLEEP: "false"
|
SKIP_RANDOM_SLEEP: "false"
|
||||||
|
|
||||||
# Optionally set how long to wait before killing a stuck script run (prevents blocking future runs, default: 8 hours)
|
# Optionally set how long to wait before killing a stuck script run (prevents blocking future runs, default: 8 hours)
|
||||||
#STUCK_PROCESS_TIMEOUT_HOURS: "8"
|
#STUCK_PROCESS_TIMEOUT_HOURS: "8"
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,47 @@
|
|||||||
# Docker Deployment Guide
|
# Docker Deployment Guide
|
||||||
|
|
||||||
## 🐳 Quick Start
|
Complete guide for containerized deployment with built-in scheduling.
|
||||||
|
|
||||||
### 1. Build the Image
|
## 📂 Docker File Structure
|
||||||
```bash
|
|
||||||
cd docker
|
```
|
||||||
docker build -t microsoft-rewards-bot -f Dockerfile ..
|
Microsoft-Rewards-Bot/
|
||||||
|
├── docker/ # All Docker-related files
|
||||||
|
│ ├── Dockerfile # Multi-stage build configuration
|
||||||
|
│ ├── compose.yaml # Service definition
|
||||||
|
│ ├── entrypoint.sh # Container initialization
|
||||||
|
│ ├── run_daily.sh # Daily execution wrapper + locking
|
||||||
|
│ └── crontab.template # Cron job template
|
||||||
|
├── src/
|
||||||
|
│ ├── accounts.jsonc # Your accounts (volume mount)
|
||||||
|
│ └── config.jsonc # Bot configuration (volume mount)
|
||||||
|
└── package.json # Build scripts
|
||||||
```
|
```
|
||||||
|
|
||||||
Or use the npm script:
|
**Important:** All Docker files are in the `docker/` folder, but the build context is the **project root** (to access `src/`, `package.json`, etc.)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🚀 Quick Start
|
||||||
|
|
||||||
|
### 1. Build the Image
|
||||||
|
|
||||||
|
**Option A: Using npm script (recommended)**
|
||||||
```bash
|
```bash
|
||||||
|
# From project root
|
||||||
npm run docker:build
|
npm run docker:build
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Option B: Direct Docker command**
|
||||||
|
```bash
|
||||||
|
# From project root
|
||||||
|
docker build -f docker/Dockerfile -t microsoft-rewards-bot .
|
||||||
|
```
|
||||||
|
|
||||||
|
**Why from root?** The Dockerfile needs access to `src/`, `package.json`, `tsconfig.json`. Docker can't copy files outside the build context.
|
||||||
|
|
||||||
### 2. Configure Environment
|
### 2. Configure Environment
|
||||||
|
|
||||||
Edit `docker/compose.yaml`:
|
Edit `docker/compose.yaml`:
|
||||||
```yaml
|
```yaml
|
||||||
environment:
|
environment:
|
||||||
@@ -23,27 +51,96 @@ environment:
|
|||||||
```
|
```
|
||||||
|
|
||||||
### 3. Start the Container
|
### 3. Start the Container
|
||||||
|
|
||||||
|
**Option A: Using npm script**
|
||||||
```bash
|
```bash
|
||||||
cd docker
|
npm run docker:compose
|
||||||
docker compose up -d
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Option B: Direct docker compose command**
|
||||||
|
```bash
|
||||||
|
docker compose -f docker/compose.yaml up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
**Note:** Volumes in `compose.yaml` use relative paths from `docker/`:
|
||||||
|
- `./src/` → `docker/../src/` (goes to project root)
|
||||||
|
- `./sessions/` → `docker/sessions/` (local to docker folder)
|
||||||
|
|
||||||
## 📋 Configuration Files
|
## 📋 Configuration Files
|
||||||
|
|
||||||
The container needs access to your configuration files via volume mounts:
|
The container needs access to your configuration files via volume mounts:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
volumes:
|
volumes:
|
||||||
- ../src/accounts.jsonc:/usr/src/microsoft-rewards-bot/dist/accounts.jsonc:ro
|
# Read-only mounts for configuration (prevents accidental container edits)
|
||||||
- ../src/config.jsonc:/usr/src/microsoft-rewards-bot/dist/config.jsonc:ro
|
- ./src/accounts.jsonc:/usr/src/microsoft-rewards-bot/dist/accounts.jsonc:ro
|
||||||
|
- ./src/config.jsonc:/usr/src/microsoft-rewards-bot/dist/config.jsonc:ro
|
||||||
|
|
||||||
|
# Read-write mount for persistent login sessions
|
||||||
- ./sessions:/usr/src/microsoft-rewards-bot/dist/browser/sessions
|
- ./sessions:/usr/src/microsoft-rewards-bot/dist/browser/sessions
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Paths explained:**
|
||||||
|
- `./src/accounts.jsonc` = `docker/../src/accounts.jsonc` (relative from compose.yaml location)
|
||||||
|
- `./sessions` = `docker/sessions/` (local to docker folder)
|
||||||
|
|
||||||
**Before starting:**
|
**Before starting:**
|
||||||
1. Create `src/accounts.jsonc` (copy from `src/accounts.example.jsonc`)
|
1. Create `src/accounts.jsonc` (copy from `src/accounts.example.jsonc`)
|
||||||
2. Edit `src/config.jsonc` with your settings
|
2. Edit `src/config.jsonc` with your settings
|
||||||
3. (Optional) Create `docker/sessions/` directory for persistent login
|
3. (Optional) Create `docker/sessions/` directory for persistent login
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🏗️ Architecture & Build Process
|
||||||
|
|
||||||
|
### Two-Stage Docker Build
|
||||||
|
|
||||||
|
**Stage 1: Builder**
|
||||||
|
```dockerfile
|
||||||
|
FROM node:22-slim AS builder
|
||||||
|
# 1. Install dependencies + dev dependencies
|
||||||
|
# 2. Compile TypeScript → JavaScript (dist/)
|
||||||
|
# 3. Install Playwright Chromium
|
||||||
|
# 4. Remove dev dependencies (keep only production)
|
||||||
|
```
|
||||||
|
|
||||||
|
**Stage 2: Runtime**
|
||||||
|
```dockerfile
|
||||||
|
FROM node:22-slim AS runtime
|
||||||
|
# 1. Install minimal system libraries for Chromium
|
||||||
|
# 2. Copy compiled code + dependencies from builder
|
||||||
|
# 3. Copy runtime scripts (entrypoint.sh, run_daily.sh)
|
||||||
|
# 4. Configure cron daemon
|
||||||
|
```
|
||||||
|
|
||||||
|
**Why two stages?**
|
||||||
|
- Smaller final image (~800 MB vs 1.5 GB)
|
||||||
|
- No build tools in production
|
||||||
|
- Security: no dev dependencies
|
||||||
|
|
||||||
|
### Build Context Explained
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# ❌ WRONG: Building from docker/ folder
|
||||||
|
cd docker
|
||||||
|
docker build -t bot .
|
||||||
|
# Error: Cannot find package.json, src/, etc.
|
||||||
|
|
||||||
|
# ✅ CORRECT: Build from root, specify Dockerfile location
|
||||||
|
cd /path/to/Microsoft-Rewards-Bot
|
||||||
|
docker build -f docker/Dockerfile -t bot .
|
||||||
|
# Success: Access to all project files
|
||||||
|
```
|
||||||
|
|
||||||
|
**The Dockerfile copies files relative to project root:**
|
||||||
|
```dockerfile
|
||||||
|
COPY package.json tsconfig.json ./ # From project root
|
||||||
|
COPY src/ ./src/ # From project root
|
||||||
|
COPY docker/run_daily.sh ./docker/ # Subfolder
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## 🔧 Environment Variables
|
## 🔧 Environment Variables
|
||||||
|
|
||||||
| Variable | Required | Default | Description |
|
| Variable | Required | Default | Description |
|
||||||
@@ -113,21 +210,50 @@ docker exec microsoft-rewards-bot ps aux
|
|||||||
|
|
||||||
## 🛠️ Troubleshooting
|
## 🛠️ Troubleshooting
|
||||||
|
|
||||||
### "Chromium not installed" After First Run
|
### ❌ Build Error: "Cannot find module 'package.json'"
|
||||||
|
|
||||||
|
**Cause:** Wrong build context - building from `docker/` instead of project root.
|
||||||
|
|
||||||
|
**Solution:**
|
||||||
|
```bash
|
||||||
|
# ❌ WRONG
|
||||||
|
cd docker
|
||||||
|
docker build -t bot .
|
||||||
|
|
||||||
|
# ✅ CORRECT (from project root)
|
||||||
|
docker build -f docker/Dockerfile -t bot .
|
||||||
|
# Or use npm script
|
||||||
|
npm run docker:build
|
||||||
|
```
|
||||||
|
|
||||||
|
### ❌ Build Error: "COPY failed: file not found: docker/run_daily.sh"
|
||||||
|
|
||||||
|
**Cause:** `.dockerignore` file excludes `docker/` folder.
|
||||||
|
|
||||||
|
**Solution:** Check `.dockerignore` - it should NOT contain `docker/`:
|
||||||
|
```ignore
|
||||||
|
# ❌ BAD
|
||||||
|
docker/
|
||||||
|
|
||||||
|
# ✅ GOOD (current config)
|
||||||
|
scripts/installer/
|
||||||
|
```
|
||||||
|
|
||||||
|
### ❌ "Chromium not installed" After First Run
|
||||||
|
|
||||||
**Symptoms:**
|
**Symptoms:**
|
||||||
- Bot works on first run
|
- Bot works on first run
|
||||||
- Fails on subsequent scheduled runs with "Chromium not installed"
|
- Fails on subsequent scheduled runs with "Chromium not installed"
|
||||||
|
|
||||||
**Root Cause:**
|
**Root Cause:**
|
||||||
Fixed in latest version! Chromium browser files are now copied correctly from builder stage.
|
Fixed in v2.56.7+! Chromium browser files are now copied correctly from builder stage.
|
||||||
|
|
||||||
**Solution:**
|
**Solution:**
|
||||||
```bash
|
```bash
|
||||||
# Rebuild with latest Dockerfile (includes fix)
|
# Rebuild with latest Dockerfile (includes fix)
|
||||||
docker build --no-cache -t microsoft-rewards-bot -f docker/Dockerfile ..
|
npm run docker:build
|
||||||
docker compose down
|
docker compose -f docker/compose.yaml down
|
||||||
docker compose up -d
|
docker compose -f docker/compose.yaml up -d
|
||||||
```
|
```
|
||||||
|
|
||||||
**Verification:**
|
**Verification:**
|
||||||
@@ -138,7 +264,7 @@ docker exec microsoft-rewards-bot ls -la /usr/src/microsoft-rewards-bot/node_mod
|
|||||||
|
|
||||||
You should see `browser-chromium/` directory.
|
You should see `browser-chromium/` directory.
|
||||||
|
|
||||||
### Container Exits Immediately
|
### ❌ Container Exits Immediately
|
||||||
|
|
||||||
**Check logs:**
|
**Check logs:**
|
||||||
```bash
|
```bash
|
||||||
@@ -147,183 +273,202 @@ docker logs microsoft-rewards-bot
|
|||||||
|
|
||||||
**Common causes:**
|
**Common causes:**
|
||||||
1. **Missing CRON_SCHEDULE:** Set environment variable in compose.yaml
|
1. **Missing CRON_SCHEDULE:** Set environment variable in compose.yaml
|
||||||
|
```yaml
|
||||||
|
environment:
|
||||||
|
CRON_SCHEDULE: "0 9 * * *" # Required!
|
||||||
|
```
|
||||||
|
|
||||||
2. **Invalid cron expression:** Validate at https://crontab.guru
|
2. **Invalid cron expression:** Validate at https://crontab.guru
|
||||||
3. **Permission issues:** Ensure config files are readable
|
|
||||||
|
3. **Script not executable:** Dockerfile should handle this automatically
|
||||||
|
```dockerfile
|
||||||
|
COPY --chmod=755 docker/entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||||
|
```
|
||||||
|
|
||||||
**Fix:**
|
**Fix:**
|
||||||
```bash
|
```bash
|
||||||
# Update compose.yaml with correct CRON_SCHEDULE
|
# Update compose.yaml with correct CRON_SCHEDULE
|
||||||
docker compose down
|
docker compose -f docker/compose.yaml down
|
||||||
docker compose up -d
|
docker compose -f docker/compose.yaml up -d
|
||||||
```
|
```
|
||||||
|
|
||||||
### Random Delays Not Working
|
### ❌ "Permission denied: entrypoint.sh"
|
||||||
|
|
||||||
**Check environment variables:**
|
**Cause:** Script not executable or Windows CRLF line endings.
|
||||||
```bash
|
|
||||||
docker exec microsoft-rewards-bot env | grep SLEEP
|
**Solution:** The Dockerfile handles both automatically:
|
||||||
|
```dockerfile
|
||||||
|
COPY --chmod=755 docker/entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||||
|
RUN sed -i 's/\r$//' /usr/local/bin/entrypoint.sh # Convert CRLF → LF
|
||||||
```
|
```
|
||||||
|
|
||||||
**Verify run_daily.sh receives variables:**
|
If still failing, manually fix line endings:
|
||||||
```bash
|
|
||||||
docker exec microsoft-rewards-bot cat docker/run_daily.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
**Test manually:**
|
|
||||||
```bash
|
|
||||||
docker exec microsoft-rewards-bot docker/run_daily.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
### Timezone Incorrect
|
|
||||||
|
|
||||||
**Check container timezone:**
|
|
||||||
```bash
|
|
||||||
docker exec microsoft-rewards-bot date
|
|
||||||
```
|
|
||||||
|
|
||||||
**Fix:**
|
|
||||||
1. Update `TZ` in compose.yaml
|
|
||||||
2. Restart container:
|
|
||||||
```bash
|
|
||||||
docker compose restart
|
|
||||||
```
|
|
||||||
|
|
||||||
**Verify:**
|
|
||||||
```bash
|
|
||||||
docker exec microsoft-rewards-bot date
|
|
||||||
docker logs microsoft-rewards-bot | grep "Timezone:"
|
|
||||||
```
|
|
||||||
|
|
||||||
### Health Check Failing
|
|
||||||
|
|
||||||
**Check cron daemon:**
|
|
||||||
```bash
|
|
||||||
docker exec microsoft-rewards-bot ps aux | grep cron
|
|
||||||
```
|
|
||||||
|
|
||||||
**Expected output:**
|
|
||||||
```
|
|
||||||
root 1 0.0 0.0 2576 1024 ? Ss 12:00 0:00 cron -f
|
|
||||||
```
|
|
||||||
|
|
||||||
**Restart container if missing:**
|
|
||||||
```bash
|
|
||||||
docker compose restart
|
|
||||||
```
|
|
||||||
|
|
||||||
### Sessions Not Persisting
|
|
||||||
|
|
||||||
**Check volume mount:**
|
|
||||||
```bash
|
|
||||||
docker inspect microsoft-rewards-bot | grep sessions
|
|
||||||
```
|
|
||||||
|
|
||||||
**Verify local directory exists:**
|
|
||||||
```bash
|
|
||||||
ls -la docker/sessions/
|
|
||||||
```
|
|
||||||
|
|
||||||
**Fix permissions:**
|
|
||||||
```bash
|
```bash
|
||||||
# Linux/Mac
|
# Linux/Mac
|
||||||
chmod -R 755 docker/sessions/
|
dos2unix docker/entrypoint.sh docker/run_daily.sh
|
||||||
|
|
||||||
# Windows
|
# Or with sed
|
||||||
# No action needed (NTFS handles permissions)
|
sed -i 's/\r$//' docker/entrypoint.sh
|
||||||
|
sed -i 's/\r$//' docker/run_daily.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
### Out of Memory Errors
|
### ❌ Volumes Not Mounting
|
||||||
|
|
||||||
**Increase memory limit in compose.yaml:**
|
### ❌ Volumes Not Mounting
|
||||||
```yaml
|
|
||||||
mem_limit: 6g # Increase from 4g
|
|
||||||
```
|
|
||||||
|
|
||||||
**Restart:**
|
**Check if files exist:**
|
||||||
```bash
|
```bash
|
||||||
docker compose down
|
# From docker/ folder
|
||||||
docker compose up -d
|
ls -la ../src/accounts.jsonc ../src/config.jsonc
|
||||||
|
|
||||||
|
# Or from project root
|
||||||
|
ls -la src/accounts.jsonc src/config.jsonc
|
||||||
```
|
```
|
||||||
|
|
||||||
**Monitor memory usage:**
|
**Verify volume paths in running container:**
|
||||||
```bash
|
```bash
|
||||||
docker stats microsoft-rewards-bot
|
docker inspect microsoft-rewards-bot | grep -A 10 Mounts
|
||||||
```
|
```
|
||||||
|
|
||||||
## 🔄 Updates
|
**Fix paths in compose.yaml:**
|
||||||
|
```yaml
|
||||||
|
# Paths are relative to compose.yaml location (docker/)
|
||||||
|
volumes:
|
||||||
|
- ./src/accounts.jsonc:/usr/src/microsoft-rewards-bot/dist/accounts.jsonc:ro
|
||||||
|
# This resolves to: docker/../src/accounts.jsonc (project root)
|
||||||
|
```
|
||||||
|
|
||||||
### Update to Latest Version
|
---
|
||||||
|
|
||||||
**Method 1: Rebuild (Recommended)**
|
## 📚 Complete File Reference
|
||||||
|
|
||||||
|
### `docker/Dockerfile`
|
||||||
|
Multi-stage build configuration:
|
||||||
|
- **Builder stage:** Compiles TypeScript, installs Playwright
|
||||||
|
- **Runtime stage:** Minimal image with only production dependencies
|
||||||
|
|
||||||
|
### `docker/compose.yaml`
|
||||||
|
Service definition with:
|
||||||
|
- Build context (points to project root)
|
||||||
|
- Volume mounts (configuration files)
|
||||||
|
- Environment variables (scheduling, timezone)
|
||||||
|
- Resource limits (CPU, memory)
|
||||||
|
- Health checks (cron daemon monitoring)
|
||||||
|
|
||||||
|
### `docker/entrypoint.sh`
|
||||||
|
Container initialization script:
|
||||||
|
1. Configures timezone from `TZ` env var
|
||||||
|
2. Validates `CRON_SCHEDULE` is set
|
||||||
|
3. Optionally runs bot immediately (`RUN_ON_START=true`)
|
||||||
|
4. Templates cron job with environment variables
|
||||||
|
5. Starts cron daemon in foreground
|
||||||
|
|
||||||
|
### `docker/run_daily.sh`
|
||||||
|
Daily execution wrapper:
|
||||||
|
- File-based locking (prevents concurrent runs)
|
||||||
|
- Self-healing lockfile validation
|
||||||
|
- Random sleep delay (anti-detection)
|
||||||
|
- Stuck process killer (timeout after N hours)
|
||||||
|
- Executes `npm start`
|
||||||
|
|
||||||
|
### `docker/crontab.template`
|
||||||
|
Cron job template with variable interpolation:
|
||||||
```bash
|
```bash
|
||||||
# Pull latest code
|
${CRON_SCHEDULE} TZ=${TZ} /bin/bash /usr/src/microsoft-rewards-bot/docker/run_daily.sh >> /proc/1/fd/1 2>&1
|
||||||
git pull origin main
|
|
||||||
|
|
||||||
# Rebuild image
|
|
||||||
docker build --no-cache -t microsoft-rewards-bot -f docker/Dockerfile ..
|
|
||||||
|
|
||||||
# Restart container
|
|
||||||
docker compose down
|
|
||||||
docker compose up -d
|
|
||||||
```
|
```
|
||||||
|
|
||||||
**Method 2: Auto-Update (If Enabled in config.jsonc)**
|
Expanded by `entrypoint.sh` using `envsubst`.
|
||||||
The bot can auto-update itself if `update.enabled: true` in config.jsonc.
|
|
||||||
After auto-update, container will restart automatically (Docker restarts on exit).
|
|
||||||
|
|
||||||
### Backup Before Update
|
---
|
||||||
|
|
||||||
|
## 🎯 Build & Deployment Checklist
|
||||||
|
|
||||||
|
### Pre-Build Checklist
|
||||||
|
- [ ] Files exist: `src/accounts.jsonc`, `src/config.jsonc`
|
||||||
|
- [ ] Docker installed and running
|
||||||
|
- [ ] At project root (not in `docker/` folder)
|
||||||
|
- [ ] `.dockerignore` does NOT exclude `docker/` folder
|
||||||
|
|
||||||
|
### Build Steps
|
||||||
```bash
|
```bash
|
||||||
# Backup sessions
|
# 1. Clean previous builds (optional)
|
||||||
cp -r docker/sessions/ docker/sessions.backup/
|
docker rmi microsoft-rewards-bot
|
||||||
|
|
||||||
# Backup config
|
# 2. Build image
|
||||||
cp src/config.jsonc src/config.jsonc.backup
|
npm run docker:build
|
||||||
cp src/accounts.jsonc src/accounts.jsonc.backup
|
# Or: docker build -f docker/Dockerfile -t microsoft-rewards-bot .
|
||||||
|
|
||||||
|
# 3. Verify image created
|
||||||
|
docker images | grep microsoft-rewards-bot
|
||||||
```
|
```
|
||||||
|
|
||||||
## 📊 Resource Usage
|
### Deployment Steps
|
||||||
|
```bash
|
||||||
|
# 1. Configure compose.yaml
|
||||||
|
# - Set CRON_SCHEDULE (required)
|
||||||
|
# - Set TZ (optional, default UTC)
|
||||||
|
# - Set RUN_ON_START (optional, default false)
|
||||||
|
|
||||||
**Typical resource consumption:**
|
# 2. Start container
|
||||||
- **CPU:** 50-80% during active runs, <1% idle
|
npm run docker:compose
|
||||||
- **RAM:** 1-3 GB during active runs, <100 MB idle
|
# Or: docker compose -f docker/compose.yaml up -d
|
||||||
- **Disk:** ~500 MB (base image + browsers)
|
|
||||||
- **Network:** Minimal (<10 MB per run)
|
|
||||||
|
|
||||||
**Recommended limits:**
|
# 3. Verify running
|
||||||
```yaml
|
docker ps | grep microsoft-rewards-bot
|
||||||
mem_limit: 4g
|
|
||||||
cpus: 2
|
# 4. Check logs
|
||||||
|
docker logs -f microsoft-rewards-bot
|
||||||
|
|
||||||
|
# 5. Verify health
|
||||||
|
docker inspect microsoft-rewards-bot --format='{{.State.Health.Status}}'
|
||||||
```
|
```
|
||||||
|
|
||||||
## 🔐 Security Hardening
|
---
|
||||||
|
|
||||||
The default compose.yaml includes:
|
## 🔍 Debugging Commands
|
||||||
```yaml
|
|
||||||
security_opt:
|
### Check Build Context
|
||||||
- no-new-privileges:true # Prevent privilege escalation
|
```bash
|
||||||
|
# List files Docker can see during build
|
||||||
|
docker build -f docker/Dockerfile -t test . --progress=plain 2>&1 | grep "COPY"
|
||||||
```
|
```
|
||||||
|
|
||||||
**Additional hardening (optional):**
|
### Inspect Running Container
|
||||||
```yaml
|
```bash
|
||||||
security_opt:
|
# Shell access
|
||||||
- no-new-privileges:true
|
docker exec -it microsoft-rewards-bot bash
|
||||||
- seccomp:unconfined # Only if Chromium fails to start
|
|
||||||
read_only: false # Must be false (Chromium needs write access)
|
# Check environment variables
|
||||||
tmpfs:
|
docker exec microsoft-rewards-bot env
|
||||||
- /tmp
|
|
||||||
- /root/.cache
|
# Check cron jobs
|
||||||
|
docker exec microsoft-rewards-bot crontab -l
|
||||||
|
|
||||||
|
# Check timezone
|
||||||
|
docker exec microsoft-rewards-bot date
|
||||||
|
|
||||||
|
# Check Playwright browsers
|
||||||
|
docker exec microsoft-rewards-bot ls -la node_modules/@playwright/
|
||||||
|
|
||||||
|
# Check running processes
|
||||||
|
docker exec microsoft-rewards-bot ps aux
|
||||||
```
|
```
|
||||||
|
|
||||||
## 🆘 Getting Help
|
### Test Scripts Manually
|
||||||
|
```bash
|
||||||
|
# Test entrypoint
|
||||||
|
docker exec microsoft-rewards-bot /usr/local/bin/entrypoint.sh
|
||||||
|
|
||||||
If issues persist:
|
# Test run_daily (bypass lock)
|
||||||
1. **Check logs:** `docker logs -f microsoft-rewards-bot`
|
docker exec microsoft-rewards-bot bash -c "rm -f /tmp/run_daily.lock && docker/run_daily.sh"
|
||||||
2. **Rebuild with no cache:** `docker build --no-cache ...`
|
|
||||||
3. **Verify Chromium:** `docker exec microsoft-rewards-bot ls -la node_modules/@playwright/`
|
|
||||||
4. **Discord Support:** https://discord.gg/k5uHkx9mne
|
|
||||||
5. **GitHub Issues:** https://github.com/Obsidian-wtf/Microsoft-Rewards-Bot/issues
|
|
||||||
|
|
||||||
## 📚 Related Documentation
|
# Test bot directly
|
||||||
|
docker exec microsoft-rewards-bot npm start
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📖 Additional Resources
|
||||||
|
|
||||||
- **Build System:** [docs/build-system.md](build-system.md)
|
- **Build System:** [docs/build-system.md](build-system.md)
|
||||||
- **Scheduling:** [src/scheduler/README.md](../src/scheduler/README.md)
|
- **Scheduling:** [src/scheduler/README.md](../src/scheduler/README.md)
|
||||||
|
|||||||
@@ -64,33 +64,20 @@ Explore advanced features and customization options:| **[NTFY Alerts](ntfy.md)**
|
|||||||
|
|
||||||
| **[Proxy Setup](proxy.md)** | IP rotation (optional) |
|
| **[Proxy Setup](proxy.md)** | IP rotation (optional) |
|
||||||
|
|
||||||
### Core Features| **[Docker](docker.md)** | Container deployment |
|
### Core Features
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
| Guide | Description |---
|
|
||||||
|
|
||||||
|
| Guide | Description |
|
||||||
|-------|-------------|
|
|-------|-------------|
|
||||||
|
| **[🔔 Notifications](notifications.md)** | Discord webhooks and mobile push alerts |
|
||||||
| **[🔔 Notifications](notifications.md)** | Discord webhooks and mobile push alerts |## 🆘 Troubleshooting
|
|
||||||
|
|
||||||
| **[📊 Dashboard](../src/dashboard/README.md)** | Web interface for monitoring and control |
|
| **[📊 Dashboard](../src/dashboard/README.md)** | Web interface for monitoring and control |
|
||||||
|
| **[🌐 Proxy Setup](proxy.md)** | Configure proxies for privacy |
|
||||||
|
| **[🤖 Humanization](humanization.md)** | Anti-detection and natural behavior patterns |
|
||||||
|
|
||||||
| **[🌐 Proxy Setup](proxy.md)** | Configure proxies for privacy || Issue | Solution |
|
### Deployment
|
||||||
|
|
||||||
| **[🤖 Humanization](humanization.md)** | Anti-detection and natural behavior patterns ||-------|----------|
|
| Guide | Description |
|
||||||
|
|-------|-------------|
|
||||||
| **Bot not working?** | [Troubleshooting Guide](diagnostics.md) |
|
| **[🐳 Docker](docker-deployment.md)** | Containerized deployment with Docker Compose |
|
||||||
|
|
||||||
### Deployment| **Login failed?** | [Accounts & 2FA](accounts.md#troubleshooting) |
|
|
||||||
|
|
||||||
| **Account banned?** | [Security Guide](security.md) |
|
|
||||||
|
|
||||||
| Guide | Description || **Git conflicts?** | [Conflict Resolution](git-conflict-resolution.md) |
|
|
||||||
|
|
||||||
|-------|-------------|| **General questions?** | [FAQ](FAQ.md) |
|
|
||||||
|
|
||||||
| **[🐳 Docker](docker.md)** | Containerized deployment with Docker Compose |
|
|
||||||
|
|
||||||
| **[☁️ Cloud Deployment](cloud-deployment.md)** | Deploy to VPS, Raspberry Pi, or cloud services |**Need help?** → [Discord Community](https://discord.gg/k5uHkx9mne)
|
| **[☁️ Cloud Deployment](cloud-deployment.md)** | Deploy to VPS, Raspberry Pi, or cloud services |**Need help?** → [Discord Community](https://discord.gg/k5uHkx9mne)
|
||||||
|
|
||||||
@@ -186,7 +173,7 @@ Technical references and detailed information:
|
|||||||
|
|
||||||
### For Docker Users
|
### For Docker Users
|
||||||
|
|
||||||
1. [Docker Guide](docker.md) — Setup Docker Compose
|
1. [Docker Guide](docker-deployment.md) — Setup Docker Compose
|
||||||
2. [Environment Variables](environment-variables.md) — Configure via env vars
|
2. [Environment Variables](environment-variables.md) — Configure via env vars
|
||||||
3. [Notifications](notifications.md) — Monitor container runs
|
3. [Notifications](notifications.md) — Monitor container runs
|
||||||
|
|
||||||
|
|||||||
@@ -31,8 +31,9 @@
|
|||||||
"lint": "eslint \"src/**/*.{ts,tsx}\"",
|
"lint": "eslint \"src/**/*.{ts,tsx}\"",
|
||||||
"setup": "node ./scripts/installer/setup.mjs",
|
"setup": "node ./scripts/installer/setup.mjs",
|
||||||
"kill-chrome": "node -e \"const { execSync } = require('child_process'); const isWin = process.platform === 'win32'; try { execSync(isWin ? 'taskkill /F /IM chrome.exe 2>nul || exit 0' : 'pkill -f chrome || true', {stdio: 'inherit'}); } catch(e) {}\"",
|
"kill-chrome": "node -e \"const { execSync } = require('child_process'); const isWin = process.platform === 'win32'; try { execSync(isWin ? 'taskkill /F /IM chrome.exe 2>nul || exit 0' : 'pkill -f chrome || true', {stdio: 'inherit'}); } catch(e) {}\"",
|
||||||
"docker:build": "docker build -t microsoft-rewards-bot .",
|
"docker:build": "docker build -f docker/Dockerfile -t microsoft-rewards-bot .",
|
||||||
"docker:run": "docker run -d --name ms-rewards microsoft-rewards-bot"
|
"docker:run": "docker run -d --name ms-rewards microsoft-rewards-bot",
|
||||||
|
"docker:compose": "docker compose -f docker/compose.yaml up -d"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"Bing Rewards",
|
"Bing Rewards",
|
||||||
|
|||||||
Reference in New Issue
Block a user