-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
49 lines (35 loc) · 1.01 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
# First stage
FROM node:22.12-bookworm-slim as builder
ARG BUILD_NUMBER
ARG GIT_REF
ARG GIT_DATE
RUN apt-get update && \
apt-get upgrade -y
WORKDIR /app
COPY . .
RUN npm ci --no-audit --ignore-scripts && \
npm run build && \
export BUILD_NUMBER=${BUILD_NUMBER:-1_0_0} && \
export GIT_REF=${GIT_REF:-dummy} && \
export GIT_DATE="${GIT_DATE:-dummy}" && \
npm run record-build-info && \
npm prune --production
# Second stage
FROM node:22.12-bookworm-slim
LABEL maintainer="HMPPS Digital Studio <info@digital.justice.gov.uk>"
RUN apt-get update && \
apt-get upgrade -y && \
apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/*
RUN addgroup --gid 2000 --system appgroup && \
adduser --uid 2000 --system appuser --gid 2000
RUN mkdir /app && chown appuser:appgroup /app
WORKDIR /app
COPY --from=builder --chown=appuser:appgroup /app /app
ENV BUILD_NUMBER=${BUILD_NUMBER}
ENV GIT_REF=${GIT_REF}
ENV GIT_DATE=${GIT_DATE}
ENV PORT=3000
EXPOSE 3000
USER 2000
CMD [ "npm", "start" ]