-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
38 lines (29 loc) · 923 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
34
35
36
37
38
# syntax=docker/dockerfile:1
ARG NODE_VERSION=20
FROM node:${NODE_VERSION}-alpine AS build
WORKDIR /app
COPY . .
# Install python/pip for node-pre-gyp
ENV PYTHONUNBUFFERED=1
RUN apk add --update --no-cache python3 && ln -sf python3 /usr/bin/python
RUN apk add --no-cache make g++
RUN npm ci
RUN npm run build
FROM node:${NODE_VERSION}-alpine AS production
WORKDIR /usr/src/app
COPY package*.json .
COPY public/ ./public
# Install python/pip for node-pre-gyp
ENV PYTHONUNBUFFERED=1
RUN apk add --update --no-cache python3 && ln -sf python3 /usr/bin/python
RUN apk add --no-cache make g++
RUN --mount=type=cache,target=/root/.npm \
npm ci --omit=dev
# RUN --mount=target=public,type=bind,source=public
COPY --from=build /app/dist ./dist
# Run the application as a non-root user.
USER node
# Expose the port that the application listens on.
# EXPOSE 3000
# Run the application.
ENTRYPOINT ["node", "dist/app.js"]