Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
66 lines (51 loc) · 2.44 KB
/
Copy pathDockerfile
File metadata and controls
66 lines (51 loc) · 2.44 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
64
65
66
FROM node:22
# Install rsync
RUN apt-get update && apt-get install -y rsync
ENV NODE_ENV=production
# The layer cache below rsyncs .yarn/cache, so install there, not to the global cache
ENV YARN_ENABLE_GLOBAL_CACHE=false
WORKDIR /usr/src/app
COPY .yarn/releases .yarn/releases
COPY .yarnrc.yml yarn.lock package.json ./
# Copy only the elements needed for a Yarn install to take advantage of
# Docker's layer caching
# This is complex because we are working with multiple workspaces.
# Copy package JSON files with wildcards
# This scoops up all package.json files in the directory and subdirectories
# to deal with Yarn workspaces. However it requires BUILDKIT to be enabled,
# which is done by setting DOCKER_BUILDKIT=1 in the environment
RUN --mount=type=bind,target=/docker-context \
cd /docker-context/; \
find . -name "package.json" -mindepth 0 -maxdepth 5 -exec cp --parents "{}" /usr/src/app/ \;
# Load the cache from the previous build
RUN --mount=type=cache,target=/yarn-cache \
rsync -a /yarn-cache/ .yarn/cache/ \
&& yarn install --immutable \
&& rsync -a .yarn/cache/ /yarn-cache
# # Remove rsync
RUN apt-get remove -y rsync
# Chromium's headless shell, for the cached map views the server draws of
# itself (src/map-snapshots). The shell only — not full Chromium, Firefox or
# WebKit — at the build playwright-core expects, with its system libraries.
# And tini, so Chromium's exited helper processes are reaped (see ENTRYPOINT).
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
RUN yarn playwright-core install --with-deps chromium-headless-shell \
&& apt-get install -y --no-install-recommends tini \
&& rm -rf /var/lib/apt/lists/*
# # Now we can run the full copy command
COPY . ./
RUN yarn run build
EXPOSE 3000
ENV NODE_NO_WARNINGS=1
# Build information, set by CI. Last, so a new commit leaves the layers above cached.
ARG MACROSTRAT_VERSION MACROSTRAT_RELEASE MACROSTRAT_COMMIT MACROSTRAT_BUILD_DATE MACROSTRAT_REPOSITORY
ENV MACROSTRAT_VERSION=$MACROSTRAT_VERSION \
MACROSTRAT_RELEASE=$MACROSTRAT_RELEASE \
MACROSTRAT_COMMIT=$MACROSTRAT_COMMIT \
MACROSTRAT_BUILD_DATE=$MACROSTRAT_BUILD_DATE \
MACROSTRAT_REPOSITORY=$MACROSTRAT_REPOSITORY
# A real init as PID 1. Chromium's helpers outlive the browser that started
# them and are re-parented to PID 1; yarn never reaps them, so without this each
# render batch would leave zombies behind.
ENTRYPOINT ["/usr/bin/tini", "--"]
CMD ["yarn", "node", "./dist/server/index.mjs"]