Make builds reproducible and redeploys graceful
All checks were successful
Build and Deploy / build-and-push (push) Successful in 43s

- Install with npm ci from package-lock.json so a rebuild can't pull
  different dependency versions than were tested.
- Run node directly (not via npm) so it receives SIGTERM and can drain
  queued webhooks; give the stack a 60s stop_grace_period and start the
  new task before stopping the old one.
- Add .dockerignore and stop tracking dist/ (already gitignored and
  rebuilt by the Dockerfile).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-10-08 15:12:09 -03:00
parent 4fe5830f8f
commit c5e168429d
7 changed files with 23 additions and 105 deletions

View File

@@ -3,9 +3,9 @@ FROM node:20-alpine AS builder
WORKDIR /app
# Copy package files and install all dependencies (including devDependencies for TypeScript)
COPY package.json ./
RUN npm install
# Copy package files and install the exact locked dependencies (including devDependencies for TypeScript)
COPY package.json package-lock.json ./
RUN npm ci
# Copy source code and build
COPY . .
@@ -16,9 +16,9 @@ FROM node:20-alpine
WORKDIR /app
# Copy package files and install ONLY production dependencies
COPY package.json ./
RUN npm install --omit=dev
# Copy package files and install ONLY the locked production dependencies
COPY package.json package-lock.json ./
RUN npm ci --omit=dev
# Copy built code from the builder stage
COPY --from=builder /app/dist ./dist
@@ -27,5 +27,5 @@ COPY --from=builder /app/data ./data
# Expose the port the app runs on
EXPOSE 3000
# Command to run the application
CMD ["npm", "start"]
# Run node directly so it receives SIGTERM on redeploy and can finish queued webhooks
CMD ["node", "dist/index.js"]