2021-02-04 16:18:48 +03:00
|
|
|
{{={= =}=}}
|
2022-09-06 21:35:59 +03:00
|
|
|
FROM node:{= nodeMajorVersion =}-alpine AS node
|
2021-02-03 21:26:14 +03:00
|
|
|
|
|
|
|
|
|
|
|
FROM node AS base
|
|
|
|
RUN apk --no-cache -U upgrade # To ensure any potential security patches are applied.
|
|
|
|
|
|
|
|
|
|
|
|
FROM base AS server-builder
|
|
|
|
# Install packages needed to build native npm packages.
|
2022-04-21 15:33:49 +03:00
|
|
|
RUN apk add --no-cache build-base libtool autoconf automake python3
|
2021-02-03 21:26:14 +03:00
|
|
|
WORKDIR /app
|
|
|
|
# Install npm packages, resulting in node_modules/.
|
2022-09-06 21:35:59 +03:00
|
|
|
{=# usingServerPatches =}
|
|
|
|
COPY server/patches ./server/patches
|
|
|
|
{=/ usingServerPatches =}
|
2021-02-03 21:26:14 +03:00
|
|
|
COPY server/package*.json ./server/
|
|
|
|
RUN cd server && npm install
|
2021-02-04 16:18:48 +03:00
|
|
|
{=# usingPrisma =}
|
2021-02-03 21:26:14 +03:00
|
|
|
COPY db/schema.prisma ./db/
|
|
|
|
RUN cd server && npx prisma generate --schema=../db/schema.prisma
|
2021-02-04 16:18:48 +03:00
|
|
|
{=/ usingPrisma =}
|
2021-02-03 21:26:14 +03:00
|
|
|
|
|
|
|
|
|
|
|
# TODO: Use pm2?
|
|
|
|
# TODO: Use non-root user (node).
|
|
|
|
FROM base AS server-production
|
|
|
|
ENV NODE_ENV production
|
|
|
|
WORKDIR /app
|
|
|
|
COPY --from=server-builder /app/server/node_modules ./server/node_modules
|
|
|
|
COPY server/ ./server/
|
|
|
|
COPY db/ ./db/
|
|
|
|
EXPOSE ${PORT}
|
|
|
|
WORKDIR /app/server
|
|
|
|
ENTRYPOINT ["npm", "run", "start-production"]
|