forked from kentcdodds/kentcdodds.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
66 lines (47 loc) · 1.43 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# base node image
FROM node:16-bullseye-slim as base
# install open ssl for prisma and ffmpeg for the call kent functionality
RUN apt-get update && apt-get install -y openssl ffmpeg
# install all node_modules, including dev
FROM base as deps
ENV CYPRESS_INSTALL_BINARY=0
ENV HUSKY_SKIP_INSTALL=1
RUN mkdir /app/
WORKDIR /app/
ADD package.json package-lock.json ./
ADD other/patches ./other/patches
RUN npm install --production=false
# TODO: enable this again. It was having trouble with v1 of Remix
RUN npx metronome setup
# setup production node_modules
FROM base as production-deps
RUN mkdir /app/
WORKDIR /app/
COPY --from=deps /app/node_modules /app/node_modules
ADD package.json package-lock.json /app/
RUN npm prune --production
# build app
FROM base as build
ARG COMMIT_SHA
ENV COMMIT_SHA=$COMMIT_SHA
RUN mkdir /app/
WORKDIR /app/
COPY --from=deps /app/node_modules /app/node_modules
# schema doesn't change much so these will stay cached
ADD prisma .
RUN npx prisma generate
# app code changes all the time
ADD . .
RUN npm run build
# build smaller image for running
FROM base
ENV NODE_ENV=production
RUN mkdir /app/
WORKDIR /app/
COPY --from=production-deps /app/node_modules /app/node_modules
COPY --from=build /app/node_modules/.prisma /app/node_modules/.prisma
COPY --from=build /app/build /app/build
COPY --from=build /app/public /app/public
COPY --from=build /app/server-build /app/server-build
ADD . .
CMD ["npm", "run", "start"]