Repository navigation
Expand file tree
/
Copy pathDockerfile.dev
More file actions
82 lines (69 loc) · 3.42 KB
/
Copy pathDockerfile.dev
File metadata and controls
82 lines (69 loc) · 3.42 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# syntax=docker/dockerfile:1
# Dockerfile.dev is a stripped down version of Dockerfile that is used for development purposes.
# It minimizes number of installs and builds to speed up the development process.
# Run this on local host only.
# Generated image is larger than production image. Do not use this for production.
FROM --platform=${BUILDPLATFORM:-amd64} node:26 AS build_dev
# Install zig toolchain
# Required to build the @lodestar/native workspace package
ARG TARGETARCH
ARG ZIG_VERSION=0.16.0
RUN case "${TARGETARCH}" in \
amd64) ZIG_ARCH=x86_64; ZIG_SHA256=70e49664a74374b48b51e6f3fdfbf437f6395d42509050588bd49abe52ba3d00 ;; \
arm64) ZIG_ARCH=aarch64; ZIG_SHA256=ea4b09bfb22ec6f6c6ceac57ab63efb6b46e17ab08d21f69f3a48b38e1534f17 ;; \
*) echo "unsupported TARGETARCH=${TARGETARCH}" && exit 1 ;; \
esac && \
curl -fsSL "https://ziglang.org/download/${ZIG_VERSION}/zig-${ZIG_ARCH}-linux-${ZIG_VERSION}.tar.xz" -o /tmp/zig.tar.xz && \
echo "${ZIG_SHA256} /tmp/zig.tar.xz" | sha256sum -c - && \
tar -xJf /tmp/zig.tar.xz -C /opt && \
ln -s /opt/zig-${ZIG_ARCH}-linux-${ZIG_VERSION}/zig /usr/local/bin/zig && \
rm /tmp/zig.tar.xz && \
zig version
WORKDIR /usr/app
# Node 26 no longer bundles corepack
RUN npm install -g corepack@0.36.0 && corepack enable
# Copy dependency manifests first for optimal layer caching.
# Only changes to package.json or lockfile will invalidate the install layer,
# source code changes will only invalidate the build layer.
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
COPY patches ./patches
COPY packages/api/package.json packages/api/
COPY packages/beacon-node/package.json packages/beacon-node/
COPY packages/builder/package.json packages/builder/
COPY packages/cli/package.json packages/cli/
COPY packages/config/package.json packages/config/
COPY packages/db/package.json packages/db/
COPY packages/era/package.json packages/era/
COPY packages/fork-choice/package.json packages/fork-choice/
COPY packages/logger/package.json packages/logger/
COPY bindings/package.json bindings/
COPY packages/params/package.json packages/params/
COPY packages/reqresp/package.json packages/reqresp/
COPY packages/spec-test-util/package.json packages/spec-test-util/
COPY packages/state-transition/package.json packages/state-transition/
COPY packages/test-utils/package.json packages/test-utils/
COPY packages/types/package.json packages/types/
COPY packages/utils/package.json packages/utils/
COPY packages/validator/package.json packages/validator/
RUN pnpm install --frozen-lockfile
# Build the native addon before copying the TypeScript sources so that
# source edits reuse this layer. Only Zig changes rebuild it.
COPY build.zig build.zig.zon ./
COPY src ./src
COPY bench ./bench
COPY scripts ./scripts
COPY test ./test
COPY bindings/napi ./bindings/napi
# Keep the Zig package and build caches outside the layer so that a Zig edit
# recompiles incrementally instead of refetching and rebuilding everything.
RUN --mount=type=cache,target=/root/.cache/zig \
--mount=type=cache,target=/usr/app/.zig-cache \
pnpm build:native
# Copy source code and build the TypeScript packages
COPY . .
RUN pnpm -r --filter "!@lodestar/native" --filter "!{.}" build
# Declare COMMIT arg after install+build layers to avoid cache invalidation
ARG COMMIT
RUN cd packages/cli && GIT_COMMIT=${COMMIT} pnpm write-git-data
ENV NODE_OPTIONS="--max-old-space-size=8192 --max-semi-space-size=64"
ENTRYPOINT ["node", "./packages/cli/bin/lodestar"]