-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
51 lines (38 loc) · 1.32 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
# NB: Når Node-versjon endres, bør samme endring også gjøres i:
# - .nvmrc
# - .github/dependabot.yml (fjern versjonspin for docker)
# - packages.json under "engines" (her leter dependabot npm)
# - .ncurc.js (automatiske oppdateringer for node-types)
# pt er vi på node 18 fordi ellers plager dekoratoren oss med "body has already been consumed"
FROM node:18-alpine AS dependencies
WORKDIR /app
COPY package.json .
COPY package-lock.json .
COPY .npmrc.dockerbuild .npmrc
RUN --mount=type=secret,id=NODE_AUTH_TOKEN NODE_AUTH_TOKEN=$(cat /run/secrets/NODE_AUTH_TOKEN) \
npm ci --prefer-offline --no-audit
FROM node:18-alpine AS builder
ARG DIGISOS_ENV
ARG LOGIN_SESSION_API_URL
ARG LOGOUT_URL
ENV NEXT_PUBLIC_DIGISOS_ENV=${DIGISOS_ENV}
ENV LOGIN_SESSION_API_URL=${LOGIN_SESSION_API_URL}
ENV LOGOUT_URL=${LOGOUT_URL}
WORKDIR /app
COPY --from=dependencies /app/node_modules/ node_modules/
COPY . .
RUN npm run orval
RUN npm run build
RUN npm prune --production
FROM gcr.io/distroless/nodejs18-debian12 AS runner
ARG DIGISOS_ENV
ENV NEXT_PUBLIC_DIGISOS_ENV=${DIGISOS_ENV}
ENV PORT=8080
ENV HOSTNAME=0.0.0.0
ENV NODE_ENV=production
WORKDIR /app
COPY --from=builder --chown=1069:1069 /app/build build
COPY --from=builder /app/node_modules/ node_modules/
COPY package.json .
COPY . .
CMD ["./node_modules/next/dist/bin/next", "start"]