forked from ledokku/ledokku
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
57 lines (38 loc) · 1.34 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
# First step is to generate a static build for the client
FROM node:12-alpine AS BUILD_CLIENT
WORKDIR /usr/src/app
COPY package.json ./
COPY yarn.lock ./
COPY client/package.json ./client/package.json
RUN yarn install --frozen-lockfile
COPY client ./client
RUN cd client && yarn build
# Then we build the server
FROM node:12-alpine AS BUILD_SERVER
WORKDIR /usr/src/app
COPY package.json ./
COPY yarn.lock ./
COPY server/package.json ./server/package.json
# Prisma folder is needed to in order to generate the prisma client
COPY server/prisma ./server/prisma
RUN yarn install --frozen-lockfile
COPY server ./server
RUN cd server && yarn build
# Last step, we prepare everything for the server
FROM node:12-alpine
WORKDIR /usr/src/app
COPY package.json ./
COPY yarn.lock ./
COPY server/package.json ./server/package.json
# Prisma folder is needed in order to run the migrations
COPY server/prisma ./server/prisma
# Copy the client build folder so we can expose it to the user
COPY --from=BUILD_CLIENT /usr/src/app/client/build ./client/build
# Copy the compiled server code
COPY --from=BUILD_SERVER /usr/src/app/server/build ./server/build
ENV NODE_ENV production
# We install only the production dependencies to reduce the size of the final image
RUN yarn install --frozen-lockfile --production
WORKDIR /usr/src/app/server
EXPOSE 4000
CMD [ "yarn", "start" ]