-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
63 lines (46 loc) · 1.34 KB
/
Dockerfile
File metadata and controls
63 lines (46 loc) · 1.34 KB
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
# This stage is used as a target in Lotic's global docker-compose at https://github.com/Lotic-ai/lotic-configs/blob/main/docker-compose.yml
FROM node:20.18.0-alpine AS dev
WORKDIR /app
# add necessary packages for building
RUN apk add --no-cache --upgrade alpine-sdk
# copy configuration files
COPY \
.env* \
.eslintrc.js \
.prettierignore \
.prettierrc \
nest-cli.json \
package.json \
tsconfig.build.json \
tsconfig.json \
tsconfig.scripts.json \
yarn.lock \
./
# copy source code
COPY src/ src/
FROM dev AS build
ARG NPM_TOKEN
# install dependencies
RUN yarn --frozen-lockfile
# run unit tests
RUN yarn test:unit
# build from source
RUN yarn build
# copy common graphql file
COPY src/modules/common/*.graphql /app/dist/graphql/
# copy graphql files from other modules
COPY src/modules/*/*/*.graphql /app/dist/graphql/
# prune dev dependencies, keep production dependencies
RUN yarn --frozen-lockfile --production --ignore-scripts --prefer-offline
FROM node:18.13.0-alpine AS prod
WORKDIR /app
ARG GIT_COMMIT
ENV GIT_COMMIT=${GIT_COMMIT}
# copy production-relevant configuration files
COPY package.json ./
# copy all dependencies
COPY --from=build /app/node_modules/ node_modules/
# copy compiled source
COPY --from=build /app/dist dist/
# CMD should prefer to call node directly, not through a yarn script
CMD ["node", "dist/main.js"]