-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathDockerfile
More file actions
61 lines (50 loc) · 2.21 KB
/
Copy pathDockerfile
File metadata and controls
61 lines (50 loc) · 2.21 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
ARG NODE_VERSION=20.19.6
ARG NODE_VERSION_SHORT=20
# Toolchain plus the manifests, shared by both dependency stages. Nothing here
# depends on source, so editing src/ leaves every layer below this cached.
FROM node:${NODE_VERSION}-bookworm-slim AS base
WORKDIR /app
RUN apt-get update \
&& apt-get install -y build-essential curl git python3
# .yarnrc carries `ignore-engines true`, which some transitive dependencies need
# to install at all. It was previously swept in by `COPY . .`; copying the
# manifests without it breaks the install. It also raises yarn's network
# timeout: the multi-platform CI build runs both installs below at once for
# each platform, and under arm64 emulation yarn's default 30 s socket timeout
# expires mid-download (ESOCKETTIMEDOUT), failing the image build.
COPY package.json yarn.lock .yarnrc ./
# Full dependency tree, used only to compile.
FROM base AS deps
RUN yarn install
# Runtime dependency tree. Deliberately a sibling of `deps` rather than a step
# after the build: it depends only on the manifests, so editing source does not
# re-resolve it. Previously this ran as `rm -rf node_modules && yarn install
# --production` below the source COPY, so every source change reinstalled the
# whole tree twice.
FROM base AS proddeps
RUN yarn install --production
# Compile. Source changes invalidate this stage and nothing above it.
# node_modules is in .dockerignore, so this cannot clobber the install above.
FROM deps AS builder
COPY . .
RUN yarn build
# Runtime
FROM gcr.io/distroless/nodejs${NODE_VERSION_SHORT}-debian12
WORKDIR /app
# Add sh and mkdir for scripts
COPY --from=busybox:1.35.0-uclibc /bin/sh /bin/sh
COPY --from=busybox:1.35.0-uclibc /bin/mkdir /bin/mkdir
COPY --from=proddeps /app/node_modules ./node_modules/
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/dist/ ./dist/
COPY ./migrations /app/migrations
COPY ./docker-entrypoint.sh /app/docker-entrypoint.sh
COPY ./healthcheck.sh /app/healthcheck.sh
COPY ./docs/openapi.yaml /app/docs/openapi.yaml
COPY ./resources /app/resources
VOLUME /app/data
EXPOSE 4000
HEALTHCHECK CMD /bin/sh healthcheck.sh
LABEL org.opencontainers.image.title="ar.io Core Service"
# Start
ENTRYPOINT [ "/bin/sh", "docker-entrypoint.sh" ]