Skip to content

Commit

Permalink
Corrected multi platform issues #287
Browse files Browse the repository at this point in the history
  • Loading branch information
craigwrong committed Dec 10, 2024
1 parent e300ae3 commit 107fdf3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,18 @@ name: Docker

on:
workflow_dispatch:

push:
branches:
- 'master'
tags:
- '*'
jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to Docker Hub
uses: docker/login-action@v3
Expand All @@ -40,6 +38,8 @@ jobs:
ghcr.io/swift-bitcoin/swift-bitcoin
tags: |
type=sha,prefix=__tool__-sha-
type=semver,pattern={{version}},prefix=__tool__-
type=semver,pattern={{major}}.{{minor}},prefix=__tool__-
-
name: Build
uses: docker/bake-action@v5
Expand Down
11 changes: 7 additions & 4 deletions tools/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
# syntax=docker/dockerfile:1

FROM swift:6.0.2 AS builder
FROM --platform=$BUILDPLATFORM swift:6.0.2 AS builder
ARG TARGETARCH
COPY . /opt/swift-bitcoin
WORKDIR /opt/swift-bitcoin
RUN \
swift sdk install https://download.swift.org/swift-6.0.2-release/static-sdk/swift-6.0.2-RELEASE/swift-6.0.2-RELEASE_static-linux-0.0.1.artifactbundle.tar.gz --checksum aa5515476a403797223fc2aad4ca0c3bf83995d5427fb297cab1d93c68cee075 && \
swift build -c release --swift-sdk aarch64-swift-linux-musl
if [ $TARGETARCH = arm64 ]; then export ARCH=aarch64; elif [ $TARGETARCH = amd64 ]; then export ARCH=x86_64; else export ARCH=$TARGETARCH; fi && \
swift build -c release --swift-sdk $ARCH-swift-linux-musl && \
mv /opt/swift-bitcoin/.build/$ARCH-swift-linux-musl /opt/swift-bitcoin/.build/swift-linux-musl
# && \ swift test

FROM scratch AS bcutil
COPY --from=builder /opt/swift-bitcoin/.build/aarch64-swift-linux-musl/release/bcutil /usr/local/bin/
COPY --from=builder /opt/swift-bitcoin/.build/swift-linux-musl/release/bcutil /usr/local/bin/
ENTRYPOINT ["/usr/local/bin/bcutil"]

FROM scratch AS bcnode
COPY --from=builder /opt/swift-bitcoin/.build/aarch64-swift-linux-musl/release/bcnode /usr/local/bin/
COPY --from=builder /opt/swift-bitcoin/.build/swift-linux-musl/release/bcnode /usr/local/bin/
ENTRYPOINT ["/usr/local/bin/bcnode"]
2 changes: 2 additions & 0 deletions tools/docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ target "bcnode" {
dockerfile = "tools/Dockerfile"
target = "bcnode"
platforms = ["linux/amd64", "linux/arm64"]
labels = [for label in target.docker-metadata-action.labels : replace(label, "__tool__", "bcnode")]
tags = [for tag in target.docker-metadata-action.tags : replace(tag, "__tool__", "bcnode")]
}

Expand All @@ -19,5 +20,6 @@ target "bcutil" {
dockerfile = "tools/Dockerfile"
target = "bcutil"
platforms = ["linux/amd64", "linux/arm64"]
labels = [for label in target.docker-metadata-action.labels : replace(label, "__tool__", "bcutil")]
tags = [for tag in target.docker-metadata-action.tags : replace(tag, "__tool__", "bcutil")]
}

0 comments on commit 107fdf3

Please sign in to comment.