final product

This commit is contained in:
2025-12-04 15:37:56 -07:00
parent d9bddd8715
commit 6b746d466f
12 changed files with 399 additions and 348 deletions

View File

@@ -1,49 +1,28 @@
# ---- Builder Stage ----
# Use official Node.js 20 (Alpine)
FROM node:20-alpine AS builder
# Install init system
RUN apk add --no-cache dumb-init
# App dir
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install production deps
RUN npm ci --only=production && npm cache clean --force
# ---- Final Stage ----
FROM node:20-alpine
COPY . .
LABEL maintainer="your-email@example.com"
LABEL org.opencontainers.image.source="https://github.com/yourname/uta-gtfs-mysql"
RUN npm run build || echo "No build step needed"
# Install dumb-init + MySQL client (optional but common)
RUN apk add --no-cache dumb-init mysql-client
# Create non-root user
RUN addgroup -g 1001 -S nodejs \
&& adduser -S utauser -u 1001
FROM node:20-alpine AS production
WORKDIR /app
# Copy node_modules from builder
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app ./
# Copy app source
COPY . .
RUN addgroup -g 1001 -S nodejs && \
adduser -S uta-sync -u 1001
RUN chown -R utauser:nodejs /app
USER utauser
USER uta-sync
# Healthcheck you may want to change port if needed
HEALTHCHECK --interval=30s --timeout=3s --start-period=60s --retries=3 \
CMD wget -qO- http://localhost:3000/ || exit 1
EXPOSE 1001
EXPOSE 3000
ENTRYPOINT ["dumb-init", "--"]
CMD ["node", "server.js"]