Session 7b: Fix pipeline - body parser, Redis queueing, poller visibility, auto-start
This commit is contained in:
+20
-13
@@ -7,9 +7,9 @@
|
||||
# 2. runner — copy src/, poller/, scripts/, node_modules and start
|
||||
#
|
||||
# The Next.js frontend ships in a separate image (web/Dockerfile). PM2
|
||||
# pollers can run inside this image via `pm2-runtime` or as a sibling
|
||||
# container — production deploys use a sibling so a poller crash doesn't
|
||||
# restart the API.
|
||||
# pollers run INSIDE this image and are auto-started by
|
||||
# scripts/docker-entrypoint.sh so a Coolify redeploy reseeds them on
|
||||
# every container start.
|
||||
#
|
||||
# Build: docker build -t vyndr-api .
|
||||
# Run: docker run -p 3001:3001 --env-file .env vyndr-api
|
||||
@@ -26,12 +26,16 @@ RUN npm ci --omit=dev --no-audit --no-fund
|
||||
FROM node:20-alpine AS runner
|
||||
WORKDIR /app
|
||||
|
||||
# curl is used by the /api/health smoke check (Coolify HEALTHCHECK), and
|
||||
# postgresql-client lets the in-container migrations script run if needed.
|
||||
# curl is used by the /api/health smoke check (Coolify HEALTHCHECK).
|
||||
RUN apk add --no-cache curl tini
|
||||
|
||||
# PM2 is installed globally so the entrypoint can call `pm2 start` to
|
||||
# boot all three pollers (NBA / WNBA / MLB) alongside the Express API.
|
||||
RUN npm install -g pm2@latest --no-audit --no-fund
|
||||
|
||||
ENV NODE_ENV=production \
|
||||
PORT=3001
|
||||
PORT=3001 \
|
||||
PM2_HOME=/app/.pm2
|
||||
|
||||
# Non-root user — the container should never run as uid 0 even if the
|
||||
# host accidentally maps a privileged port.
|
||||
@@ -44,19 +48,22 @@ COPY poller ./poller
|
||||
COPY scripts ./scripts
|
||||
COPY supabase ./supabase
|
||||
|
||||
# Persistent volume for JSONL training data. Coolify mounts this path so
|
||||
# resolutions survive redeploys.
|
||||
RUN mkdir -p /app/data/training && chown -R vyndr:vyndr /app/data
|
||||
# Persistent volume for JSONL training data (resolutions survive
|
||||
# redeploys via the Coolify mount). PM2_HOME lives outside it so
|
||||
# supervisor state is local to the container.
|
||||
RUN mkdir -p /app/data/training /app/.pm2 \
|
||||
&& chown -R vyndr:vyndr /app/data /app/.pm2 \
|
||||
&& chmod +x /app/scripts/docker-entrypoint.sh
|
||||
|
||||
USER vyndr
|
||||
|
||||
EXPOSE 3001
|
||||
|
||||
# tini reaps zombies cleanly when Node spawns child processes (e.g., the
|
||||
# embedded Python pre-checks the orchestrator may run during a slate).
|
||||
# tini reaps zombies — important now that we spawn pm2 as a child of
|
||||
# this entrypoint.
|
||||
ENTRYPOINT ["/sbin/tini", "--"]
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=20s --retries=3 \
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
|
||||
CMD curl -fsS http://127.0.0.1:3001/api/health || exit 1
|
||||
|
||||
CMD ["node", "src/server.js"]
|
||||
CMD ["sh", "scripts/docker-entrypoint.sh"]
|
||||
|
||||
Reference in New Issue
Block a user