forked from MyZubster-Ecosystem/myzubster
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
39 lines (27 loc) · 964 Bytes
/
Copy pathDockerfile
File metadata and controls
39 lines (27 loc) · 964 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# ============================================================
# MyZubster Backend — Dockerfile
# Node.js + Express + Mongoose API server
# ============================================================
# ---- Build stage ----
FROM node:20-alpine AS builder
WORKDIR /app
# Install dependencies first (layer caching)
COPY package.json package-lock.json ./
RUN npm ci --omit=dev --ignore-scripts
# ---- Runtime stage ----
FROM node:20-alpine AS runtime
WORKDIR /app
# Install curl for healthcheck
RUN apk add --no-cache curl
# Create non-root user
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
# Copy built node_modules and source from builder
COPY --from=builder /app/node_modules ./node_modules
COPY package.json ./
COPY src/ ./src/
# Switch to non-root user
USER appuser
EXPOSE 3009
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
CMD curl -f http://localhost:3009/health || exit 1
CMD ["node", "src/index.js"]