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

feat: set up docker buildx builder #68

Merged
merged 1 commit into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion .github/workflows/pr-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,9 @@ jobs:
role: ${{ steps.baseproject.outputs.gha_vault_role }}
secrets: |
zon/v1/github-actions-baseproject-tests/example foo | EXAMPLE_VAULT_VALUE ;


- name: '[TEST] Run docker build'
run: |
docker buildx build --output type=docker \
--cache-from type=gha --cache-to type=gha,mode=max \
--tag test ./test
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@ jobs:
```


### Set up docker buildx

For both convenience and consistency this action can also set up a `docker buildx` builder.

This behaviour is controlled by the `setup_buildx` input, which defaults to "do nothing";
set it to "true" to enable.
Setting `gar_docker_auth` also enables this implicitly
(with the assumption, if you want to push a docker image, you probably want to build one first),
if this is not desired, set `setup_buildx` to "false" explicitly.


## Reference

Here are all the inputs available through `with`:
Expand All @@ -82,6 +93,7 @@ Here are all the inputs available through `with`:
| `gar_docker_auth` | Authenticate to GAR (Google Artifact Registry) for Docker | `false` | |
| `python_registry` | Setup dependencies for Python Registry (Google Artifact Registry) | `false` | |
| `vault_export_token` | Get a Vault Token and export it as VAULT_TOKEN | `false` | |
| `setup_buildx` | Set up docker buildx | `unset` | |


## Releases
Expand Down
23 changes: 23 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ inputs:
required: false
default: 'false'

# docker setup, both for convenience and centralization
setup_buildx:
description: 'Setup docker buildx. Enabling gar_docker_auth implies this; set explicitly to "false" to disable'
required: false
default: 'unset'

outputs:
project_name:
value: ${{ steps.baseproject-config.outputs.project_name }}
Expand Down Expand Up @@ -209,3 +215,20 @@ runs:
shell: bash
run: |
python -m pip install --upgrade --upgrade-strategy eager setuptools twine keyrings.google-artifactregistry-auth

- name: Parse setup docker buildx input
shell: bash
run: |
setup_buildx="${{ inputs.setup_buildx }}"
if [[ "$setup_buildx" != "false" && "${{ inputs.gar_docker_auth }}" = "true" ]]; then
setup_build="true"
fi
echo "setup_buildx=$setup_buildx" >> $GITHUB_ENV
- name: Setup docker buildx container
if: env.setup_buildx == 'true'
uses: docker/[email protected]
norman-zon marked this conversation as resolved.
Show resolved Hide resolved
# Support `docker buildx build --cache-[from}to] type=gha` directly,
# and not just via docker/build-push-action.
- name: Setup docker buildx environment
if: env.setup_buildx == 'true'
uses: crazy-max/[email protected]
1 change: 1 addition & 0 deletions test/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM nginx:latest
Loading