Skip to content

Commit 0b09b28

Browse files
committed
feat: add shadow build in Makefile and Dockerfile
1 parent 42a86af commit 0b09b28

2 files changed

Lines changed: 40 additions & 2 deletions

File tree

Dockerfile

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,29 @@ ENV RUSTFLAGS="$RUSTFLAGS"
3030
ARG FEATURES=""
3131
ENV FEATURES=$FEATURES
3232

33+
# Disable default features (e.g. for `shadow-integration`, which must drop the
34+
# default `jemalloc` and `devnet4` features). Empty for a normal build.
35+
ARG NO_DEFAULT_FEATURES=""
36+
ENV NO_DEFAULT_FEATURES=$NO_DEFAULT_FEATURES
37+
38+
# `--locked` by default; the Shadow build injects an uncommitted `[patch]` and so
39+
# must build unlocked (pass LOCKED= empty).
40+
ARG LOCKED="--locked"
41+
ENV LOCKED=$LOCKED
42+
3343
# Build dependencies
34-
RUN cargo chef cook --profile $BUILD_PROFILE --features "$FEATURES" --recipe-path recipe.json
44+
RUN cargo chef cook --profile $BUILD_PROFILE $NO_DEFAULT_FEATURES --features "$FEATURES" --recipe-path recipe.json
3545

3646
# Build application
3747
COPY --exclude=.git --exclude=dist . .
38-
RUN cargo build --profile $BUILD_PROFILE --features "$FEATURES" --locked --bin ream
48+
49+
# Shadow simulator compatibility: the quinn-udp fallback is a Cargo `[patch]`,
50+
# which cannot be feature-gated and is therefore not committed. Set SHADOW=1 to
51+
# inject it into the manifest before building.
52+
ARG SHADOW=""
53+
RUN if [ -n "$SHADOW" ]; then bash shadow/inject-patch.sh; fi
54+
55+
RUN cargo build --profile $BUILD_PROFILE $NO_DEFAULT_FEATURES --features "$FEATURES" $LOCKED --bin ream
3956

4057
# ARG is not resolved in COPY so we have to hack around it by copying the
4158
# binary to a temporary location

Makefile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ BIN_DIR = "dist/bin"
66
# Cargo features for builds.
77
FEATURES ?=
88

9+
# Devnet feature selected for Shadow builds (devnet4/devnet5 are mutually
10+
# exclusive, and `--no-default-features` drops the default `devnet4`).
11+
SHADOW_DEVNET ?= devnet5
12+
913
# Cargo profile for builds.
1014
PROFILE ?= release
1115

@@ -123,6 +127,23 @@ pr: lint update-book-cli clean-deps test # Run all checks for a PR.
123127
build-%:
124128
cross build --bin ream --target $* --features "$(FEATURES)" --profile "$(PROFILE)" $(EXTRA_FLAGS)
125129

130+
##@ Shadow simulator
131+
132+
.PHONY: shadow-build
133+
shadow-build: # Shadow-compatible binary (single-threaded, no jemalloc, quinn-udp patch).
134+
./shadow/build.sh cargo build --profile "$(PROFILE)" \
135+
--no-default-features --features "shadow-integration $(SHADOW_DEVNET)" --bin ream
136+
137+
.PHONY: shadow-docker-build
138+
shadow-docker-build: # Build a Shadow-compatible Docker image, tagged ...:latest-shadow.
139+
docker build --file ./Dockerfile . \
140+
--build-arg SHADOW=1 \
141+
--build-arg NO_DEFAULT_FEATURES=--no-default-features \
142+
--build-arg FEATURES="shadow-integration $(SHADOW_DEVNET)" \
143+
--build-arg LOCKED= \
144+
--build-arg BUILD_PROFILE=$(PROFILE) \
145+
--tag ghcr.io/reamlabs/ream:latest-shadow
146+
126147
.PHONY: docker-build-push
127148
docker-build-push:
128149
$(MAKE) build-x86_64-unknown-linux-gnu

0 commit comments

Comments
 (0)