Skip to content

Commit

Permalink
Use mirror.gcr.io as buildx pull-through cache
Browse files Browse the repository at this point in the history
Signed-off-by: Brad Davidson <[email protected]>
  • Loading branch information
brandond committed Jul 18, 2024
1 parent 1ba1b52 commit 4b33a5d
Show file tree
Hide file tree
Showing 10 changed files with 241 additions and 64 deletions.
51 changes: 45 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,27 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up buildx
uses: docker/setup-buildx-action@v3
id: buildx
with:
version: v0.16.0
driver: docker-container
buildkitd-config-inline: |
[registry."docker.io"]
mirrors = ["mirror.gcr.io"]
- name: Export Cache Env Vars
uses: actions/github-script@v7
env:
github-token: ${{ secrets.GITHUB_TOKEN }}
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env['ACTIONS_CACHE_URL'])
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env['ACTIONS_RUNTIME_TOKEN'])
core.exportVariable('ACTIONS_RUNTIME_URL', process.env['ACTIONS_RUNTIME_URL'])
- name: Install Dapper
run: |
curl -sL https://releases.rancher.com/dapper/latest/dapper-$(uname -s)-$(uname -m) > /usr/local/bin/dapper
curl -sL https://github.com/brandond/dapper/releases/download/v0.7.0-bd5/dapper-$(uname -s)-$(uname -m) > /usr/local/bin/dapper
chmod +x /usr/local/bin/dapper
- name: "Read secrets"
uses: rancher-eio/read-vault-secrets@main
Expand All @@ -31,21 +49,42 @@ jobs:
secret/data/github/repo/${{ github.repository }}/aws-secret-access-key/credentials token | AWS_SECRET_ACCESS_KEY ;
- name: Build
run: |
dapper -f Dockerfile --target dapper make dapper-ci
dapper -f Dockerfile --bake --cache-from=type=gha --cache-to=type=gha,ignore-error=true,mode=max --target dapper make dapper-ci
env:
AWS_ACCESS_KEY_ID: ${{ env.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ env.AWS_SECRET_ACCESS_KEY }}
BUILDX_BUILDER: ${{ steps.buildx.outputs.name }}
- name: Test
run: |
dapper -f Dockerfile --target dapper make test
dapper -f Dockerfile --bake --cache-from=type=gha --cache-to=type=gha,ignore-error=true,mode=max --target dapper make test
env:
BUILDX_BUILDER: ${{ steps.buildx.outputs.name }}
build-arm64:
runs-on: runs-on,runner=8cpu-linux-arm64,run-id=${{ github.run_id }},image=ubuntu22-full-arm64,hdd=64
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up buildx
uses: docker/setup-buildx-action@v3
id: buildx
with:
version: v0.16.0
driver: docker-container
buildkitd-config-inline: |
[registry."docker.io"]
mirrors = ["mirror.gcr.io"]
- name: Export Cache Env Vars
uses: actions/github-script@v7
env:
github-token: ${{ secrets.GITHUB_TOKEN }}
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env['ACTIONS_CACHE_URL'])
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env['ACTIONS_RUNTIME_TOKEN'])
core.exportVariable('ACTIONS_RUNTIME_URL', process.env['ACTIONS_RUNTIME_URL'])
- name: Install Dapper
run: |
curl -sL https://releases.rancher.com/dapper/latest/dapper-$(uname -s)-$(uname -m) > /usr/local/bin/dapper
curl -sL https://github.com/brandond/dapper/releases/download/v0.7.0-bd5/dapper-$(uname -s)-$(uname -m) > /usr/local/bin/dapper
chmod +x /usr/local/bin/dapper
- name: "Read secrets"
uses: rancher-eio/read-vault-secrets@main
Expand All @@ -55,8 +94,8 @@ jobs:
secret/data/github/repo/${{ github.repository }}/aws-secret-access-key/credentials token | AWS_SECRET_ACCESS_KEY ;
- name: Build
run: |
dapper -f Dockerfile --target dapper make dapper-ci
dapper -f Dockerfile --bake --cache-from=type=gha --cache-to=type=gha,ignore-error=true,mode=max --target dapper make dapper-ci
env:
AWS_ACCESS_KEY_ID: ${{ env.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ env.AWS_SECRET_ACCESS_KEY }}

