2022-12-13 13:34:59 +03:00
|
|
|
# NOTE: Why do we specify alpine version here?
|
|
|
|
# Because if not, we had situations where it would use the different version
|
|
|
|
# locally and on Github CI. This way we ensure exact version is used,
|
|
|
|
# and also have control over updating it (instead of update surprising us).
|
|
|
|
FROM node:18-alpine3.17 AS node
|
2022-03-01 23:42:31 +03:00
|
|
|
|
|
|
|
|
2022-12-15 01:41:10 +03:00
|
|
|
# We split Dockerfile into base, server-builder and server-production.
|
|
|
|
# This way we have separate situations -> in server-builder we build all
|
|
|
|
# we need to run the server, and then in server-production we start fresh
|
|
|
|
# and just copy what we need from server-builder, avoiding intermediate
|
|
|
|
# artifacts and any settings / pollution we don't need in production
|
|
|
|
# but only for building.
|
2022-03-01 23:42:31 +03:00
|
|
|
|
|
|
|
|
2022-12-15 01:41:10 +03:00
|
|
|
FROM node AS base
|
|
|
|
RUN apk --no-cache -U upgrade # To ensure any potential security patches are applied.
|
2022-12-13 13:34:59 +03:00
|
|
|
# TODO: Remove line below (installation of openssl 1.1) once Prisma adds support for
|
|
|
|
# openssl 3 on alpine. Alpine >= 3.17 has openssl 3 as default.
|
|
|
|
# Relevant GH issue: https://github.com/wasp-lang/wasp/issues/877
|
|
|
|
RUN apk add --no-cache openssl1.1-compat
|
2022-12-15 01:41:10 +03:00
|
|
|
|
|
|
|
|
|
|
|
FROM base AS server-builder
|
|
|
|
RUN apk add --no-cache build-base libtool autoconf automake
|
2022-03-01 23:42:31 +03:00
|
|
|
WORKDIR /app
|
|
|
|
# Install npm packages, resulting in node_modules/.
|
|
|
|
COPY server/package*.json ./server/
|
|
|
|
RUN cd server && npm install
|
|
|
|
|
|
|
|
|
|
|
|
# TODO: Use pm2?
|
|
|
|
# TODO: Use non-root user (node).
|
|
|
|
FROM base AS server-production
|
2022-12-15 01:41:10 +03:00
|
|
|
# In case they want to use python3 in their app.
|
|
|
|
RUN apk add --no-cache python3
|
2022-03-01 23:42:31 +03:00
|
|
|
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"]
|
2022-10-13 19:46:07 +03:00
|
|
|
|
|
|
|
|
|
|
|
# Any user-defined Dockerfile contents will be appended below.
|
|
|
|
|