-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotes.Dockerfile
More file actions
38 lines (31 loc) · 1.25 KB
/
notes.Dockerfile
File metadata and controls
38 lines (31 loc) · 1.25 KB
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
# syntax=docker/dockerfile:1
# Build stage: install only production dependencies
FROM node:24.12.0-alpine3.23 AS builder
WORKDIR /app
COPY package*.json ./
# Install reproducible, production-only deps and clean cache
RUN npm ci --only=production && npm cache clean --force
# Runtime stage: minimal image, non-root user
FROM node:24.12.0-alpine3.23 AS runner
# Install wget for health checks
RUN apk add --no-cache wget
ENV NODE_ENV=production
WORKDIR /app
# Copy only production dependencies from builder
COPY --from=builder --chown=node:node /app/node_modules ./node_modules
# Copy the application code to the container (only what's needed to run)
# Include package.json so Node recognizes ESM (type: module)
COPY --chown=node:node package.json ./
COPY --chown=node:node src/notes-api-server.js .
# Include the shared logger module required at runtime
COPY --chown=node:node src/logger.js .
COPY --chown=node:node src/public ./public
COPY --chown=node:node src/db ./db
COPY --chown=node:node src/models ./models
COPY --chown=node:node src/routes ./routes
# Drop privileges to non-root user provided by the Node image
USER node
# Expose the port the Express server will run on
EXPOSE 3000
# Define the command to run the Node.js server
CMD ["node", "notes-api-server.js"]