forked from ethereum-optimism/ecosystem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
53 lines (37 loc) · 1.65 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
FROM node:18-alpine AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
########################################
# STEP 1: BUILDER
########################################
FROM base AS builder
# install required dependencies for node-gyp
# context: https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md#node-gyp-alpine
RUN apk add --no-cache python3 make g++
WORKDIR /usr/src/monorepo
# copy just the lockfile to run pnpm fetch
COPY pnpm-lock.yaml ./
# https://pnpm.io/cli/fetch
# Fetches packages based on lockfile not package.json - cache is valid even if any other file than pnpm-lock.yaml changes
RUN pnpm fetch
# copy in all monorepo files
COPY . ./
# install monorepo dependencies, from the virtual store
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile --offline
# build all packages/apps
RUN pnpm nx run-many --target=build
# copy built paymaster-proxy app & isolated node_modules to prod/paymaster-proxy
#
# note: unexpected behavior of pnpm deploy (that will hopefully be fixed)
# - it ignores /dist folder because it is listed in the local gitignore. Have to add "dist" folder explicitly to "files" in package.json to include. (https://github.com/pnpm/pnpm/issues/7286)
RUN pnpm deploy --filter=paymaster-proxy --prod /prod/paymaster-proxy
########################################
# STEP 2: PAYMASTER-PROXY
########################################
FROM base AS paymaster-proxy
COPY --from=builder /prod/paymaster-proxy /prod/paymaster-proxy
WORKDIR /prod/paymaster-proxy
ENV NODE_EXTRA_CA_CERTS=/usr/local/share/ca-certificates/extra-ca-certificates.crt
EXPOSE 7310
CMD [ "pnpm", "start" ]