-
Notifications
You must be signed in to change notification settings - Fork 2
/
dockerfile
71 lines (41 loc) · 1.5 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
FROM node:20-bullseye-slim as base
ENV NODE_ENV production
RUN apt-get update && apt-get install -y openssl
FROM base as deps
WORKDIR /myapp
ADD package.json ./
ADD client/package.json ./client/
ADD server/package.json ./server/
RUN npm run install-production
FROM base as production-deps
WORKDIR /myapp
COPY --from=deps /myapp/node_modules /myapp/node_modules
ADD package.json ./
ADD client/package.json ./client/
ADD server/package.json ./server/
RUN npm prune --production
RUN cd client && npm prune --production
RUN cd server && npm prune --production
# Build the app
FROM base as build
WORKDIR /myapp
COPY --from=deps /myapp/node_modules /myapp/node_modules
# COPY --from=deps /myapp/client/node_modules /myapp/client/node_modules
# COPY --from=deps /myapp/server/node_modules /myapp/server/node_modules
ADD server/prisma ./server
RUN cd server && npx prisma generate
ADD . .
RUN npm run build-production
# Finally, build the production image with minimal footprint
FROM base
WORKDIR /myapp
COPY --from=production-deps /myapp/node_modules /myapp/node_modules
# COPY --from=production-deps /myapp/client/node_modules /myapp/client/node_modules
COPY --from=build /myapp/node_modules/.prisma /myapp/node_modules/.prisma
COPY --from=build /myapp/server/build /myapp/server/build
COPY --from=build /myapp/client/dist /myapp/client/dist
COPY --from=build /myapp/client/public /myapp/client/public
ADD package.json ./
ADD server/package.json ./server/
ADD server/prisma ./server/
CMD npm run run-production