Skip to content

Commit

Permalink
docker: build multi platform images
Browse files Browse the repository at this point in the history
  • Loading branch information
codebien committed Sep 8, 2023
1 parent c944ebf commit a6219a0
Showing 1 changed file with 69 additions and 51 deletions.
120 changes: 69 additions & 51 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,18 @@ jobs:
with:
fetch-depth: 0
- name: Build
run: docker build --target release -t $DOCKER_IMAGE_ID .
run: |
docker buildx create \
--name multibuilder \
--platform linux/amd64,linux/arm64 \
--bootstrap --use
docker buildx build \
--platform linux/amd64,linux/arm64 \
-t $DOCKER_IMAGE_ID .
- name: Check
run: |
docker buildx build --load -t $DOCKER_IMAGE_ID .
# Assert that simple cases works for the new built image
docker run $DOCKER_IMAGE_ID version
docker run $DOCKER_IMAGE_ID --help
docker run $DOCKER_IMAGE_ID help
Expand All @@ -154,8 +163,6 @@ jobs:
docker run $DOCKER_IMAGE_ID pause --help
docker run $DOCKER_IMAGE_ID resume --help
- name: Build browser-enabled image
run: docker build -t $DOCKER_IMAGE_ID:with-browser --target with-browser .
- name: Log into ghcr.io
if: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v') }}
run: |
Expand All @@ -165,78 +172,89 @@ jobs:
if: ${{ github.ref == 'refs/heads/master' }}
run: |
echo "Publish as ghcr.io/$GHCR_IMAGE_ID:$VERSION"
docker tag "$DOCKER_IMAGE_ID" "ghcr.io/$GHCR_IMAGE_ID:master"
docker push "ghcr.io/$GHCR_IMAGE_ID:master"
docker tag "$DOCKER_IMAGE_ID:with-browser" "ghcr.io/$GHCR_IMAGE_ID:master-with-browser"
docker push "ghcr.io/$GHCR_IMAGE_ID:master-with-browser"
docker buildx build --push \
--platform linux/amd64,linux/arm64 \
-t ghcr.io/$GHCR_IMAGE_ID:master .
docker buildx build --push \
--target with-browser \
--platform linux/amd64,linux/arm64 \
-t ghcr.io/$GHCR_IMAGE_ID:master-with-browser .
- name: Publish tagged version image to ghcr.io
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
run: |
VERSION="${VERSION#v}"
echo "Publish as ghcr.io/$GHCR_IMAGE_ID:$VERSION"
docker tag "$DOCKER_IMAGE_ID" "ghcr.io/$GHCR_IMAGE_ID:$VERSION"
docker push "ghcr.io/$GHCR_IMAGE_ID:$VERSION"
docker tag "$DOCKER_IMAGE_ID:with-browser" "ghcr.io/$GHCR_IMAGE_ID:$VERSION-with-browser"
docker push "ghcr.io/$GHCR_IMAGE_ID:$VERSION-with-browser"
docker buildx build --push \
--platform linux/amd64,linux/arm64 \
-t ghcr.io/$GHCR_IMAGE_ID:$VERSION .
docker buildx build --push \
--target with-browser \
--platform linux/amd64,linux/arm64 \
-t ghcr.io/$GHCR_IMAGE_ID:$VERSION-with-browser .
# We also want to tag the latest stable version as latest
if [[ ! "$VERSION" =~ (RC|rc) ]]; then
echo "Publish as ghcr.io/$GHCR_IMAGE_ID:latest"
docker tag "$DOCKER_IMAGE_ID" "ghcr.io/$GHCR_IMAGE_ID:latest"
docker push "ghcr.io/$GHCR_IMAGE_ID:latest"
docker tag "$DOCKER_IMAGE_ID:with-browser" "ghcr.io/$GHCR_IMAGE_ID:latest-with-browser"
docker push "ghcr.io/$GHCR_IMAGE_ID:latest-with-browser"
docker buildx build --push \
--platform linux/amd64,linux/arm64 \
-t ghcr.io/$GHCR_IMAGE_ID:latest .
docker buildx build --push \
--target with-browser \
--platform linux/amd64,linux/arm64 \
-t ghcr.io/$GHCR_IMAGE_ID:latest-with-browser .
fi
- name: Log into Docker Hub
if: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v') }}
run: |
# Log into Docker Hub Registry
echo "${{ secrets.DOCKER_PASS }}" | docker login -u "${{ secrets.DOCKER_USER }}" --password-stdin
- name: Publish k6:master image to Docker Hub
if: ${{ github.ref == 'refs/heads/master' }}
run: |
echo "Publish to Docker Hub as $DOCKER_IMAGE_ID:master"
docker tag "$DOCKER_IMAGE_ID" "$DOCKER_IMAGE_ID:master"
docker push "$DOCKER_IMAGE_ID:master"
docker tag "$DOCKER_IMAGE_ID:with-browser" "$DOCKER_IMAGE_ID:master-with-browser"
docker push "$DOCKER_IMAGE_ID:master-with-browser"
echo "Publish to Docker Hub as $DOCKER_IMAGE_ID:master and $LI_DOCKER_IMAGE_ID:master"
docker buildx build --push \
--platform linux/amd64,linux/arm64 \
-t $DOCKER_IMAGE_ID:master .
docker buildx build --push \
--target with-browser \
--platform linux/amd64,linux/arm64 \
-t $DOCKER_IMAGE_ID:master-with-browser .
# LoadImpact images are deprecated, we don't build arm64 for it.
docker buildx build --push \
--platform linux/amd64 \
-t $LI_DOCKER_IMAGE_ID:master .
- name: Publish tagged version image to Docker Hub
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
run: |
# We need to push the same image in both the loadimpact and the grafana docker hub orgs
VERSION="${VERSION#v}"
echo "Publish to Docker Hub as $DOCKER_IMAGE_ID:$VERSION"
docker tag "$DOCKER_IMAGE_ID" "$DOCKER_IMAGE_ID:$VERSION"
docker push "$DOCKER_IMAGE_ID:$VERSION"
docker tag "$DOCKER_IMAGE_ID:with-browser" "$DOCKER_IMAGE_ID:$VERSION-with-browser"
docker push "$DOCKER_IMAGE_ID:$VERSION-with-browser"
# We also want to tag the latest stable version as latest
if [[ ! "$VERSION" =~ (RC|rc) ]]; then
echo "Publish to Docker Hub as $DOCKER_IMAGE_ID:latest"
docker tag "$DOCKER_IMAGE_ID" "$DOCKER_IMAGE_ID:latest"
docker push "$DOCKER_IMAGE_ID:latest"
docker tag "$DOCKER_IMAGE_ID:with-browser" "$DOCKER_IMAGE_ID:latest-with-browser"
docker push "$DOCKER_IMAGE_ID:latest-with-browser"
fi
- name: Build loadimpact/k6
run: docker build -t $LI_DOCKER_IMAGE_ID --target legacy .
- name: Publish loadimpact/k6:master image to Docker Hub
if: ${{ github.ref == 'refs/heads/master' }}
run: |
echo "Publish to Docker Hub as $LI_DOCKER_IMAGE_ID:master"
docker tag "$LI_DOCKER_IMAGE_ID" "$LI_DOCKER_IMAGE_ID:master"
docker push "$LI_DOCKER_IMAGE_ID:master"
- name: Publish loadimpact/k6 tagged version image to Docker Hub
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
run: |
VERSION="${VERSION#v}"
echo "Publish to Docker Hub as $LI_DOCKER_IMAGE_ID:$VERSION"
docker tag "$LI_DOCKER_IMAGE_ID" "$LI_DOCKER_IMAGE_ID:$VERSION"
docker push "$LI_DOCKER_IMAGE_ID:$VERSION"
echo "Publish to Docker Hub as $DOCKER_IMAGE_ID:$VERSION and $LI_DOCKER_IMAGE_ID:$VERSION"
docker buildx build --push \
--platform linux/amd64,linux/arm64 \
-t $DOCKER_IMAGE_ID:$VERSION .
docker buildx build --push \
--target with-browser \
--platform linux/amd64,linux/arm64 \
-t $DOCKER_IMAGE_ID:$VERSION-with-browser .
# LoadImpact images are deprecated, we don't build arm64 for it.
docker buildx build --push \
--platform linux/amd64 \
-t $LI_DOCKER_IMAGE_ID:$VERSION .
# We also want to tag the latest stable version as latest
if [[ ! "$VERSION" =~ (RC|rc) ]]; then
echo "Publish to Docker Hub as $LI_DOCKER_IMAGE_ID:latest"
docker tag "$LI_DOCKER_IMAGE_ID" "$LI_DOCKER_IMAGE_ID:latest"
docker push "$LI_DOCKER_IMAGE_ID:latest"
echo "Publish to Docker Hub as $DOCKER_IMAGE_ID:latest and $LI_DOCKER_IMAGE_ID:latest"
docker buildx build --push \
--platform linux/amd64,linux/arm64 \
-t $DOCKER_IMAGE_ID:latest .
docker buildx build --push \
--target with-browser \
--platform linux/amd64,linux/arm64 \
-t $DOCKER_IMAGE_ID:latest-with-browser .
# LoadImpact images are deprecated, we don't build arm64 for it.
docker buildx build --push \
--platform linux/amd64 \
-t $LI_DOCKER_IMAGE_ID:latest .
fi
package-windows:
Expand Down

0 comments on commit a6219a0

Please sign in to comment.