Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker: Build multi platform images #3320

Merged
merged 1 commit into from
Sep 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 .
mstoykov marked this conversation as resolved.
Show resolved Hide resolved
- 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 .
mstoykov marked this conversation as resolved.
Show resolved Hide resolved
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 \
codebien marked this conversation as resolved.
Show resolved Hide resolved
--platform linux/amd64 \
-t $LI_DOCKER_IMAGE_ID:latest .
fi

package-windows:
Expand Down