-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
47 lines (39 loc) · 1.22 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
#
# ----------- Base -----------
FROM node:17-alpine as deps
WORKDIR /code
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
# copy project file
COPY package.json package.json
COPY package-lock.json package-lock.json
RUN npm set progress=false && \
npm config set depth 0 && \
npm ci
## ----------- Builder -----------
FROM node:17-alpine AS builder
WORKDIR /code
COPY . .
COPY --from=deps /code/node_modules ./node_modules
ARG RELEASE
ARG SENTRY_AUTH_TOKEN
ENV SENTRY_RELEASE=${RELEASE}
ENV NEXT_PUBLIC_RELEASE=${RELEASE}
RUN npm run build
#
## ----------- Runner -----------
FROM node:17-alpine AS runner
WORKDIR /code
ARG APP=/code
ENV APP_USER=runner
RUN addgroup -S $APP_USER \
&& adduser -S $APP_USER -G $APP_USER \
&& mkdir -p ${APP}
RUN chown -R $APP_USER:$APP_USER ${APP}
COPY --from=builder /code/package.json ./package.json
COPY --from=builder /code/next.config.js ./
COPY --from=builder /code/next-i18next.config.js ./
COPY --from=builder /code/public ./public
COPY --from=builder /code/.next ./.next
COPY --from=builder /code/node_modules ./node_modules
CMD [ "npm", "start" ]