Skip to content

Commit

Permalink
FIX: Fix paths in docker builds (#491)
Browse files Browse the repository at this point in the history
* FIX: Fix paths in docker builds

* CI: Why is the job skipped...

* FIX: Remove .filter

* FIX: Filter non-crates

* BUILD: Enable binding build by default. Move source trigger to fendermint
  • Loading branch information
aakoshh authored Dec 20, 2023
1 parent cc07711 commit 879cf1b
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 37 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
target
fendermint/builtin-actors
contracts/cache
contracts/node-modules
18 changes: 9 additions & 9 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
uses: ./.github/workflows/contracts-prettier.yaml
needs: [changes]
if: >-
needs.changes.filter.outputs.contracts == 'true' ||
needs.changes.outputs.contracts == 'true' ||
github.ref == 'refs/heads/main'
contracts-test:
Expand All @@ -79,32 +79,32 @@ jobs:
uses: ./.github/workflows/fvm-utils.yaml
needs: [changes, license]
if: >-
needs.changes.filter.outputs.fvm-utils == 'true' ||
needs.changes.outputs.fvm-utils == 'true' ||
github.ref == 'refs/heads/main'
ipc:
uses: ./.github/workflows/ipc.yaml
needs: [changes, license]
if: >-
needs.changes.filter.outputs.contracts == 'true' ||
needs.changes.filter.outputs.ipc == 'true' ||
needs.changes.outputs.contracts == 'true' ||
needs.changes.outputs.ipc == 'true' ||
github.ref == 'refs/heads/main'
ipld-resolver:
uses: ./.github/workflows/ipld-resolver.yaml
needs: [changes, license]
if: >-
needs.changes.filter.outputs.ipld-resolver == 'true' ||
needs.changes.outputs.ipld-resolver == 'true' ||
github.ref == 'refs/heads/main'
fendermint-test:
uses: ./.github/workflows/fendermint-test.yaml
needs: [changes, license]
if: >-
needs.changes.filter.outputs.contracts == 'true' ||
needs.changes.filter.outputs.ipc == 'true' ||
needs.changes.filter.outputs.ipld-resolver == 'true' ||
needs.changes.filter.outputs.fendermint == 'true' ||
needs.changes.outputs.contracts == 'true' ||
needs.changes.outputs.ipc == 'true' ||
needs.changes.outputs.ipld-resolver == 'true' ||
needs.changes.outputs.fendermint == 'true' ||
github.ref == 'refs/heads/main'
fendermint-publish:
Expand Down
1 change: 0 additions & 1 deletion contracts/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ crytic-export/
.vscode
.idea
.env
.gen
broadcast/
out/

Expand Down
4 changes: 1 addition & 3 deletions contracts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ NETWORK ?= auto
# It is required by docker builds, but shouldn't be checked into git.
OUTPUT ?= out

IPC_ACTORS_CODE := $(shell find . -type f \( -name "*.sol" \))

deploy-ipc:
./ops/deploy.sh $(NETWORK)

Expand Down Expand Up @@ -36,7 +34,7 @@ compile-abi: | forge
./ops/compile-abi.sh $(OUTPUT)

rust-binding:
OUTPUT=$(OUTPUT) BUILD_BINDINGS=1 cargo build --locked --release --manifest-path ./binding/Cargo.toml -p ipc_actors_abis
OUTPUT=$(OUTPUT) cargo build --locked --release --manifest-path ./binding/Cargo.toml -p ipc_actors_abis

# commit-abi:
# ./ops/commit-abi.sh $(OUTPUT)
Expand Down
7 changes: 4 additions & 3 deletions contracts/binding/build.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions fendermint/.dockerignore

This file was deleted.

1 change: 1 addition & 0 deletions fendermint/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ cometbft
test-network
.idea
.make
.contracts-gen
18 changes: 9 additions & 9 deletions fendermint/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ BUILTIN_ACTORS_BUNDLE := $(PWD)/builtin-actors/output/bundle.car

IPC_ACTORS_DIR := $(PWD)/../contracts
IPC_ACTORS_OUT := $(IPC_ACTORS_DIR)/out
IPC_ACTORS_GEN := $(IPC_ACTORS_DIR)/.gen
IPC_ACTORS_CODE := $(shell find $(IPC_ACTORS_DIR) -type f \( -name "*.sol" \))
IPC_ACTORS_GEN := .contracts-gen

FENDERMINT_CODE := $(shell find . -type f \( -name "*.rs" -o -name "Cargo.toml" \) | grep -v target)

Expand Down Expand Up @@ -33,7 +34,7 @@ install: $(IPC_ACTORS_GEN)
cargo install --locked --path fendermint/app

# Using --release for testing because wasm can otherwise be slow.
test: $(BUILTIN_ACTORS_BUNDLE) $(IPC_ACTORS_OUT) $(IPC_ACTORS_GEN)
test: $(BUILTIN_ACTORS_BUNDLE) $(IPC_ACTORS_GEN)
FM_BUILTIN_ACTORS_BUNDLE=$(BUILTIN_ACTORS_BUNDLE) \
FM_CONTRACTS_DIR=$(IPC_ACTORS_OUT) \
cargo test --release --package 'fendermint_*'
Expand Down Expand Up @@ -73,14 +74,14 @@ docker-build: docker-deps $(FENDERMINT_CODE)
$(BUILDX_STORE) \
$(BUILDX_FLAGS) \
-f docker/Dockerfile \
-t $(BUILDX_TAG) $(PWD); \
-t $(BUILDX_TAG) $(PWD)/..; \
else \
cat docker/builder.local.Dockerfile docker/runner.Dockerfile > docker/Dockerfile ; \
DOCKER_BUILDKIT=1 \
docker build \
$(BUILDX_STORE) \
-f docker/Dockerfile \
-t fendermint:latest $(PWD); \
-t fendermint:latest $(PWD)/..; \
fi


Expand All @@ -94,11 +95,10 @@ $(BUILTIN_ACTORS_BUNDLE):
mkdir -p $(dir $@)
curl -L -o $@ https://github.com/filecoin-project/builtin-actors/releases/download/$(BUILTIN_ACTORS_TAG)/builtin-actors-mainnet.car

# Generate the ABI artifacts if we don't have them already.
$(IPC_ACTORS_GEN):
cd $(IPC_ACTORS_DIR) && make .gen

$(IPC_ACTORS_OUT): $(IPC_ACTORS_GEN)
# Regenerate the ABI artifacts if we don't have them already, or they changed.
$(IPC_ACTORS_GEN): $(IPC_ACTORS_CODE)
cd $(IPC_ACTORS_DIR) && make compile-abi
touch $@

.PHONY: protoc
protoc:
Expand Down
14 changes: 7 additions & 7 deletions fendermint/docker/builder.ci.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ FROM --platform=$BUILDPLATFORM ubuntu:latest as stripper

WORKDIR /app

# Copy the Cargo artifacts and Rust sources.
# Copy the Cargo artifacts and Rust sources everything; even though we only need Cargo.* artifacts and Rust sources.
COPY Cargo.toml Cargo.lock ./
COPY fendermint fendermint/
COPY . .

# Delete anything other than cargo files: Rust sources, config files, Markdown, etc.
RUN find fendermint -type f \! -name "Cargo.*" | xargs rm -rf
RUN find . -type f \! -name "Cargo.*" | xargs rm -rf

# Construct dummy sources. Add a print to help debug the case if we failed to properly replace the file.
RUN echo "fn main() { println!(\"I'm the dummy.\"); }" > fendermint/app/src/main.rs && \
for crate in $(find fendermint -name "Cargo.toml" | xargs dirname); do \
RUN echo "fn main() { println!(\"I'm the dummy.\"); }" > fendermint/fendermint/app/src/main.rs && \
for crate in $(find . -name "Cargo.toml" | xargs dirname | grep -v infra | grep -v node_modules | grep /); do \
touch $crate/src/lib.rs; \
done

Expand Down Expand Up @@ -76,12 +76,12 @@ RUN set -eux; \
COPY . .

# Need to invalidate build caches otherwise they won't be recompiled with the real code.
RUN find fendermint -type f \( -wholename "**/src/lib.rs" -o -wholename "**/src/main.rs" \) | xargs touch
RUN find . -type f \( -wholename "**/src/lib.rs" -o -wholename "**/src/main.rs" \) | xargs touch

# Do the final build.
RUN set -eux; \
case "${TARGETARCH}" in \
amd64) ARCH='x86_64' ;; \
arm64) ARCH='aarch64' ;; \
esac; \
cargo install --locked --root output --path fendermint/app --target ${ARCH}-unknown-linux-gnu
cargo install --locked --root output --path fendermint/fendermint/app --target ${ARCH}-unknown-linux-gnu
2 changes: 1 addition & 1 deletion fendermint/docker/builder.local.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ COPY . .
RUN --mount=type=cache,target=target \
--mount=type=cache,target=$RUSTUP_HOME,from=rust,source=$RUSTUP_HOME \
--mount=type=cache,target=$CARGO_HOME,from=rust,source=$CARGO_HOME \
cargo install --locked --root output --path fendermint/app
cargo install --locked --root output --path fendermint/fendermint/app
4 changes: 2 additions & 2 deletions fendermint/docker/runner.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ STOPSIGNAL SIGTERM
ENV FM_ABCI__LISTEN__HOST=0.0.0.0
ENV FM_ETH__LISTEN__HOST=0.0.0.0

COPY docker/.artifacts/bundle.car $FM_HOME_DIR/bundle.car
COPY docker/.artifacts/contracts $FM_HOME_DIR/contracts
COPY fendermint/docker/.artifacts/bundle.car $FM_HOME_DIR/bundle.car
COPY fendermint/docker/.artifacts/contracts $FM_HOME_DIR/contracts
COPY --from=builder /app/fendermint/app/config $FM_HOME_DIR/config
COPY --from=builder /app/output/bin/fendermint /usr/local/bin/fendermint

0 comments on commit 879cf1b

Please sign in to comment.