Skip to content

Commit

Permalink
multi-arch docker workflow updates
Browse files Browse the repository at this point in the history
  • Loading branch information
smohan-dw committed Jun 15, 2024
1 parent 7bd9ab4 commit 2bcfaa2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 25 deletions.
45 changes: 22 additions & 23 deletions .github/workflows/docker-multiarch.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: docker
name: Multi-Arch Docker Build

on:
push:
Expand All @@ -18,16 +18,16 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v4.1.1
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
uses: docker/login-action@v3
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ env.USERNAME }}
Expand All @@ -43,22 +43,21 @@ jobs:
- name: Build and Push to Docker Hub
run: |
# Get the branch name
DOCKER_BRANCH=${{ github.ref }}
DOCKER_BRANCH=${DOCKER_BRANCH/refs\/heads\//}
docker buildx create --use
docker buildx build --no-cache --file docker/Dockerfile --tag ${{ env.IMAGE_NAME}}:$DOCKER_BRANCH --platform linux/amd64,linux/arm64 --build-arg profile=${{ env.BUILD_PROFILE }} --push .
docker tag \
${{ env.IMAGE_NAME}}:$DOCKER_BRANCH \
${{ env.REGISTRY }}/${{ env.USERNAME }}/${{ env.IMAGE_NAME}}:${{ env.COMMIT_SHA}} \
&& docker tag \
${{ env.IMAGE_NAME}}:$DOCKER_BRANCH \
${{ env.REGISTRY }}/${{ env.USERNAME }}/${{ env.IMAGE_NAME}}:$DOCKER_BRANCH \
&& docker tag \
${{ env.IMAGE_NAME}}:$DOCKER_BRANCH \
${{ env.REGISTRY }}/${{ env.USERNAME }}/${{ env.IMAGE_NAME}}:latest
docker push ${{ env.REGISTRY }}/${{ env.USERNAME }}/${{ env.IMAGE_NAME}}:$DOCKER_BRANCH
docker push ${{ env.REGISTRY }}/${{ env.USERNAME }}/${{ env.IMAGE_NAME}}:latest
DOCKER_BRANCH=${{ github.ref_name }}
docker buildx build --platform linux/amd64,linux/arm64 \
--build-arg BUILDPROFILE=${{ env.BUILD_PROFILE }} \
--tag ${{ env.REGISTRY }}/${{ env.USERNAME }}/${{ env.IMAGE_NAME }}:$DOCKER_BRANCH \
--tag ${{ env.REGISTRY }}/${{ env.USERNAME }}/${{ env.IMAGE_NAME }}:${{ env.COMMIT_SHA }} \
--tag ${{ env.REGISTRY }}/${{ env.USERNAME }}/${{ env.IMAGE_NAME }}:latest \
--file docker/Dockerfile \
--push \
.
- name: Verify Image Tags
run: |
echo "Docker Image Tags:"
echo " - ${{ env.REGISTRY }}/${{ env.USERNAME }}/${{ env.IMAGE_NAME }}:$DOCKER_BRANCH"
echo " - ${{ env.REGISTRY }}/${{ env.USERNAME }}/${{ env.IMAGE_NAME }}:${{ env.COMMIT_SHA }}"
echo " - ${{ env.REGISTRY }}/${{ env.USERNAME }}/${{ env.IMAGE_NAME }}:latest"
4 changes: 2 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ LABEL maintainer="[email protected]"
FROM --platform=$BUILDPLATFORM rust:1-bullseye as build
ARG BUILDPLATFORM
ARG TARGETPLATFORM
ARG PROFILE
ARG BUILDPROFILE

RUN echo "DEBIAN_ARCH_TRIPLET='$(dpkg-architecture -A${TARGETPLATFORM#linux/} -qDEB_TARGET_MULTIARCH)'" >>/root/dynenv
RUN . /root/dynenv && \
Expand Down Expand Up @@ -59,7 +59,7 @@ ARG chain="cord"
RUN set -x && \
cat /root/dynenv && \
. /root/dynenv && \
cargo build --locked $CARGO_OPTIONS $PROFILE --target "$RUST_ARCH_TRIPLET" && \
cargo build --locked $CARGO_OPTIONS $BUILDPROFILE --target "$RUST_ARCH_TRIPLET" && \
mkdir -p build && \
mv target/$RUST_ARCH_TRIPLET/$TARGET_FOLDER/cord build/ && \

Expand Down

0 comments on commit 2bcfaa2

Please sign in to comment.