Skip to content

Commit dfabbd0

Browse files
authored
fix: fix docker image build (#47) (#48)
1 parent 2301108 commit dfabbd0

File tree

5 files changed

+49
-12
lines changed

5 files changed

+49
-12
lines changed

.dockerignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
*
2-
!src
3-
!Cargo.*
1+
target/

.github/workflows/build.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,25 @@ jobs:
7474
run: cargo deny check advisories bans sources
7575
continue-on-error: true
7676

77+
build-docker:
78+
name: build docker image
79+
needs: check
80+
runs-on: ubuntu-latest
81+
steps:
82+
- uses: actions/checkout@v4
83+
- name: Set up QEMU
84+
uses: docker/setup-qemu-action@v3
85+
- name: Set up Docker Buildx
86+
uses: docker/setup-buildx-action@v3
87+
- name: Build Docker image
88+
uses: docker/build-push-action@v6
89+
with:
90+
platforms: linux/amd64,linux/arm64
91+
context: .
92+
push: false
93+
tags: ${{ steps.meta.outputs.tags }}
94+
labels: ${{ steps.meta.outputs.labels }}
95+
7796
publish-dry-run:
7897
name: publish dry run
7998
needs: tests

.github/workflows/publish-to-dockerhub.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,16 @@ jobs:
2929
with:
3030
images: ${{ env.IMAGE_NAME }}
3131

32+
- name: Set up QEMU
33+
uses: docker/setup-qemu-action@v3
34+
35+
- name: Set up Docker Buildx
36+
uses: docker/setup-buildx-action@v3
37+
3238
- name: Build and push Docker image
33-
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
39+
uses: docker/build-push-action@v6
3440
with:
41+
platforms: linux/amd64,linux/arm64
3542
context: .
3643
push: true
3744
tags: ${{ steps.meta.outputs.tags }}

.github/workflows/publish-to-ghcr.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,16 @@ jobs:
3434
with:
3535
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
3636

37+
- name: Set up QEMU
38+
uses: docker/setup-qemu-action@v3
39+
40+
- name: Set up Docker Buildx
41+
uses: docker/setup-buildx-action@v3
42+
3743
- name: Build and push Docker image
38-
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
44+
uses: docker/build-push-action@v6
3945
with:
46+
platforms: linux/amd64,linux/arm64
4047
context: .
4148
push: true
4249
tags: ${{ steps.meta.outputs.tags }}

Dockerfile

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
FROM ekidd/rust-musl-builder:latest as builder
1+
FROM rust:alpine3.21 as builder
22

3-
ADD --chown=rust:rust . ./
4-
RUN cargo build --release
3+
WORKDIR /app
4+
5+
COPY . ./
6+
RUN apk update && \
7+
apk add musl-dev jq && \
8+
cargo build --release --message-format=json > build.json
9+
# copy binary to a new location
10+
RUN jq -r '.executable | select(. != null)' build.json | xargs -I '{}' cp '{}' /app
511

612
# final image
713
FROM alpine:latest
@@ -10,8 +16,8 @@ LABEL name="ssd-benchmark"
1016
LABEL org.opencontainers.image.source="https://github.com/sassman/ssd-benchmark-rs"
1117
LABEL repository="https://github.com/sassman/ssd-benchmark-rs"
1218
LABEL homepage="https://github.com/sassman/ssd-benchmark-rs"
13-
LABEL maintainer="Sven Assmann"
19+
LABEL maintainer="Sven Kanoldt <sven@d34dl0ck.me>"
1420

15-
COPY --from=builder /home/rust/src/target/x86_64-unknown-linux-musl/release/ssd-benchmark \
16-
/usr/local/bin/
17-
CMD /usr/local/bin/ssd-benchmark
21+
COPY --from=builder /app/ssd-benchmark \
22+
/usr/local/bin/
23+
CMD /usr/local/bin/ssd-benchmark

0 commit comments

Comments
 (0)