Skip to content

Commit

Permalink
Add permissions and fix typos
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahchen6 committed Sep 23, 2024
1 parent c515a44 commit b21b304
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ on:
jobs:
build:
runs-on: ubuntu-latest
name: Build ruby 3.4
name: Build Docker image
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -30,17 +33,17 @@ jobs:
# Tag image separately to avoid interference with caching and so that testing step can reference the image
- name: Build single-arch image (x86-64)
run: |
docker buildx build . --builder=container --cache-from=type=registry,ref=ghrc.io/datadog/catadog --output=type=image,push=false --platform linux/x86_64 -f ./Dockerfile
docker buildx build . --builder=container --cache-from=type=registry,ref=ghcr.io/datadog/catadog --output=type=image,push=false --platform linux/x86_64 -f ./Dockerfile
- name: Tag single-arch image (x86-64)
run: |
docker buildx build . --builder=container --cache-from=type=registry,ref=ghrc.io/datadog/catadog --load --platform linux/x86_64 -f ./Dockerfile --tag ghrc.io/datadog/catadog
docker buildx build . --builder=container --cache-from=type=registry,ref=ghcr.io/datadog/catadog --load --platform linux/x86_64 -f ./Dockerfile --tag ghcr.io/datadog/catadog
- name: Test single-arch image (x86-64)
run: |
docker run --platform linux/x86_64 --rm ghrc.io/datadog/catadog /bin/sh -c 'true'
docker run --platform linux/x86_64 --rm ghrc.io/datadog/catadog ruby -e 'puts RUBY_DESCRIPTION'
docker run --platform linux/x86_64 --rm ghrc.io/datadog/catadog gem --version
docker run --platform linux/x86_64 --rm ghrc.io/datadog/catadog bundle --version
docker run --platform linux/x86_64 --rm -v "${PWD}":"${PWD}" -w "${PWD}" ghrc.io/datadog/catadog /bin/sh -c 'bundle install && bundle exec rake test'
docker run --platform linux/x86_64 --rm ghcr.io/datadog/catadog /bin/sh -c 'true'
docker run --platform linux/x86_64 --rm ghcr.io/datadog/catadog ruby -e 'puts RUBY_DESCRIPTION'
docker run --platform linux/x86_64 --rm ghcr.io/datadog/catadog gem --version
docker run --platform linux/x86_64 --rm ghcr.io/datadog/catadog bundle --version
docker run --platform linux/x86_64 --rm -v "${PWD}":"${PWD}" -w "${PWD}" ghcr.io/datadog/catadog /bin/sh -c 'bundle install && bundle exec rake test'
# Build image for aarch64-linux, emulated under qemu
#
Expand All @@ -50,26 +53,26 @@ jobs:
docker run --privileged --rm tonistiigi/binfmt --install arm64
- name: Build single-arch image (aarch64-linux)
run: |
docker buildx build . --builder=container --cache-from=type=registry,ref=ghrc.io/datadog/catadog --output=type=image,push=false --platform linux/aarch64 -f ./Dockerfile
docker buildx build . --builder=container --cache-from=type=registry,ref=ghcr.io/datadog/catadog --output=type=image,push=false --platform linux/aarch64 -f ./Dockerfile
- name: Tag single-arch image (aarch64-linux)
run: |
docker buildx build . --builder=container --cache-from=type=registry,ref=ghrc.io/datadog/catadog --load --platform linux/aarch64 -f ./Dockerfile --tag ghrc.io/datadog/catadog
docker buildx build . --builder=container --cache-from=type=registry,ref=ghcr.io/datadog/catadog --load --platform linux/aarch64 -f ./Dockerfile --tag ghcr.io/datadog/catadog
- name: Test single-arch image (aarch64-linux)
run: |
docker run --platform linux/aarch64 --rm ghrc.io/datadog/catadog /bin/sh -c 'true'
docker run --platform linux/aarch64 --rm ghrc.io/datadog/catadog ruby -e 'puts RUBY_DESCRIPTION'
docker run --platform linux/aarch64 --rm ghrc.io/datadog/catadog gem --version
docker run --platform linux/aarch64 --rm ghrc.io/datadog/catadog bundle --version
docker run --platform linux/aarch64 --rm -v "${PWD}":"${PWD}" -w "${PWD}" ghrc.io/datadog/catadog /bin/sh -c 'bundle install && bundle exec rake test'
docker run --platform linux/aarch64 --rm ghcr.io/datadog/catadog /bin/sh -c 'true'
docker run --platform linux/aarch64 --rm ghcr.io/datadog/catadog ruby -e 'puts RUBY_DESCRIPTION'
docker run --platform linux/aarch64 --rm ghcr.io/datadog/catadog gem --version
docker run --platform linux/aarch64 --rm ghcr.io/datadog/catadog bundle --version
docker run --platform linux/aarch64 --rm -v "${PWD}":"${PWD}" -w "${PWD}" ghcr.io/datadog/catadog /bin/sh -c 'bundle install && bundle exec rake test'
# Assemble multi-arch image for a combined push to the registry
#
# Docker build is rerun, but build is fast because the layers are already cached
- name: Log in to the container registry
if: ${{ inputs.push }}
run: |
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghrc.io -u ${{ github.actor }} --password-stdin
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Build multi-arch image (x86-64, aarch64)
if: ${{ inputs.push }}
run: |
docker buildx build . --builder=container --cache-from=type=registry,ref=ghrc.io/datadog/catadog --output=type=image,push=true --build-arg BUILDKIT_INLINE_CACHE=1 --platform linux/x86_64,linux/aarch64 -f ./Dockerfile --tag ghrc.io/datadog/catadog
docker buildx build . --builder=container --cache-from=type=registry,ref=ghcr.io/datadog/catadog --output=type=image,push=true --build-arg BUILDKIT_INLINE_CACHE=1 --platform linux/x86_64,linux/aarch64 -f ./Dockerfile --tag ghcr.io/datadog/catadog

0 comments on commit b21b304

Please sign in to comment.