-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dockerfile
63 lines (46 loc) · 1.41 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
FROM node:20-bookworm-slim as builder
ARG BUILD_NUMBER
ARG GIT_REF
ENV BUILD_NUMBER=${BUILD_NUMBER}
ENV GIT_REF=${GIT_REF}
RUN test -n "$BUILD_NUMBER" || (echo "BUILD_NUMBER not set" && false)
RUN test -n "$GIT_REF" || (echo "GIT_REF not set" && false)
RUN apt-get update && \
apt-get upgrade -y
WORKDIR /app
COPY . .
RUN npm ci --no-audit && \
export BUILD_NUMBER=${BUILD_NUMBER} && \
export GIT_REF=${GIT_REF} && \
npm run record-build-info
RUN npm prune --production
FROM node:20-bookworm-slim
LABEL maintainer="HMPPS Digital Studio <[email protected]>"
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
ENV TZ=Europe/London
RUN ln -snf "/usr/share/zoneinfo/$TZ" /etc/localtime && echo "$TZ" > /etc/timezone
# Create app directory
RUN mkdir /app && chown appuser:appgroup /app
USER 2000
WORKDIR /app
COPY --from=builder --chown=appuser:appgroup \
/app/package.json \
/app/package-lock.json \
/app/build-info.json \
/app/config.js \
/app/proxy.js \
/app/server.js \
/app/convert-hrtime.js \
./
COPY --from=builder --chown=appuser:appgroup \
/app/node_modules ./node_modules
ENV NODE_ENV=production
ENV PORT=3000
EXPOSE 3000
USER 2000
CMD [ "node", "server" ]