From 8f64dcc0e4e389903e6a7198d0a2b11498fcd948 Mon Sep 17 00:00:00 2001 From: yyamashita Date: Fri, 8 May 2026 00:06:36 +0900 Subject: Add scraper service to docker-compose with 6-hourly cron Co-Authored-By: Claude Sonnet 4.6 --- Dockerfile | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'Dockerfile') diff --git a/Dockerfile b/Dockerfile index 64f51e2..9977bbe 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,7 @@ COPY --from=deps /app/node_modules /app/node_modules WORKDIR /app RUN npm run build -FROM node:20-slim +FROM node:20-slim AS app WORKDIR /app COPY package.json package-lock.json ./ RUN npm ci --omit=dev @@ -18,3 +18,18 @@ RUN npx playwright install chromium --with-deps RUN mkdir -p /app/data EXPOSE 3000 CMD ["npm", "start"] + +FROM node:20-slim AS scraper +WORKDIR /app +COPY package.json package-lock.json ./ +RUN npm ci --omit=dev && npm install tsx +COPY --from=build /app/build ./build +COPY scripts ./scripts +COPY app ./app +COPY tsconfig.json ./ +RUN npx playwright install chromium --with-deps +RUN apt-get update && apt-get install -y cron && rm -rf /var/lib/apt/lists/* +RUN echo '0 */6 * * * root cd /app && DB_PATH=/app/data/events.db node --import tsx/esm scripts/scrape.ts >> /app/data/scraper.log 2>&1' > /etc/cron.d/scraper \ + && chmod 0644 /etc/cron.d/scraper +RUN mkdir -p /app/data +CMD ["cron", "-f"] -- cgit v1.2.3