Spaces:
Sleeping
Sleeping
| # βββ δ»ε½©539 AI ι ζΈ¬η³»η΅± β Dockerfile βββββββββββββββββββββββββββββββββββββββ | |
| # Multi-stage is unnecessary here, keep it simple with Node 18 Alpine. | |
| # The container: | |
| # 1. On startup: runs scraper.js (+ backtest.js) if data doesn't exist yet | |
| # 2. Schedules a daily cron at 21:30 (Asia/Taipei) to refresh data automatically | |
| # 3. Runs serve.js (HTTP server on port 7860) in the foreground | |
| FROM node:18-alpine | |
| # Install timezone data so cron runs at correct Taiwan time | |
| RUN apk add --no-cache tzdata | |
| ENV TZ=Asia/Taipei | |
| WORKDIR /app | |
| # Copy application files | |
| COPY . . | |
| # Create logs directory | |
| RUN mkdir -p /app/logs | |
| # Register the cron job: | |
| # Every day at 21:30 Asia/Taipei β node scraper.js then node backtest.js | |
| RUN echo "30 21 * * * cd /app && node scraper.js >> /app/logs/scraper.log 2>&1 && node backtest.js >> /app/logs/backtest.log 2>&1" \ | |
| > /etc/crontabs/root | |
| # Expose the web server port | |
| EXPOSE 7860 | |
| # Entrypoint | |
| CMD ["sh", "/app/start.sh"] | |