@@ -26,41 +26,23 @@ jobs:
26
26
- name : Set up Rust + QEMU
27
27
uses : docker/setup-qemu-action@v2
28
28
with :
29
- platforms : linux/amd64,linux/arm64 # ✅ Only needed once per buildx host
29
+ platforms : linux/amd64,linux/arm64
30
30
31
- # Install ARM cross-compiler
32
- - name : Install cross-compilation toolchain
33
- run : |
34
- sudo apt-get update
35
- sudo apt-get install -y gcc-aarch64-linux-gnu
36
-
37
- # Install Rust toolchain with both x86_64 and arm64 targets
38
- - name : Set up Rust targets
31
+ # Install Rust and cache artifacts
32
+ - name : Set up Rust
39
33
uses : dtolnay/rust-toolchain@stable
40
34
with :
41
- targets : x86_64-unknown-linux-gnu,aarch64-unknown-linux-gnu # ✅ Targets declared here
35
+ toolchain : stable
42
36
43
- # Cache Rust build artifacts (unique key avoids 409 Conflict errors)
44
37
- uses : Swatinem/rust-cache@v2
45
38
with :
46
39
shared-key : ${{ runner.os }}-cargo-${{ github.sha }}
47
40
48
- # Install sea-orm-cli globally
41
+ # Install sea-orm-cli globally (if needed for migration or seed)
49
42
- name : Install sea-orm-cli
50
43
run : cargo install sea-orm-cli
51
44
52
- # Configure the Rust linker for arm64 builds
53
- - name : Set linker for cross-compilation
54
- run : |
55
- mkdir -p ~/.cargo
56
- echo '[target.aarch64-unknown-linux-gnu]' >> ~/.cargo/config.toml
57
- echo 'linker = "aarch64-linux-gnu-gcc"' >> ~/.cargo/config.toml
58
-
59
- # Build release binaries for ARM64
60
- - name : Build release binaries
61
- run : cargo build --release --workspace --target aarch64-unknown-linux-gnu
62
-
63
- # Run tests for x86_64 (native)
45
+ # Run tests for x86_64 only (CI feedback)
64
46
- name : Run tests
65
47
run : cargo test --release
66
48
77
59
# Checkout source code
78
60
- uses : actions/checkout@v4
79
61
80
- # Authenticate to GitHub Container Registry
62
+ # Docker login to GHCR
81
63
- name : Docker login
82
64
uses : docker/login-action@v2
83
65
with :
96
78
echo -e "\033[1;34m🔍 Checking buildx cache BEFORE build...\033[0m"
97
79
docker buildx du || echo -e "\033[1;33m⚠️ No cache found yet.\033[0m"
98
80
99
- # Compute image name based on branch name and tag as `latest`
81
+ # Compute image tag
100
82
- name : Determine Image Tags
101
83
id : tags
102
84
run : |
@@ -105,27 +87,27 @@ jobs:
105
87
echo "backend_tags=$IMAGE_NAME:latest" >> $GITHUB_OUTPUT
106
88
echo "backend_image_name=$IMAGE_NAME" >> $GITHUB_OUTPUT
107
89
108
- # Build and push multi-arch Docker image with GHA cache
90
+ # Build and push multi-arch Docker image with cache
109
91
- name : Build + Push Backend
110
92
id : push_backend
111
93
uses : docker/build-push-action@v5
112
94
with :
113
95
context : .
114
96
file : ./Dockerfile
115
- platforms : linux/amd64,linux/arm64 # ✅ Declared again for buildx
97
+ platforms : linux/amd64,linux/arm64 # ✅ Key multi-arch setting
116
98
push : true
117
99
provenance : true
118
100
tags : ${{ steps.tags.outputs.backend_tags }}
119
101
cache-from : type=gha
120
102
cache-to : type=gha,mode=max
121
103
122
- # Show updated Docker cache state
104
+ # Show updated cache usage
123
105
- name : Show Docker Build Cache (After)
124
106
run : |
125
107
echo -e "\033[1;34m📦 Checking buildx cache AFTER build...\033[0m"
126
108
docker buildx du || echo -e "\033[1;31m❌ Failed to get updated cache info\033[0m"
127
109
128
- # Generate SBOM + attestation only on main branch
110
+ # Attest build provenance if on main branch
129
111
- name : Attest Backend
130
112
if : github.ref == 'refs/heads/main' && github.event_name == 'push'
131
113
uses : actions/attest-build-provenance@v2
@@ -141,4 +123,4 @@ jobs:
141
123
echo " docker pull ${{ steps.tags.outputs.backend_image_name }}:latest"
142
124
echo ""
143
125
echo -e "\033[1;36m▶️ Run Backend:\033[0m"
144
- echo " docker run --rm -p 8000:8000 ${{ steps.tags.outputs.backend_image_name }}:latest"
126
+ echo " docker run --rm --env-file .env - p 8000:8000 ${{ steps.tags.outputs.backend_image_name }}:latest"
0 commit comments