Skip to content

Commit b17c757

Browse files
authored
Merge pull request #66 from wulfraem/fix/docker-issues-on-macos
Fix Docker Issues on macOS
2 parents 0072620 + 1986da0 commit b17c757

File tree

2 files changed

+36
-122
lines changed

2 files changed

+36
-122
lines changed

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

+18-111
Original file line numberDiff line numberDiff line change
@@ -23,32 +23,9 @@ jobs:
2323
runs-on: ubuntu-latest
2424
strategy:
2525
matrix:
26-
config:
27-
- {
28-
binary_name: "iota-gas-station",
29-
docker_repo: "iotaledger/gas-station",
30-
runner: "ubuntu-latest",
31-
platform: "linux/amd64",
32-
}
33-
- {
34-
binary_name: "iota-gas-station",
35-
docker_repo: "iotaledger/gas-station",
36-
runner: "macos-latest",
37-
platform: "linux/arm64/v8",
38-
}
39-
40-
- {
41-
binary_name: "tool",
42-
docker_repo: "iotaledger/gas-station-tool",
43-
runner: "ubuntu-latest",
44-
platform: "linux/amd64",
45-
}
46-
- {
47-
binary_name: "tool",
48-
docker_repo: "iotaledger/gas-station-tool",
49-
runner: "macos-latest",
50-
platform: "linux/arm64/v8",
51-
}
26+
image:
27+
- { name: "iota-gas-station", repo: "iotaledger/gas-station" }
28+
- { name: "tool", repo: "iotaledger/gas-station-tool" }
5229
steps:
5330
- name: Check out the repo
5431
uses: actions/checkout@v4
@@ -61,91 +38,21 @@ jobs:
6138
username: ${{ secrets.IOTALEDGER_DOCKER_USERNAME }}
6239
password: ${{ secrets.IOTALEDGER_DOCKER_PASSWORD }}
6340

