Skip to content

Commit

Permalink
fix: docker CI performance & release builds (#2659)
Browse files Browse the repository at this point in the history
## Description

- We now build the docker test CI jobs in a way that more closely
resembles the release process. It should compile the binaries and build
the image significantly faster now. (down from 8+ min to 2 min)
- Secrets are properly passed in to the reusable workflow so [release
docker builds should no longer
fail](https://github.com/n0-computer/iroh/actions/runs/10473026816/job/29005092378)

## Breaking Changes

<!-- Optional, if there are any breaking changes document them,
including how to migrate older code. -->

## Notes & open questions

<!-- Any notes, remarks or open questions you have to make about the PR.
-->

## Change checklist

- [x] Self-review.
- [ ] Documentation updates following the [style
guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text),
if relevant.
- [ ] Tests if relevant.
- [ ] All breaking changes documented.
  • Loading branch information
Arqu authored Aug 22, 2024
1 parent c70caaf commit d567231
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 9 deletions.
17 changes: 15 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,17 @@ jobs:
- name: Install sccache
uses: mozilla-actions/sccache-action@v0.0.5

- name: Prep
run: sudo apt-get install musl-tools -y

- name: Build iroh
run: cargo build --profile=dev-ci --all-features --bin iroh --target x86_64-unknown-linux-musl

- name: Prep bins
run: |
mkdir -p bins/linux/amd64
cp target/x86_64-unknown-linux-musl/dev-ci/iroh bins/linux/amd64/iroh
- name: Cleanup Docker
continue-on-error: true
run: |
Expand All @@ -445,12 +456,14 @@ jobs:
tags: n0computer/iroh-test:latest
target: iroh
platforms: linux/amd64
file: docker/Dockerfile
file: docker/Dockerfile.ci

- name: Run Docker image & stats test
run: |
docker run -p 9090:9090 -p 4919:4919/udp -Pd n0computer/iroh-test:latest --rpc-addr 0.0.0.0:4919 start
cargo run --bin iroh -- --rpc-addr 127.0.0.1:4919 stats
# Give the server time to start
sleep 3
target/x86_64-unknown-linux-musl/dev-ci/iroh --rpc-addr 127.0.0.1:4919 stats
codespell:
runs-on: ubuntu-latest
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:
uses: docker/build-push-action@v6
with:
context: .
push: true
push: ${{ github.event.inputs.publish }}
tags: n0computer/iroh:latest,n0computer/iroh:${{ github.event.inputs.release_version }}
target: iroh
platforms: linux/amd64,linux/arm64/v8
Expand All @@ -98,7 +98,7 @@ jobs:
uses: docker/build-push-action@v6
with:
context: .
push: true
push: ${{ github.event.inputs.publish }}
tags: n0computer/iroh-relay:latest,n0computer/iroh-relay:${{ github.event.inputs.release_version }}
target: iroh-relay
platforms: linux/amd64,linux/arm64/v8
Expand All @@ -108,7 +108,7 @@ jobs:
uses: docker/build-push-action@v6
with:
context: .
push: true
push: ${{ github.event.inputs.publish }}
tags: n0computer/iroh-dns-server:latest,n0computer/iroh-dns-server:${{ github.event.inputs.release_version }}
target: iroh-dns-server
platforms: linux/amd64,linux/arm64/v8
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ jobs:
docker:
needs: build_release
uses: './.github/workflows/docker.yaml'
secrets: inherit
with:
release_version: ${{ needs.build_release.outputs.release_version }}
base_hash: ${{ needs.build_release.outputs.base_hash }}
Expand Down
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ resolver = "2"
[profile.release]
debug = true

[profile.dev-ci]
inherits = 'dev'
opt-level = 1

[profile.optimized-release]
inherits = 'release'
debug = false
Expand Down
8 changes: 4 additions & 4 deletions docker/Dockerfile.ci
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
### Base image for iroh-relay and iroh-dns-server
FROM alpine:latest as base
FROM alpine:latest AS base
RUN apk update && apk add ca-certificates && update-ca-certificates


### Target image
FROM base as iroh
FROM base AS iroh
ARG TARGETPLATFORM

COPY bins/${TARGETPLATFORM}/iroh /iroh
Expand All @@ -20,7 +20,7 @@ ENTRYPOINT ["/iroh"]
CMD ["start"]

### Target image
FROM base as iroh-relay
FROM base AS iroh-relay
ARG TARGETPLATFORM

COPY bins/${TARGETPLATFORM}/iroh-relay /iroh-relay
Expand All @@ -36,7 +36,7 @@ ENTRYPOINT ["/iroh-relay"]
CMD [""]

### Target image
FROM base as iroh-dns-server
FROM base AS iroh-dns-server
ARG TARGETPLATFORM

COPY bins/${TARGETPLATFORM}/iroh-dns-server /iroh-dns-server
Expand Down

0 comments on commit d567231

Please sign in to comment.