Skip to content

Commit

Permalink
Minor improvements to repro builds with Docker
Browse files Browse the repository at this point in the history
  • Loading branch information
rvagg committed Jan 23, 2025
1 parent 2e0f0e4 commit bf92dac
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 11 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target/
18 changes: 16 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
FROM rust:1.81.0-bookworm@sha256:7b7f7ae5e49819e708369d49925360bde2af4f1962842e75a14af17342f08262

ARG USER_ID
ARG GROUP_ID

RUN groupadd -g ${GROUP_ID} user && \
useradd -m -u ${USER_ID} -g user user

USER user

WORKDIR /usr/src/builtin-actors

# Install the compiler. Unfortunately, the rust docker container doesn't actually contain the rust
# compiler...
COPY ./rust-toolchain.toml .
RUN rustup show
RUN rustup toolchain install $(cat rust-toolchain.toml | grep channel | cut -d '"' -f 2) && \
rustup component add rustfmt clippy && \
rustup show

USER root

# Then checkout a clean copy of the repo.
RUN --mount=type=bind,rw,target=/tmp/repo \
echo "Building $(git -C /tmp/repo rev-parse HEAD)" && \
git --git-dir /tmp/repo/.git --work-tree . checkout -f HEAD

ENTRYPOINT ["/bin/bash", "-c"]
USER user

ENTRYPOINT ["/bin/bash", "-c"]
27 changes: 18 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
SHELL=/usr/bin/env bash

DOCKER := docker
DOCKER_IMAGE_NAME := builtin-actors-builder
DOCKER_RUN_OPTS := --rm -u $$(id -u):$$(id -g) -v $(PWD)/output:/usr/src/builtin-actors/output

# Run cargo fmt
rustfmt:
cargo fmt --all --check
Expand All @@ -17,54 +21,56 @@ test:
cargo test --workspace

docker-builder:
docker build . -t builtin-actors-builder
$(DOCKER) build --build-arg USER_ID=$$(id -u) --build-arg GROUP_ID=$$(id -g) . -t $(DOCKER_IMAGE_NAME); \

# Create a bundle in a deterministic location
bundle:
cargo run -- -o output/builtin-actors.car

bundle-repro: docker-builder
docker run -e BUILD_FIL_NETWORK --rm -v `pwd`/output:/usr/src/builtin-actors/output builtin-actors-builder "make bundle"
$(DOCKER) run -e BUILD_FIL_NETWORK $(DOCKER_RUN_OPTS) $(DOCKER_IMAGE_NAME) "make bundle"

# Create all canonical network bundles
all-bundles: bundle-mainnet bundle-caterpillarnet bundle-butterflynet bundle-calibrationnet bundle-devnet bundle-testing bundle-testing

all-bundles-repro: bundle-mainnet-repro bundle-caterpillarnet-repro bundle-butterflynet-repro bundle-calibrationnet-repro bundle-devnet-repro bundle-testing-repro

bundle-mainnet:
BUILD_FIL_NETWORK=mainnet cargo run -- -o output/builtin-actors-mainnet.car

bundle-mainnet-repro: docker-builder
docker run --rm -v `pwd`/output:/usr/src/builtin-actors/output builtin-actors-builder "make bundle-mainnet"
$(DOCKER) run $(DOCKER_RUN_OPTS) $(DOCKER_IMAGE_NAME) "make bundle-mainnet"

bundle-caterpillarnet:
BUILD_FIL_NETWORK=caterpillarnet cargo run -- -o output/builtin-actors-caterpillarnet.car

bundle-caterpillarnet-repro: docker-builder
docker run --rm -v `pwd`/output:/usr/src/builtin-actors/output builtin-actors-builder "make bundle-caterpillarnet"
$(DOCKER) run $(DOCKER_RUN_OPTS) $(DOCKER_IMAGE_NAME) "make bundle-caterpillarnet"

bundle-butterflynet:
BUILD_FIL_NETWORK=butterflynet cargo run -- -o output/builtin-actors-butterflynet.car

bundle-butterflynet-repro: docker-builder
docker run --rm -v `pwd`/output:/usr/src/builtin-actors/output builtin-actors-builder "make bundle-butterflynet"
$(DOCKER) run $(DOCKER_RUN_OPTS) $(DOCKER_IMAGE_NAME) "make bundle-butterflynet"

bundle-calibrationnet:
BUILD_FIL_NETWORK=calibrationnet cargo run -- -o output/builtin-actors-calibrationnet.car

bundle-calibrationnet-repro: docker-builder
docker run --rm -v `pwd`/output:/usr/src/builtin-actors/output builtin-actors-builder "make bundle-calibrationnet"
$(DOCKER) run $(DOCKER_RUN_OPTS) $(DOCKER_IMAGE_NAME) "make bundle-calibrationnet"

bundle-devnet:
BUILD_FIL_NETWORK=devnet cargo run -- -o output/builtin-actors-devnet.car

bundle-devnet-repro: docker-builder
docker run --rm -v `pwd`/output:/usr/src/builtin-actors/output builtin-actors-builder "make bundle-devnet"
$(DOCKER) run $(DOCKER_RUN_OPTS) $(DOCKER_IMAGE_NAME) "make bundle-devnet"

bundle-testing:
BUILD_FIL_NETWORK=testing cargo run -- -o output/builtin-actors-testing.car
BUILD_FIL_NETWORK=testing-fake-proofs cargo run -- -o output/builtin-actors-testing-fake-proofs.car

bundle-testing-repro: docker-builder
docker run --rm -v `pwd`/output:/usr/src/builtin-actors/output builtin-actors-builder "make bundle-testing"
$(DOCKER) run $(DOCKER_RUN_OPTS) $(DOCKER_IMAGE_NAME) "make bundle-testing"

# Check if the working tree is clean.
check-clean:
Expand All @@ -74,4 +80,7 @@ check-clean:
}

.PHONY: rustfmt check check-clean test bundle
.PHONY: all-bundles bundle-mainnet bundle-caterpillarnet bundle-butterflynet bundle-calibrationnet bundle-devnet bundle-testing bundle-mainnet-repro bundle-caterpillarnet-repro bundle-butterflynet-repro bundle-calibrationnet-repro bundle-devnet-repro bundle-testing-repro docker-builder
.PHONY: all-bundles bundle-mainnet bundle-caterpillarnet bundle-butterflynet bundle-calibrationnet \
bundle-devnet bundle-testing all-bundles-repro bundle-mainnet-repro bundle-caterpillarnet-repro \
bundle-butterflynet-repro bundle-calibrationnet-repro bundle-devnet-repro bundle-testing-repro \
docker-builder

0 comments on commit bf92dac

Please sign in to comment.