-
Notifications
You must be signed in to change notification settings - Fork 131
Build Docker image from source via cargo install #2595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,37 +17,7 @@ defaults: | |
| shell: bash | ||
|
|
||
| jobs: | ||
| build: | ||
| strategy: | ||
| matrix: | ||
| include: | ||
| - runs-on: ubuntu-latest | ||
| arch: amd64 | ||
| - runs-on: ubuntu-24.04-arm | ||
| arch: arm64 | ||
| runs-on: ${{ matrix.runs-on }} | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
| with: | ||
| ref: ${{ github.event_name == 'workflow_dispatch' && inputs.ref || github.ref }} | ||
|
|
||
| - name: Install build dependencies | ||
| run: sudo apt-get update && sudo apt-get install -y --no-install-recommends libudev-dev libdbus-1-dev | ||
|
|
||
| - name: Build binary | ||
| run: cargo build --package stellar-cli --release | ||
|
|
||
| - name: Upload binary | ||
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | ||
| with: | ||
| name: stellar-${{ matrix.arch }} | ||
| path: target/release/stellar | ||
| retention-days: 1 | ||
|
|
||
| docker: | ||
| needs: build | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
|
|
@@ -57,12 +27,6 @@ jobs: | |
| ref: ${{ github.event_name == 'workflow_dispatch' && inputs.ref || github.ref }} | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Download binaries | ||
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | ||
| with: | ||
| pattern: stellar-* | ||
| merge-multiple: false | ||
|
|
||
| - name: Set up QEMU | ||
| uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4 | ||
|
|
||
|
|
@@ -100,6 +64,8 @@ jobs: | |
| platforms: linux/amd64,linux/arm64 | ||
| push: true | ||
| tags: ${{ env.DOCKER_TAGS }} | ||
| build-args: | | ||
| STELLAR_CLI_REV=${{ github.event_name == 'workflow_dispatch' && inputs.ref || github.ref_name }} | ||
|
Comment on lines
+67
to
+68
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For Since the workflow already does - name: Resolve ref to SHA
id: rev
run: echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
# ...
build-args: |
STELLAR_CLI_REV=${{ steps.rev.outputs.sha }}This makes the build reproducible and avoids the tag-vs-rev ambiguity.
Comment on lines
+67
to
+68
Comment on lines
+67
to
+68
|
||
|
|
||
| - name: Update Docker Hub description | ||
| run: | | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,15 +3,26 @@ FROM rust:latest | |
| RUN rustup target add wasm32v1-none | ||
|
|
||
| RUN apt-get update && \ | ||
| apt-get install -y --no-install-recommends ca-certificates libdbus-1-3 libssl3 libudev1 && \ | ||
| apt-get install -y --no-install-recommends \ | ||
| build-essential \ | ||
| ca-certificates \ | ||
| git \ | ||
| libdbus-1-dev \ | ||
| libssl-dev \ | ||
| libudev-dev \ | ||
| pkg-config && \ | ||
| rm -rf /var/lib/apt/lists/* | ||
|
|
||
| ARG TARGETARCH | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| COPY stellar-${TARGETARCH}/stellar /usr/local/bin/stellar | ||
| RUN chmod +x /usr/local/bin/stellar | ||
| ARG STELLAR_CLI_REV | ||
| RUN cargo install --locked \ | ||
| --git https://github.com/stellar/stellar-cli.git \ | ||
| --rev "${STELLAR_CLI_REV}" \ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For Useful? React with 👍 / 👎. |
||
| stellar-cli | ||
|
Comment on lines
+18
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Consider resolving the input to a SHA in the workflow before passing it as There is also no default or guard: if someone builds the image locally without
Comment on lines
+18
to
+21
|
||
|
|
||
| ENV STELLAR_CONFIG_HOME=/config | ||
| ENV STELLAR_DATA_HOME=/data | ||
| ENV STELLAR_NO_UPDATE_CHECK=1 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: setting |
||
|
|
||
| COPY entrypoint.sh /usr/local/bin/entrypoint.sh | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cross-arch builds now run under QEMU emulation. The previous workflow built
arm64natively on anubuntu-24.04-armrunner. With thebuildmatrix removed, thelinux/arm64image is now compiled from source inside QEMU on an amd64 host. Building Rust under QEMU is typically 10–30× slower than native — for a project the size of stellar-cli this can mean very long builds (potentially exceeding the default 6-hour job timeout) and significant CI cost.Consider keeping the multi-arch matrix and using
docker/build-push-actionper-arch on native runners, then assembling a manifest withdocker buildx imagetools create. Or use buildx withplatforms: linux/amd64onubuntu-latestandplatforms: linux/arm64onubuntu-24.04-armand merge.Also worth adding
cache-from/cache-to(e.g. GHA cache) to avoid re-compiling everything on every push.