-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
82 lines (57 loc) · 2 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
FROM node:20-slim AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
FROM base AS src-deps
WORKDIR /usr/src/app
COPY package*.json .
COPY pnpm-*.yaml .
RUN mkdir -p ./externals/lifi-contract-types
COPY externals/lifi-contract-types/package*.json ./externals/lifi-contract-types
COPY externals/lifi-contract-types/yarn.lock ./externals/lifi-contract-types
RUN mkdir -p ./common
COPY common/package*.json ./common
COPY common/pnpm-*.yaml ./common
RUN mkdir -p ./fees-reporter
COPY fees-reporter/package*.json ./fees-reporter
COPY fees-reporter/pnpm-*.yaml ./fees-reporter
FROM src-deps AS build-deps
WORKDIR /usr/src/app
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
FROM src-deps AS build-deps-prod
WORKDIR /usr/src/app
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile --prod
FROM build-deps AS build-assets
# Set NODE_ENV environment variable
ENV NODE_ENV production
WORKDIR /usr/src/app
# Prepare for the TS Compilation of src dirs
COPY tsconfig*.json .
COPY externals/lifi-contract-types/tsconfig*.json ./externals/lifi-contract-types
COPY externals/lifi-contract-types/src ./externals/lifi-contract-types/src
COPY common/tsconfig*.json ./common
COPY common/src ./common/src
COPY fees-reporter/tsconfig*.json ./fees-reporter
COPY fees-reporter/src ./fees-reporter/src
# Build all available workspaces
RUN pnpm run -r build
FROM build-assets AS fees-reporter
WORKDIR /usr/src/app
RUN rm -rf **/src
RUN rm -rf **/tsconfig*
WORKDIR /usr/src/app/fees-reporter
EXPOSE 3000
CMD [ "node", "dist/main" ]
FROM build-assets AS fees-reporter-prod
# Set NODE_ENV environment variable
ENV NODE_ENV production
WORKDIR /usr/src/app
RUN --mount=type=cache,id=pnpm-prod,target=/pnpm/store pnpm store prune
RUN rm -rf **/node_modules
RUN --mount=type=cache,id=pnpm-prod,target=/pnpm/store pnpm install --prod
RUN rm -rf **/src
RUN rm ./tsconfig*
RUN rm -rf **/tsconfig*
WORKDIR /usr/src/app/fees-reporter
EXPOSE 3000
CMD [ "node", "dist/main" ]