Skip to content

Commit

Permalink
feat: update Dockerfile to support configurable binary name during build
Browse files Browse the repository at this point in the history
The Dockerfile has been updated to include an argument `BINARY_NAME` that allows for the specification of the binary name during the build process. This allows for more flexibility in naming the binary based on different platforms or requirements. The entrypoint has also been updated to use the specified binary name.
  • Loading branch information
Mogyuchi authored and gitbutler-client committed Feb 9, 2024
1 parent 6fb6a8d commit 76826fe
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
24 changes: 13 additions & 11 deletions .github/files/build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
# syntax=docker/dockerfile:1.6.0@sha256:ac85f380a63b13dfcefa89046420e1781752bab202122f8f50032edf31be0021
ARG BINARY_NAME
FROM --platform=$BUILDPLATFORM busybox:1.36.1-uclibc@sha256:cc71f45a5a48738c4c295314b2bc9bcc18eb0c33e7bb127c3735b751b724141b AS env
ARG TARGETPLATFORM
RUN --mount=type=bind,source=artifact,target=artifact \
if [ "$TARGETPLATFORM" = 'darwin/amd64' ]; then\
cp artifact/x86_64-apple-darwin/binary .\
;elif [ "$TARGETPLATFORM" = 'darwin/arm64' ]; then\
cp artifact/aarch64-apple-darwin/binary .\
;elif [ "$TARGETPLATFORM" = 'linux/amd64' ]; then\
cp artifact/x86_64-unknown-linux-musl/binary .\
;elif [ "$TARGETPLATFORM" = 'linux/arm64' ]; then\
cp artifact/aarch64-unknown-linux-musl/binary .\
;fi
if [ "$TARGETPLATFORM" = 'darwin/amd64' ]; then\
cp artifact/x86_64-apple-darwin/binary .\
;elif [ "$TARGETPLATFORM" = 'darwin/arm64' ]; then\
cp artifact/aarch64-apple-darwin/binary .\
;elif [ "$TARGETPLATFORM" = 'linux/amd64' ]; then\
cp artifact/x86_64-unknown-linux-musl/binary .\
;elif [ "$TARGETPLATFORM" = 'linux/arm64' ]; then\
cp artifact/aarch64-unknown-linux-musl/binary .\
;fi

FROM --platform=$BUILDPLATFORM scratch as runner
COPY --from=env --chmod=755 binary .
ENTRYPOINT ["./binary"]
ENV BINARY_NAME=${BINARY_NAME}
COPY --from=env --chmod=755 binary "${BINARY_NAME}"
ENTRYPOINT ["./${BINARY_NAME}"]
3 changes: 2 additions & 1 deletion .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ jobs:
needs: build
permissions:
packages: write
runs-on: 'ubuntu-latest'
runs-on: "ubuntu-latest"
outputs:
image_tags: ${{ steps.meta.outputs.tags }}
env:
Expand Down Expand Up @@ -138,6 +138,7 @@ jobs:
- name: Build and push Docker image
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0
with:
build-args: BINARY_NAME=${{ env.BINARY_NAME }}
context: .
file: .github/files/build/Dockerfile
platforms: darwin/amd64,darwin/arm64,linux/amd64,linux/arm64
Expand Down

0 comments on commit 76826fe

Please sign in to comment.