-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile.web
38 lines (31 loc) · 1.11 KB
/
Dockerfile.web
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
# Look this: https://github.com/osscameroon/blog/blob/main/Dockerfile - lighter docker image
FROM node:14-buster AS setup
WORKDIR /app
COPY frontend/package.json ./
RUN npm install
COPY frontend .
FROM setup AS build
ARG NEXT_PUBLIC_API_URL
ARG NEXT_PUBLIC_API_DOC_URL
ARG NEXT_PUBLIC_GRAPHQL_URL
ARG NEXT_PUBLIC_GA_ID
ARG NEXT_PUBLIC_CLIENT_ORIGIN
# https://www.saltycrane.com/blog/2021/04/buildtime-vs-runtime-environment-variables-nextjs-docker/
ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL
ENV NEXT_PUBLIC_API_DOC_URL=$NEXT_PUBLIC_API_DOC_URL
ENV NEXT_PUBLIC_GRAPHQL_URL=$NEXT_PUBLIC_GRAPHQL_URL
ENV NEXT_PUBLIC_GA_ID=$NEXT_PUBLIC_GA_ID
ENV NEXT_PUBLIC_CLIENT_ORIGIN=$NEXT_PUBLIC_CLIENT_ORIGIN
ENV NODE_ENV=production
WORKDIR /build
COPY --from=setup /app ./
RUN npm run build
FROM node:14-alpine AS production
ENV NODE_ENV=production
WORKDIR /app
COPY --chown=node:node --from=build /build/package*.json ./
COPY --chown=node:node --from=build /build/.next ./.next
COPY --chown=node:node --from=build /build/public ./public
RUN npm install next && chown node:node -R node_modules package-lock.json
EXPOSE 3000
CMD npm run start