BUILDX_BUILDER: ${{ steps.buildx.outputs.name }}
44 changes: 38 additions & 6 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,58 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up buildx
uses: docker/setup-buildx-action@v3
id: buildx
with:
version: v0.16.0
driver: docker-container
buildkitd-config-inline: |
[registry."docker.io"]
mirrors = ["mirror.gcr.io"]
- name: Export Cache Env Vars
uses: actions/github-script@v7
env:
github-token: ${{ secrets.GITHUB_TOKEN }}
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env['ACTIONS_CACHE_URL'])
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env['ACTIONS_RUNTIME_TOKEN'])
core.exportVariable('ACTIONS_RUNTIME_URL', process.env['ACTIONS_RUNTIME_URL'])
- name: Install Dapper
run: |
curl -sL https://releases.rancher.com/dapper/latest/dapper-$(uname -s)-$(uname -m) > /usr/local/bin/dapper
curl -sL https://github.com/brandond/dapper/releases/download/v0.7.0-bd5/dapper-$(uname -s)-$(uname -m) > /usr/local/bin/dapper
chmod +x /usr/local/bin/dapper
- name: Build
run: |
dapper -f Dockerfile --target dapper make dapper-ci
dapper -f Dockerfile --bake --cache-from=type=gha --cache-to=type=gha,ignore-error=true,mode=max --target dapper make dapper-ci
env:
BUILDX_BUILDER: ${{ steps.buildx.outputs.name }}
- name: Test
run: |
dapper -f Dockerfile --target dapper make test
dapper -f Dockerfile --bake --cache-from=type=gha --cache-to=type=gha,ignore-error=true,mode=max --target dapper make test
env:
BUILDX_BUILDER: ${{ steps.buildx.outputs.name }}
build-arm64:
runs-on: runs-on,runner=8cpu-linux-arm64,run-id=${{ github.run_id }},image=ubuntu22-full-arm64,hdd=64
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up buildx
uses: docker/setup-buildx-action@v3
id: buildx
with:
version: v0.16.0
driver: docker-container
buildkitd-config-inline: |
[registry."docker.io"]
mirrors = ["mirror.gcr.io"]
- name: Install Dapper
run: |
curl -sL https://releases.rancher.com/dapper/latest/dapper-$(uname -s)-$(uname -m) > /usr/local/bin/dapper
curl -sL https://github.com/brandond/dapper/releases/download/v0.7.0-bd5/dapper-$(uname -s)-$(uname -m) > /usr/local/bin/dapper
chmod +x /usr/local/bin/dapper
- name: Build
run: |
dapper -f Dockerfile --target dapper make dapper-ci
dapper -f Dockerfile --bake --cache-from=type=gha --cache-to=type=gha,ignore-error=true,mode=max --target dapper make dapper-ci
env:
BUILDX_BUILDER: ${{ steps.buildx.outputs.name }}
123 changes: 106 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,40 @@ jobs:

- name: Install Dapper
run: |
curl -sL https://releases.rancher.com/dapper/latest/dapper-$(uname -s)-$(uname -m) > /usr/local/bin/dapper
curl -sL https://github.com/brandond/dapper/releases/download/v0.7.0-bd5/dapper-$(uname -s)-$(uname -m) > /usr/local/bin/dapper
chmod +x /usr/local/bin/dapper
- name: Set up buildx
uses: docker/setup-buildx-action@v3
id: buildx
with:
version: v0.16.0
driver: docker-container
buildkitd-config-inline: |
[registry."docker.io"]
mirrors = ["mirror.gcr.io"]
- name: Export Cache Env Vars
uses: actions/github-script@v7
env:
github-token: ${{ secrets.GITHUB_TOKEN }}
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env['ACTIONS_CACHE_URL'])
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env['ACTIONS_RUNTIME_TOKEN'])
core.exportVariable('ACTIONS_RUNTIME_URL', process.env['ACTIONS_RUNTIME_URL'])
- name: Validate Release
run: |
dapper -f Dockerfile --target dapper make validate-release
dapper -f Dockerfile --bake --cache-from=type=gha --cache-to=type=gha,ignore-error=true,mode=max --target dapper make validate-release
env:
BUILDX_BUILDER: ${{ steps.buildx.outputs.name }}

