This repository has been archived by the owner on Dec 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathDockerfile.buildkit
42 lines (40 loc) · 1.56 KB
/
Dockerfile.buildkit
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
# syntax=docker/dockerfile:1.2
# create a standard base image that has all the defaults
FROM node:14-stretch-slim as base
ARG DATABASE_URL
ARG SESSION_SECRET_KEY
ENV NODE_ENV=production
ENV PATH /home/node/app/node_modules/.bin:$PATH
ENV TINI_VERSION v0.19.0
WORKDIR /home/node/app
RUN apt-get update && apt-get install -y openssl --no-install-recommends \
&& rm -rf /var/lib/apt/lists/* \
&& chown -R node:node /home/node/app
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
RUN chmod +x /tini
RUN --mount=type=cache,target=/home/node/.cache/yarn YARN_CACHE_FOLDER=/home/node/.cache/yarn
USER node
COPY --chown=node:node package*.json yarn.lock* ./
RUN yarn install --frozen-lockfile --prefer-offline \
&& yarn cache clean --force
# create a build image
FROM base as build
ENV NODE_ENV=development
ENV DATABASE_URL=$DATABASE_URL
USER node
COPY --chown=node:node . .
RUN yarn install --prefer-offline && yarn cache clean --force \
&& blitz prisma migrate deploy --preview-feature \
&& blitz prisma generate && blitz build
# create a production image
FROM base as prod
ENV NODE_ENV=production
ENV SESSION_SECRET_KEY=$SESSION_SECRET_KEY
USER node
COPY --chown=node:node --from=build /home/node/app/.blitz /home/node/app/.blitz
COPY --chown=node:node --from=build /home/node/app/db /home/node/app/db
COPY --chown=node:node --from=build /home/node/app/public /home/node/app/public
COPY --chown=node:node --from=build /home/node/app/blitz.config.js /home/node/app/blitz.config.js
EXPOSE 3000
ENTRYPOINT ["/tini", "--"]
CMD blitz prisma generate && blitz start