From 51fb504a2e2981739547c23d3a588a080aebea39 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Fri, 1 Aug 2025 14:04:02 +0000 Subject: [PATCH] feat: add an LXC based example of docker/build-push-action usage (#781) The motivations for this additional example are: - Using https://github.com/docker/build-push-action/ with the Forgejo runner is a recurring question and there is no example of how to do that - Reproducing https://code.forgejo.org/forgejo/runner/issues/208 will benefit from this example --- - features - [PR](https://code.forgejo.org/forgejo/runner/pulls/781): feat: add an LXC based example of docker/build-push-action usage [skip cascade] Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/781 Reviewed-by: Michael Kriese Co-authored-by: Earl Warren Co-committed-by: Earl Warren --- .../docker-build-push-action-in-lxc.yml | 78 +++++++++++++++++++ examples/README.md | 5 +- examples/docker-build-push-action/Dockerfile | 1 + examples/docker-build-push-action/README.md | 3 + 4 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 .forgejo/workflows/docker-build-push-action-in-lxc.yml create mode 100644 examples/docker-build-push-action/Dockerfile create mode 100644 examples/docker-build-push-action/README.md diff --git a/.forgejo/workflows/docker-build-push-action-in-lxc.yml b/.forgejo/workflows/docker-build-push-action-in-lxc.yml new file mode 100644 index 00000000..fe6b4eed --- /dev/null +++ b/.forgejo/workflows/docker-build-push-action-in-lxc.yml @@ -0,0 +1,78 @@ +# +# Example that requires a Forgejo runner with an [LXC backend](https://forgejo.org/docs/latest/admin/actions/runner-installation/#setting-up-the-container-environment). +# +# - Start a Forgejo instance to be used as a container registry +# - Build a container image using the [docker/build-push-action](https://code.forgejo.org/docker/build-push-action) action +# - Push the image to the Forgejo instance +# - Retrieve the image +# +# Runs of this workflow can be seen in [the Forgejo runner](https://code.forgejo.org/forgejo/runner/actions?workflow=docker-build-push-action-in-lxc.yml) logs. +# +name: example +on: + push: + branches: + - 'main' + pull_request: + +env: + FORGEJO_VERSION: 11.0.3 # renovate: datasource=docker depName=code.forgejo.org/forgejo/forgejo + FORGEJO_USER: root + FORGEJO_PASSWORD: admin1234 + +jobs: + docker-build-push-action-in-lxc: + if: forge.repository_owner != 'forgejo-integration' && forge.repository_owner != 'forgejo-experimental' && forge.repository_owner != 'forgejo-release' + runs-on: lxc-bookworm + + steps: + + - name: install Forgejo so it can be used as a container registry + id: registry + uses: https://data.forgejo.org/actions/setup-forgejo@v3.0.1 + with: + user: ${{ env.FORGEJO_USER }} + password: ${{ env.FORGEJO_PASSWORD }} + binary: https://code.forgejo.org/forgejo/forgejo/releases/download/v${{ env.FORGEJO_VERSION }}/forgejo-${{ env.FORGEJO_VERSION }}-linux-amd64 + lxc-ip-prefix: 10.0.9 + + - name: enable insecure / http uploads to the Forgejo registry + run: |- + set -x + # the docker daemon was implicitly installed when Forgejo was + # installed in the previous step. But it will refuse to connect + # to an insecure / http registry by default and must be told + # otherwise + cat > /etc/docker/daemon.json <