- name: Build
run: |
dapper -f Dockerfile --target dapper make dapper-ci
dapper -f Dockerfile --bake --cache-from=type=gha --cache-to=type=gha,ignore-error=true,mode=max --target dapper make dapper-ci
env:
BUILDX_BUILDER: ${{ steps.buildx.outputs.name }}

- name: "Read secrets"
uses: rancher-eio/read-vault-secrets@main
Expand All @@ -45,27 +69,38 @@ jobs:
- name: Package Images
run: |
dapper -f Dockerfile --target dapper make package-images
dapper -f Dockerfile --bake --cache-from=type=gha --cache-to=type=gha,ignore-error=true,mode=max --target dapper make package-images
env:
BUILDX_BUILDER: ${{ steps.buildx.outputs.name }}

- name: Scan Images
continue-on-error: true
run: |
dapper -f Dockerfile --target dapper make scan-images
dapper -f Dockerfile --bake --cache-from=type=gha --cache-to=type=gha,ignore-error=true,mode=max --target dapper make scan-images
env:
BUILDX_BUILDER: ${{ steps.buildx.outputs.name }}

- name: Test
run: |
dapper -f Dockerfile --target dapper make test
dapper -f Dockerfile --bake --cache-from=type=gha --cache-to=type=gha,ignore-error=true,mode=max --target dapper make test
env:
BUILDX_BUILDER: ${{ steps.buildx.outputs.name }}

- name: Publish Image Runtime
run: |
GITHUB_ACTION_TAG=${{ github.ref_name }} dapper -f Dockerfile --target dapper make publish-image-runtime
dapper -f Dockerfile --bake --cache-from=type=gha --cache-to=type=gha,ignore-error=true,mode=max --target dapper make publish-image-runtime
env:
DOCKER_USERNAME: ${{ env.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ env.DOCKER_PASSWORD }}
BUILDX_BUILDER: ${{ steps.buildx.outputs.name }}
GITHUB_ACTION_TAG: ${{ github.ref_name }}

- name: Checksum Artifacts
run: |
GITHUB_ACTION_TAG=${{ github.ref_name }} dapper -f Dockerfile --target dapper make checksum
dapper -f Dockerfile --bake --cache-from=type=gha --cache-to=type=gha,ignore-error=true,mode=max --target dapper make checksum
env:
BUILDX_BUILDER: ${{ steps.buildx.outputs.name }}
GITHUB_ACTION_TAG: ${{ github.ref_name }}

- name: Publish Artifacts
run: |
Expand All @@ -76,18 +111,42 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up buildx
uses: docker/setup-buildx-action@v3
id: buildx
with:
version: v0.16.0
driver: docker-container
buildkitd-config-inline: |
[registry."docker.io"]
mirrors = ["mirror.gcr.io"]
- name: Export Cache Env Vars
uses: actions/github-script@v7
env:
github-token: ${{ secrets.GITHUB_TOKEN }}
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env['ACTIONS_CACHE_URL'])
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env['ACTIONS_RUNTIME_TOKEN'])
core.exportVariable('ACTIONS_RUNTIME_URL', process.env['ACTIONS_RUNTIME_URL'])
- name: Install Dapper
run: |
curl -sL https://releases.rancher.com/dapper/latest/dapper-$(uname -s)-$(uname -m) > /usr/local/bin/dapper
curl -sL https://github.com/brandond/dapper/releases/download/v0.7.0-bd5/dapper-$(uname -s)-$(uname -m) > /usr/local/bin/dapper
chmod +x /usr/local/bin/dapper
- name: Validate Release
run: |
dapper -f Dockerfile --target dapper make validate-release
dapper -f Dockerfile --bake --cache-from=type=gha --cache-to=type=gha,ignore-error=true,mode=max --target dapper make validate-release
env:
BUILDX_BUILDER: ${{ steps.buildx.outputs.name }}

