-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathDockerfile
51 lines (34 loc) · 1.12 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
FROM node:20.11.0 as build-api-stage
WORKDIR /app
COPY package*.json /app/
RUN npm ci
COPY . /app/
RUN npx nx build api:build:production --prod
RUN curl -sf https://gobinaries.com/tj/node-prune | sh
RUN npm prune --production
RUN node-prune
FROM node:20.11.0 as build-web-base
WORKDIR /app
COPY package*.json /app/
RUN npm ci
COPY ./ /app/
COPY ./nginx.conf /nginx.conf
FROM node:20.11.0 as build-web-stage
COPY --from=build-web-base . .
WORKDIR /app
RUN npx nx test web --configuration=ci
# RUN npx nx run web-e2e:e2e --configuration=ci
RUN npx nx build web:build:production
# Package React App and API together
FROM node:18-alpine
WORKDIR /app
RUN apk update && apk add --no-cache gettext moreutils
ENV JSFOLDER=/app/web/*.js
COPY --from=build-web-stage /app/dist/apps/web/ /app/web/
COPY --from=build-api-stage /app/dist/apps/api/ /app/api/
COPY --from=build-api-stage /app/node_modules/ /app/node_modules/
COPY ./healthcheck.js /app/healthcheck.js
COPY ./inject-env-and-start.sh /usr/bin/inject-env-and-start.sh
RUN chmod +x /usr/bin/inject-env-and-start.sh
ENV NODE_ENV production
ENTRYPOINT [ "inject-env-and-start.sh" ]