Files
Microsoft-Rewards-Bot/Dockerfile
LightZirconite 2cc9df5278 Refactor project structure and update references from Light60-1 to Obsidian-wtf
- Changed working directory in Dockerfile from /usr/src/microsoft-rewards-script to /app
- Updated Docker container name and service name from microsoft-rewards-script to microsoft-rewards-bot
- Modified LICENSE, NOTICE, README.md, and other documentation files to reflect new project ownership
- Updated package.json and package-lock.json to change project name and repository links
- Adjusted entrypoint script and Docker Compose configurations for new paths
- Updated security and login handling in source code to reflect new documentation URLs
- Changed logo asset to reflect new branding
2025-11-03 15:17:06 +01:00

88 lines
2.3 KiB
Docker

###############################################################################
# Stage 1: Builder
###############################################################################
FROM node:22-slim AS builder
WORKDIR /app
ENV PLAYWRIGHT_BROWSERS_PATH=0
# Copy package files
COPY package.json package-lock.json tsconfig.json ./
# Install all dependencies required to build the script
RUN npm ci --ignore-scripts
# Copy source and build
COPY . .
RUN npm run build
# Remove build dependencies, and reinstall only runtime dependencies
RUN rm -rf node_modules \
&& npm ci --omit=dev --ignore-scripts \
&& npm cache clean --force
# Install Chromium Headless Shell, and cleanup
RUN npx playwright install --with-deps --only-shell chromium \
&& rm -rf /root/.cache /tmp/* /var/tmp/*
###############################################################################
# Stage 2: Runtime
###############################################################################
FROM node:22-slim AS runtime
WORKDIR /app
# Set production environment variables
ENV NODE_ENV=production \
TZ=UTC \
PLAYWRIGHT_BROWSERS_PATH=0 \
FORCE_HEADLESS=1
# Install minimal system libraries required for Chromium headless to run
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
libglib2.0-0 \
libdbus-1-3 \
libexpat1 \
libfontconfig1 \
libgtk-3-0 \
libnspr4 \
libnss3 \
libasound2 \
libflac12 \
libatk1.0-0 \
libatspi2.0-0 \
libdrm2 \
libgbm1 \
libdav1d6 \
libx11-6 \
libx11-xcb1 \
libxcomposite1 \
libxcursor1 \
libxdamage1 \
libxext6 \
libxfixes3 \
libxi6 \
libxrandr2 \
libxrender1 \
libxss1 \
libxtst6 \
libdouble-conversion3 \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*
# Copy compiled application and dependencies from builder stage
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/package*.json ./
COPY --from=builder /app/node_modules ./node_modules
# Copy entrypoint script
COPY docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
# Use entrypoint that supports both scheduler and cron
ENTRYPOINT ["docker-entrypoint.sh"]
# Default: use built-in scheduler
CMD ["npm", "run", "start:schedule"]