- name: Build
run: |
dapper -f Dockerfile --target dapper make dapper-ci
dapper -f Dockerfile --bake --cache-from=type=gha --cache-to=type=gha,ignore-error=true,mode=max --target dapper make dapper-ci
env:
BUILDX_BUILDER: ${{ steps.buildx.outputs.name }}

- name: "Read secrets"
uses: rancher-eio/read-vault-secrets@main
Expand All @@ -98,23 +157,32 @@ jobs:
- name: Package Images
run: |
dapper -f Dockerfile --target dapper make package-images
dapper -f Dockerfile --bake --cache-from=type=gha --cache-to=type=gha,ignore-error=true,mode=max --target dapper make package-images
env:
BUILDX_BUILDER: ${{ steps.buildx.outputs.name }}

- name: Scan Images
continue-on-error: true
run: |
dapper -f Dockerfile --target dapper make scan-images
dapper -f Dockerfile --bake --cache-from=type=gha --cache-to=type=gha,ignore-error=true,mode=max --target dapper make scan-images
env:
BUILDX_BUILDER: ${{ steps.buildx.outputs.name }}

- name: Publish Image Runtime
run: |
GITHUB_ACTION_TAG=${{ github.ref_name }} dapper -f Dockerfile --target dapper make publish-image-runtime
dapper -f Dockerfile --bake --cache-from=type=gha --cache-to=type=gha,ignore-error=true,mode=max --target dapper make publish-image-runtime
env:
DOCKER_USERNAME: ${{ env.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ env.DOCKER_PASSWORD }}
BUILDX_BUILDER: ${{ steps.buildx.outputs.name }}
GITHUB_ACTION_TAG: ${{ github.ref_name }}

- name: Checksum
run: |
GITHUB_ACTION_TAG=${{ github.ref_name }} dapper -f Dockerfile --target dapper make checksum
dapper -f Dockerfile --bake --cache-from=type=gha --cache-to=type=gha,ignore-error=true,mode=max --target dapper make checksum
env:
BUILDX_BUILDER: ${{ steps.buildx.outputs.name }}
GITHUB_ACTION_TAG: ${{ github.ref_name }}

- name: Publish Artifacts
run: |
Expand All @@ -126,9 +194,29 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up buildx
uses: docker/setup-buildx-action@v3
id: buildx
with:
version: v0.16.0
driver: docker-container
buildkitd-config-inline: |
[registry."docker.io"]
mirrors = ["mirror.gcr.io"]
- name: Export Cache Env Vars
uses: actions/github-script@v7
env:
github-token: ${{ secrets.GITHUB_TOKEN }}
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env['ACTIONS_CACHE_URL'])
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env['ACTIONS_RUNTIME_TOKEN'])
core.exportVariable('ACTIONS_RUNTIME_URL', process.env['ACTIONS_RUNTIME_URL'])
- name: Install Dapper
run: |
curl -sL https://releases.rancher.com/dapper/latest/dapper-$(uname -s)-$(uname -m) > /usr/local/bin/dapper
curl -sL https://github.com/brandond/dapper/releases/download/v0.7.0-bd5/dapper-$(uname -s)-$(uname -m) > /usr/local/bin/dapper
chmod +x /usr/local/bin/dapper
- name: "Read secrets"
Expand All @@ -139,8 +227,9 @@ jobs:
- name: Dispatch
run: |
dapper -f Dockerfile --target dapper make dispatch
dapper -f Dockerfile --bake --cache-from=type=gha --cache-to=type=gha,ignore-error=true,mode=max --target dapper make dispatch
env:
PAT_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PATH_USERNAME: ${{ env.PAT_USERNAME }}
GITHUB_ACTION_TAG: ${{ env.GITHUB_ACTION_TAG }}
BUILDX_BUILDER: ${{ steps.buildx.outputs.name }}
Loading

0 comments on commit 4b33a5d

Please sign in to comment.