Skip to content

Commit

Permalink
Merge pull request #3199 from grafana/browser_enabled_image
Browse files Browse the repository at this point in the history
Build and publish browser-enabled Docker image
  • Loading branch information
andrewslotin authored Jul 25, 2023
2 parents 344c446 + a5fb29c commit 8a04dc0
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
16 changes: 15 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -165,18 +167,24 @@ 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: |
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"
# 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
Expand All @@ -190,21 +198,27 @@ 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: |
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 .
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: |
Expand Down
20 changes: 19 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,26 @@ WORKDIR /home/k6
ENTRYPOINT ["k6"]

# Legacy loadimpact/k6 image
FROM release
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"]

0 comments on commit 8a04dc0

Please sign in to comment.