-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
62 lines (34 loc) · 1.19 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
# Build React app
FROM node:lts-alpine AS webBuilder
WORKDIR /app
ENV INLINE_RUNTIME_CHUNK=false
COPY web/package.json web/yarn.lock web/tsconfig.json /app/
RUN yarn --version && yarn
COPY web/public/ /app/public
COPY web/src/ /app/src/
RUN yarn build
# Build NestJs app
FROM node:lts-alpine AS apiBuilder
WORKDIR /app
COPY api/package.json api/yarn.lock api/tsconfig.json api/nest-cli.json api/tsconfig.build.json api/tsconfig.production.json api/prisma/ /app/
RUN yarn --version && yarn
RUN yarn prisma generate
COPY api/src/ /app/src/
RUN yarn build
# Production container
FROM node:lts-alpine
LABEL org.opencontainers.image.authors="Chao Tzu-Hsien"
WORKDIR /app
RUN addgroup -S conote && adduser -S conote -G conote
COPY --chown=conote api/package.json api/yarn.lock api/nest-cli.json api/prisma/ /app/
RUN chown -R conote:conote /app
USER conote:conote
RUN yarn --version && yarn --prod
RUN yarn prisma generate
# Copy default configuration
COPY api/config/ /app/config
COPY --from=webBuilder --chown=conote /app/build /app/client
# Copy built Javascript from apiBuild container
COPY --from=apiBuilder --chown=conote /app/dist /app/dist
EXPOSE 8080
ENTRYPOINT ["yarn", "start:prod"]