-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
39 lines (30 loc) · 1.13 KB
/
Dockerfile
File metadata and controls
39 lines (30 loc) · 1.13 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
39
# --------------------
# Stage 1: Build Stage
# --------------------
# Use slim version of Node.js 22 for smaller image size
FROM node:22-slim AS build
# Set working directory inside the container
WORKDIR /app
# Copy only package.json and package-lock.json
# (This allows Docker to cache npm install step if dependencies don't change)
COPY package*.json ./
# Install production dependencies only
# - `npm ci` (ci - Clean Install) ensures clean and fast installation
# - `--omit=dev` skips dev dependencies (like testing, linting tools)
RUN npm install
# Now copy the rest of your application code
COPY . .
# ----------------------------
# Stage 2: Production Stage (Distroless)
# ----------------------------
# Use very small distroless image that has only Node.js runtime
FROM gcr.io/distroless/nodejs22-debian12
# Set working directory
WORKDIR /app
# Copy built app + node_modules from build stage
COPY --from=build /app /app
# Expose the port your server listens on
EXPOSE 8085
# Start the server
# (Distroless will automatically use "index.js" if present, but CMD is better for clarity)
CMD ["index.js"]