Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 5 additions & 35 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,41 +1,11 @@
# Stage 1: Build
FROM node:18-alpine AS builder

# Set working directory
FROM node:24 AS builder
WORKDIR /app

# Install dependencies
COPY package.json package-lock.json ./
RUN npm ci --only=production

# Copy source code
COPY . .
RUN npm ci --omit=dev
COPY . ./

# Stage 2: Production
FROM node:18-alpine

# Set working directory
FROM gcr.io/distroless/nodejs24-debian12 AS production
WORKDIR /app

# Create a non-root user
RUN addgroup -S appgroup && adduser -S appuser -G appgroup

# Copy dependencies from builder
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app ./

# Set environment variables
ENV NODE_ENV=production

# Expose port
EXPOSE 5001

# Switch to non-root user
USER appuser

# Start the server
CMD ["npm", "start"]

# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:5001/health || exit 1
CMD ["src/index.js"]
Loading