Skip to content

Commit 7f37b6f

Browse files
committed
Build the binary inside the chosen base image.
1 parent bec1f85 commit 7f37b6f

1 file changed

Lines changed: 25 additions & 3 deletions

File tree

.github/workflows/docker.yml

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,33 @@ jobs:
3838
with:
3939
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.ref || github.ref }}
4040

41-
- name: Install build dependencies
42-
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends libudev-dev libdbus-1-dev
41+
- name: Resolve rust image
42+
run: |
43+
rust_image="${{ github.event_name == 'workflow_dispatch' && inputs.rust_image || 'latest' }}"
44+
echo "RUST_IMAGE=${rust_image}" >> "$GITHUB_ENV"
4345
46+
# Build inside the rust_image container so the binary's glibc and linked
47+
# libraries match the runtime base image. Each matrix runner is native
48+
# arch, so docker pulls the matching variant from the multi-arch manifest
49+
# — no QEMU emulation.
4450
- name: Build binary
45-
run: cargo build --package stellar-cli --release
51+
run: |
52+
# Compute the revision on the host so we don't need git inside the
53+
# container. soroban-cli's source reads GIT_REVISION via env!() at
54+
# compile time; setting it here lets cargo pass it through to rustc.
55+
git_revision="$(git rev-parse HEAD)"
56+
docker run --rm \
57+
-v "$(pwd):/src" \
58+
-w /src \
59+
-e "GIT_REVISION=${git_revision}" \
60+
"rust:${RUST_IMAGE}" \
61+
sh -c "
62+
apt-get update && \
63+
apt-get install -y --no-install-recommends \
64+
build-essential cmake pkg-config \
65+
libssl-dev libudev-dev libdbus-1-dev && \
66+
cargo build --package stellar-cli --release
67+
"
4668
4769
- name: Upload binary
4870
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1

0 commit comments

Comments
 (0)