Add Docker CLI bootstrap and update README with DOCKER_HOST instructions
Some checks failed
Publish Container / publish (push) Failing after 1m0s

This commit is contained in:
MaddoScientisto 2026-03-14 17:48:36 +01:00
commit 1f29b94491
2 changed files with 45 additions and 0 deletions

View file

@ -15,6 +15,10 @@ env:
jobs: jobs:
publish: publish:
runs-on: docker runs-on: docker
env:
# Keep the runner-provided DOCKER_HOST when available.
# For common dind sidecar setups, this default works out of the box.
DOCKER_HOST: ${{ vars.DOCKER_HOST != '' && vars.DOCKER_HOST || 'tcp://forgejo-docker-in-docker:2375' }}
steps: steps:
- name: Checkout - name: Checkout
@ -38,6 +42,37 @@ jobs:
if [ -z "${{ secrets.FORGEJO_REGISTRY_USERNAME }}" ]; then echo "secrets.FORGEJO_REGISTRY_USERNAME is required"; exit 1; fi if [ -z "${{ secrets.FORGEJO_REGISTRY_USERNAME }}" ]; then echo "secrets.FORGEJO_REGISTRY_USERNAME is required"; exit 1; fi
if [ -z "${{ secrets.FORGEJO_REGISTRY_TOKEN }}" ]; then echo "secrets.FORGEJO_REGISTRY_TOKEN is required"; exit 1; fi if [ -z "${{ secrets.FORGEJO_REGISTRY_TOKEN }}" ]; then echo "secrets.FORGEJO_REGISTRY_TOKEN is required"; exit 1; fi
- name: Ensure Docker CLI exists
run: |
set -eu
if command -v docker >/dev/null 2>&1; then
docker --version
exit 0
fi
ARCH="$(uname -m)"
case "${ARCH}" in
x86_64) DOCKER_ARCH="x86_64" ;;
aarch64|arm64) DOCKER_ARCH="aarch64" ;;
*) echo "Unsupported architecture for Docker CLI bootstrap: ${ARCH}"; exit 1 ;;
esac
DOCKER_CLI_VERSION="27.5.1"
curl -fsSL "https://download.docker.com/linux/static/stable/${DOCKER_ARCH}/docker-${DOCKER_CLI_VERSION}.tgz" -o docker.tgz
tar -xzf docker.tgz
mkdir -p "${HOME}/.local/bin"
mv docker/docker "${HOME}/.local/bin/docker"
chmod +x "${HOME}/.local/bin/docker"
echo "${HOME}/.local/bin" >> "${GITHUB_PATH}"
"${HOME}/.local/bin/docker" --version
- name: Check Docker daemon connectivity
run: |
set -eu
echo "Using DOCKER_HOST=${DOCKER_HOST}"
docker version
docker info >/dev/null
- name: Restore and publish app - name: Restore and publish app
run: dotnet publish src/MaddoScientisto.Web/MaddoScientisto.Web.csproj -c Release -o ./artifacts/publish run: dotnet publish src/MaddoScientisto.Web/MaddoScientisto.Web.csproj -c Release -o ./artifacts/publish

View file

@ -41,6 +41,7 @@ Set these Forgejo Actions variables:
- `FORGEJO_REGISTRY` (example: `forgejo.example.com`) - `FORGEJO_REGISTRY` (example: `forgejo.example.com`)
- `IMAGE_NAMESPACE` (example: `maddo`) - `IMAGE_NAMESPACE` (example: `maddo`)
- `IMAGE_NAME` (example: `maddoscientisto-web`) - `IMAGE_NAME` (example: `maddoscientisto-web`)
- Optional: `DOCKER_HOST` (example: `tcp://forgejo-docker-in-docker:2375`)
Set these Forgejo Actions secrets: Set these Forgejo Actions secrets:
@ -53,3 +54,12 @@ The workflow in `.forgejo/workflows/publish-container.yml` runs on pushes to `ma
- `${FORGEJO_REGISTRY}/${IMAGE_NAMESPACE}/${IMAGE_NAME}:latest` - `${FORGEJO_REGISTRY}/${IMAGE_NAMESPACE}/${IMAGE_NAME}:latest`
- `${FORGEJO_REGISTRY}/${IMAGE_NAMESPACE}/${IMAGE_NAME}:sha-<12-char-commit>` - `${FORGEJO_REGISTRY}/${IMAGE_NAMESPACE}/${IMAGE_NAME}:sha-<12-char-commit>`
## Forgejo runner notes (Docker-in-Docker)
If the runner image does not contain the `docker` binary, the workflow bootstraps a Docker CLI in user space before login/build/push.
For dind-based runners, ensure the job can reach your daemon over `DOCKER_HOST`.
With your compose topology, the default `tcp://forgejo-docker-in-docker:2375` should work.
If you still get connection failures after the CLI bootstrap step, set a repo variable named `DOCKER_HOST` to the correct daemon endpoint for your runner network.