-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
33 lines (26 loc) · 1007 Bytes
/
Dockerfile
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
# Build stage for amd64 architecture
FROM --platform=linux/amd64 node:gallium-alpine3.18 AS builder-amd64
WORKDIR /app
# Copy the package.json and package-lock.json to the container
COPY ./src/package*.json .
RUN npm ci --ignore-scripts
# Copy the rest of the application code to the container
COPY ./src .
# Build stage for arm64/v8 architecture
FROM --platform=linux/arm64/v8 node:gallium-alpine3.18 AS builder-arm64
WORKDIR /app
# Copy the package.json and package-lock.json to the container
COPY ./src/package*.json .
RUN npm ci --ignore-scripts
# Copy the rest of the application code to the container
COPY ./src .
# Production stage
FROM node:gallium-alpine3.18 AS runtime
RUN addgroup -S nonroot && adduser -S nonroot -G nonroot
WORKDIR /app
# Copy the files from the appropriate builder stage based on the target architecture
COPY --from=builder-amd64 /app /app
COPY --from=builder-arm64 /app /app
USER nonroot
# Set the default command to run when starting the container
CMD ["npm", "start"]