From d7d6cdd886e7778732c27a9994031557d7af8393 Mon Sep 17 00:00:00 2001 From: Andrew Slotin Date: Fri, 14 Jul 2023 14:41:14 +0200 Subject: [PATCH 1/3] Explicitly specify the build target for loadimpact/k6 image --- .github/workflows/build.yml | 2 +- Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ff3ce0d8ef5..65d450a6613 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -204,7 +204,7 @@ jobs: docker push "$DOCKER_IMAGE_ID:latest" fi - name: Build loadimpact/k6 - run: docker build -t $LI_DOCKER_IMAGE_ID . + 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: | diff --git a/Dockerfile b/Dockerfile index 455368bc487..920b456fbab 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,7 @@ WORKDIR /home/k6 ENTRYPOINT ["k6"] # Legacy loadimpact/k6 image -FROM release +FROM release as legacy COPY entrypoint-legacy.sh /usr/bin/ From 8292a8cf5746459ae7a34ff79d42ecff423a3e68 Mon Sep 17 00:00:00 2001 From: Andrew Slotin Date: Fri, 14 Jul 2023 14:41:45 +0200 Subject: [PATCH 2/3] Add a stage to build browser-enabled image --- Dockerfile | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Dockerfile b/Dockerfile index 920b456fbab..a1f5affabad 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,3 +23,21 @@ FROM release as legacy COPY entrypoint-legacy.sh /usr/bin/ ENTRYPOINT ["/usr/bin/entrypoint-legacy.sh"] + +# Browser-enabled bundle +FROM release as with-browser + +USER root + +COPY --from=release /usr/bin/k6 /usr/bin/k6 +RUN apk --no-cache add chromium-swiftshader + +USER k6 + +ENV CHROME_BIN=/usr/bin/chromium-browser +ENV CHROME_PATH=/usr/lib/chromium/ + +ENV K6_BROWSER_ENABLED=true +ENV K6_BROWSER_HEADLESS=true + +ENTRYPOINT ["k6"] From a5fb29c268ddb3b4cd0148ed4c5aeb506edfcdf3 Mon Sep 17 00:00:00 2001 From: Andrew Slotin Date: Fri, 14 Jul 2023 14:54:35 +0200 Subject: [PATCH 3/3] Build and publish grafana/k6:with-browser images --- .github/workflows/build.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 65d450a6613..3bce111d2f7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -154,6 +154,8 @@ 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: | @@ -165,6 +167,8 @@ jobs: 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" - name: Publish tagged version image to ghcr.io if: ${{ startsWith(github.ref, 'refs/tags/v') }} run: | @@ -172,11 +176,15 @@ jobs: 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" # 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" fi - name: Log into Docker Hub @@ -190,6 +198,8 @@ jobs: 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" - name: Publish tagged version image to Docker Hub if: ${{ startsWith(github.ref, 'refs/tags/v') }} run: | @@ -197,11 +207,15 @@ jobs: 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 .