-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.api
56 lines (33 loc) · 1.39 KB
/
Dockerfile.api
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
FROM node:alpine as deps-container
WORKDIR /tmp/deps
COPY --chown=node:node package.json .
COPY --chown=node:node package-lock.json .
COPY --chown=node:node packages/rimun-api/package.json ./packages/rimun-api/
RUN npm -w @rimun/api ci --include=dev
COPY --chown=node:node prisma ./prisma
RUN npm run db:generate
###
FROM node:alpine as build-container
WORKDIR /tmp/build
COPY --chown=node:node package.json .
COPY --chown=node:node tsconfig.base.json .
COPY --chown=node:node packages/rimun-api/package.json ./packages/rimun-api/
COPY --chown=node:node packages/rimun-api/tsconfig.json ./packages/rimun-api/
COPY --chown=node:node packages/rimun-api/src ./packages/rimun-api/src
COPY --chown=node:node --from=deps-container /tmp/deps/node_modules ./node_modules
RUN chown -R node:node /tmp/build
USER node
RUN npm -w @rimun/api run build
###
FROM node:alpine as runtime-container
WORKDIR /app
COPY --chown=node:node package.json ./
COPY --chown=node:node packages/rimun-api/package.json ./packages/rimun-api/
COPY --chown=node:node --from=deps-container /tmp/deps/node_modules ./node_modules
COPY --chown=node:node --from=build-container /tmp/build/packages/rimun-api/dist ./packages/rimun-api/dist
RUN chown -R node:node /app
USER node
ENV HOST="0.0.0.0"
ENV NODE_ENV=production
EXPOSE 3000
CMD ["node", "--trace-uncaught", "-r", "tsconfig-paths/register", "/app/packages/rimun-api/dist/src/index.js"]