64-
- name: Set up Docker Buildx
65-
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1
66-
67-
- name: Local Image Names
68-
id: names
69-
run: |
70-
echo "local_image=${{ matrix.config.binary_name }}-${{ matrix.config.runner }}" >> $GITHUB_OUTPUT
71-
echo "ext_image=${{ matrix.config.docker_repo }}:${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT
72-
73-
- name: Build docker image (DRY-RUN) ${{ matrix.config.docker_repo }} - ${{ matrix.config.platform }}
74-
if: ${{ github.event.inputs.is-dry-run == 'true' }}
75-
run: |
76-
ENTRY_BINARY=${{ matrix.config.binary_name }} docker/build.sh \
77-
-t ${{ steps.names.outputs.ext_image }} \
78-
--platform ${{ matrix.config.platform }}
79-
80-
- name: Build & Push docker image Build docker image ${{ matrix.config.docker_repo }} - ${{ matrix.config.platform }}
81-
if: ${{ github.event.inputs.is-dry-run == 'false' }}
82-
id: build-push-image
41+
- name: Build image with build.sh
8342
run: |
84-
ENTRY_BINARY=${{ matrix.config.binary_name }} docker/build.sh \
85-
--platform ${{ matrix.config.platform }} \
86-
--output type=image,"name=${{ matrix.config.docker_repo }}",push-by-digest=true,name-canonical=true,push=true \
87-
--iidfile docker.id
88-
89-
DOCKER_ID=$(cat docker.id)
90-
DIGEST=$(docker manifest inspect ${{ matrix.config.docker_repo }}@${DOCKER_ID} | jq -r '.manifests[0].digest')
91-
echo "Obtained the docker image $DIGEST"
92-
echo "digest=$DIGEST" >> "$GITHUB_OUTPUT"
93-
94-
- name: Export digest
95-
if: ${{ github.event.inputs.is-dry-run == 'false' }}
96-
run: |
97-
mkdir -p ${{ runner.temp }}/digests/${{ github.sha }}
98-
digest="${{ steps.build-push-image.outputs.digest }}"
99-
touch "${{ runner.temp }}/digests/${{ github.sha}}/${digest#sha256:}"
100-
101-
- name: Upload digest
102-
if: ${{ steps.build-push-image.outputs.digest != '' }}
103-
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
104-
with:
105-
name: digests-${{ github.sha }}-${{ matrix.config.binary_name }}-${{ matrix.config.runner }}
106-
path: ${{ runner.temp }}/digests/${{ github.sha }}/*
107-
if-no-files-found: error
108-
retention-days: 1
109-
110-
push-index:
111-
if: ${{ github.event.inputs.is-dry-run == 'false' }}
112-
environment: release
113-
needs: push_to_registry
114-
runs-on: ubuntu-latest
115-
strategy:
116-
matrix:
117-
config:
118-
- {
119-
binary_name: "iota-gas-station",
120-
docker_repo: "iotaledger/gas-station",
121-
}
122-
- { binary_name: "tool", docker_repo: "iotaledger/gas-station-tool" }
123-
124-
steps:
125-
- name: Login to Docker Registry
126-
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
127-
with:
128-
username: ${{ secrets.IOTALEDGER_DOCKER_USERNAME }}
129-
password: ${{ secrets.IOTALEDGER_DOCKER_PASSWORD }}
130-
131-
- name: Set up Docker Buildx
132-
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1
133-
134-
- name: Download digests
135-
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
136-
with:
137-
path: ${{ runner.temp }}/digests
138-
pattern: digests-${{ github.sha }}-${{ matrix.config.binary_name }}-*
139-
merge-multiple: true
43+
ENTRY_BINARY=${{ matrix.image.name }} docker/build.sh -t ${{ matrix.image.repo }}:${{ github.event.inputs.tag }}
14044
141-
- name: Push multi-platform index
45+
- name: Push docker image
46+
if: ${{ github.event.inputs.is-dry-run != 'true' }}
14247
run: |
143-
cmd="docker buildx imagetools create --tag ${{ matrix.config.docker_repo }}:${{ github.event.inputs.tag }}"
144-
for file in ${{ runner.temp }}/digests/*; do
145-
# Extract the filename (which is the hash).
146-
hash=$(basename "$file")
147-
# Append the amend option for the current hash.
148-
cmd+=" ${{ matrix.config.docker_repo }}@sha256:$hash"
149-
done
150-
echo -e "$cmd"
151-
eval "$cmd"
48+
docker push ${{ matrix.image.repo }}:${{ github.event.inputs.tag }}
49+
50+
# - name: Docker Hub Description for ${{ matrix.image.repo }}
51+
# if: ${{ github.event.inputs.is-dry-run == 'false'}}
52+
# uses: peter-evans/dockerhub-description@e98e4d1628a5f3be2be7c231e50981aee98723ae
53+
# with:
54+
# username: ${{ secrets.IOTALEDGER_DOCKER_USERNAME }}
55+
# password: ${{ secrets.IOTALEDGER_DOCKER_PASSWORD }}
56+
# repository: ${{ matrix.image.repo }}
57+
# readme-filepath: ./README.md
58+
# short-description: ${{ github.event.repository.description }}

docker/Dockerfile

+18-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1+
FROM --platform=$BUILDPLATFORM tonistiigi/xx AS xx
2+
13
FROM --platform=$BUILDPLATFORM rust:1.85-bullseye AS chef
24

5+
# setup xx
6+
# copy xx scripts to your build stage
7+
COPY --from=xx / /
8+
# export TARGETPLATFORM (or other TARGET*)
9+
ARG TARGETPLATFORM
10+
# you can now call xx-* commands
11+
RUN xx-info env
12+
313
WORKDIR /iota
414

515
ARG GIT_REVISION
@@ -8,34 +18,31 @@ ENV GIT_REVISION=$GIT_REVISION
818
# This is a workaround for the following the issue related to the libc-bin package
919
RUN rm /var/lib/dpkg/info/libc-bin.*
1020

11-
RUN apt-get clean
12-
RUN apt-get update && apt-get install -y cmake clang lld
13-
21+
RUN apt-get update && apt-get install -y clang lld
1422

1523
# Build and cache all dependencies.
1624
FROM chef AS builder
1725
WORKDIR /iota
1826

19-
# Configure Rust to use clang and lld as the linker
20-
RUN mkdir -p ./.cargo && \
21-
echo "[target.x86_64-unknown-linux-gnu]\nlinker = \"clang\"\nrustflags = [\"-C\", \"link-arg=-fuse-ld=lld\"]" > ./.cargo/config.toml
22-
2327
COPY Cargo.toml ./
2428
COPY src ./src
29+
ARG ENTRY_BINARY=iota-gas-station
2530

26-
RUN cargo build --release
31+
RUN xx-cargo build --release --target-dir ./build
32+
RUN xx-verify "./build/$(xx-cargo --print-target-triple)/release/${ENTRY_BINARY}"
2733

34+
# move binary to a location we can access it more easily in `FROM` command
35+
RUN mv "./build/$(xx-cargo --print-target-triple)/release/${ENTRY_BINARY}" ./build/entrypoint
2836

2937
# Production Image
3038
FROM debian:bullseye-slim AS runtime
3139
RUN apt-get update && apt-get install -y libjemalloc-dev ca-certificates
3240

33-
ARG ENTRY_BINARY=iota-gas-station
34-
COPY --from=builder /iota/target/release/${ENTRY_BINARY} /usr/local/bin/entrypoint
41+
COPY --from=builder "/iota/build/entrypoint" /usr/local/bin/entrypoint
3542

3643
ARG BUILD_DATE
3744
ARG GIT_REVISION
3845
LABEL build-date=$BUILD_DATE
3946
LABEL git-revision=$GIT_REVISION
4047

41-
ENTRYPOINT ["/usr/local/bin/entrypoint"]
48+
ENTRYPOINT ["/usr/local/bin/entrypoint"]

0 commit comments

Comments
 (0)