forked from freeCodeCamp/chapter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.Dockerfile
41 lines (30 loc) · 1.05 KB
/
client.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
FROM node:18.16 as development
WORKDIR /usr/chapter/
FROM development as build
ARG NEXT_PUBLIC_DEPLOYMENT_ENVIRONMENT=production
ARG NEXT_PUBLIC_USE_AUTH0=true
ARG NEXT_PUBLIC_AUTH0_DOMAIN
ARG NEXT_PUBLIC_AUTH0_CLIENT_ID
ARG NEXT_PUBLIC_AUTH0_AUDIENCE
ARG NEXT_PUBLIC_SERVER_URL
ARG NEXT_PUBLIC_CLIENT_URL
# We need the dev dependencies to build the app, but this needs to be configurable
# so we can create test builds
ARG NODE_ENV=development
COPY client ./client
COPY common ./common
COPY package*.json ./
# Regardless of the NODE_ENV, we need to install dev dependencies to build the
# app. They will not be included in the final image.
RUN npm ci -w=client --ignore-scripts --include=dev
RUN npm -w=client run build
FROM node:18-alpine3.17 as production
WORKDIR /usr/chapter/
COPY --from=build /usr/chapter/client/.next ./client/.next
COPY client/public ./client/public
COPY package*.json ./
COPY client/package.json ./client/package.json
RUN npm ci -w=client --ignore-scripts --omit=dev
EXPOSE 3000
WORKDIR /usr/chapter/client
CMD [ "npm", "run", "start" ]