-
Notifications
You must be signed in to change notification settings - Fork 18
/
Dockerfile
47 lines (40 loc) · 1.14 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
FROM node:20-alpine AS base
RUN mkdir -p /usr/app
WORKDIR /usr/app
# Build front
FROM base AS build-frontend
ARG BASE_API_URL
ENV BASE_API_URL=$BASE_API_URL
ARG BASE_SOCKET_URL
ENV BASE_SOCKET_URL=$BASE_SOCKET_URL
COPY ./front ./
RUN npm ci
RUN npm run build
# Build backend
FROM base AS build-backend
COPY ./back ./
RUN npm ci
RUN npm run build
# Release
FROM base AS release
ENV NODE_ENV=production
ENV STATIC_FILES_PATH=./public
COPY --from=build-backend /usr/app/dist ./
COPY --from=build-frontend /usr/app/dist $STATIC_FILES_PATH
COPY ./back/package.json ./
COPY ./back/package-lock.json ./
RUN npm ci --only=production
FROM nasdan/azure-pm2-nginx:nodejs-20-nginx-1.24
ENV NODE_ENV=production
ENV STATIC_FILES_PATH=./public
ENV MOCK_REPOSITORY=false
ENV CORS_ORIGIN=false
ENV API_URL=/api
COPY --from=release /usr/app ./
COPY nginx.conf /etc/nginx/conf.d/default.conf
ENV INTERNAL_PORT=3000
RUN sed -i -e 's|INTERNAL_PORT|'"$INTERNAL_PORT"'|g' /etc/nginx/conf.d/default.conf
CMD sh docker-entrypoint.sh && \
sed -i -e 's|PORT|80|g' /etc/nginx/conf.d/default.conf && \
pm2 start ./index.js --name "app" --env production && \
nginx -g 'daemon off;'