2020-05-19 16:38:18 +02:00
|
|
|
# ---------------
|
2020-05-01 14:08:30 +02:00
|
|
|
# Install Dependencies
|
2020-05-19 16:38:18 +02:00
|
|
|
# ---------------
|
2023-11-30 20:07:47 +01:00
|
|
|
FROM node:18.18.2-alpine as deps
|
2020-12-16 13:52:59 +01:00
|
|
|
|
|
|
|
WORKDIR /app
|
2020-04-12 18:27:01 +02:00
|
|
|
|
2020-05-01 14:08:30 +02:00
|
|
|
# Install dependencies neccesary for node-gyp on node alpine
|
2020-05-19 16:38:18 +02:00
|
|
|
RUN apk add --update --no-cache \
|
2022-05-06 00:23:38 +02:00
|
|
|
libc6-compat \
|
2022-06-24 13:30:36 +02:00
|
|
|
python3 \
|
2022-05-06 00:23:38 +02:00
|
|
|
make \
|
|
|
|
g++
|
2020-12-16 13:52:59 +01:00
|
|
|
|
2020-04-12 18:27:01 +02:00
|
|
|
# Install app dependencies
|
2020-12-16 13:52:59 +01:00
|
|
|
COPY package.json package-lock.json ./
|
2022-02-23 13:57:39 +01:00
|
|
|
RUN npm ci
|
2020-12-16 13:52:59 +01:00
|
|
|
|
|
|
|
# ---------------
|
|
|
|
# Build App
|
|
|
|
# ---------------
|
|
|
|
FROM deps as build
|
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
# Set env variables
|
|
|
|
ARG BASE_PATH=""
|
|
|
|
ENV BASE_PATH=${BASE_PATH}
|
2021-12-11 17:33:32 +01:00
|
|
|
ARG NODE_ENV="production"
|
|
|
|
ENV NODE_ENV=${NODE_ENV}
|
2020-12-16 13:52:59 +01:00
|
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
2020-08-09 16:03:18 +02:00
|
|
|
|
2021-12-11 17:33:32 +01:00
|
|
|
# Build the NestJS and NextJS application
|
2020-08-09 16:03:18 +02:00
|
|
|
COPY . .
|
2022-04-04 16:55:35 +02:00
|
|
|
RUN npm run build:nest
|
|
|
|
RUN npm run build:next
|
2020-08-09 16:03:18 +02:00
|
|
|
|
|
|
|
# Remove non production necessary modules
|
|
|
|
RUN npm prune --production
|
2020-05-12 12:16:44 +02:00
|
|
|
|
2020-05-01 14:08:30 +02:00
|
|
|
# ---------------
|
2020-12-16 13:52:59 +01:00
|
|
|
# Release App
|
2020-05-01 14:08:30 +02:00
|
|
|
# ---------------
|
2023-11-30 20:07:47 +01:00
|
|
|
FROM node:18.18.2-alpine as final
|
2020-05-01 14:08:30 +02:00
|
|
|
|
2020-05-07 13:51:39 +02:00
|
|
|
WORKDIR /app
|
|
|
|
|
2020-12-16 13:52:59 +01:00
|
|
|
# Set env variables
|
|
|
|
ARG BASE_PATH=""
|
|
|
|
ENV BASE_PATH=${BASE_PATH}
|
2021-12-11 17:33:32 +01:00
|
|
|
ARG NODE_ENV="production"
|
|
|
|
ENV NODE_ENV=${NODE_ENV}
|
2020-12-16 13:52:59 +01:00
|
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
2020-04-12 18:27:01 +02:00
|
|
|
|
2022-02-23 13:57:39 +01:00
|
|
|
COPY --from=build /app/package.json ./
|
2022-05-06 00:23:38 +02:00
|
|
|
COPY --from=build /app/node_modules/ ./node_modules
|
2021-12-11 17:33:32 +01:00
|
|
|
|
|
|
|
# Copy NextJS files
|
|
|
|
COPY --from=build /app/src/client/public ./src/client/public
|
|
|
|
COPY --from=build /app/src/client/next.config.js ./src/client/
|
2022-02-09 18:33:41 +01:00
|
|
|
COPY --from=build /app/src/client/.next/ ./src/client/.next
|
2020-12-16 13:52:59 +01:00
|
|
|
|
2021-12-11 17:33:32 +01:00
|
|
|
# Copy NestJS files
|
|
|
|
COPY --from=build /app/dist/ ./dist
|
2020-12-16 13:52:59 +01:00
|
|
|
|
2021-12-11 17:33:32 +01:00
|
|
|
EXPOSE 3000
|
2020-04-13 07:30:19 +02:00
|
|
|
|
2022-05-06 00:23:38 +02:00
|
|
|
CMD [ "npm", "run", "start:prod" ]
|