3.1 KiB
Docker Build & Registry — ${REPO_NAME}
Overview
The Docker workflow (.gitea/workflows/docker.yml) builds Docker images and
optionally pushes them to the Gitea Container Registry.
Gitea Container Registry Naming Convention
Gitea's registry follows this pattern:
{REGISTRY_HOST}/{OWNER}/{IMAGE}:{TAG}
Example:
git.hiddenden.cafe/myorg/myapp:1.2.3
This is different from Docker Hub (docker.io/library/myapp:latest).
The workflow enforces this format automatically.
Dynamic Owner/Repo Derivation
The workflow dynamically determines the image owner and name so it works for both user repos and organization repos without hardcoding.
Logic:
- Determine
FULL_REPOfrom (in priority order):$GITEA_REPOSITORY(Gitea native environment variable)${{ github.repository }}(Gitea Actions compatibility layer)
- Split into
OWNER(before/) andREPO(after/). - If
IMAGE_OWNER=autoin config → useOWNER; else use the config value. - If
IMAGE_NAME=autoin config → useREPO; else use the config value.
This means you rarely need to change IMAGE_OWNER or IMAGE_NAME.
Triggers & Push Behavior
| Event | Build? | Push? | Condition |
|---|---|---|---|
| Pull Request | Yes | No | Never pushes on PRs |
Push to main |
Yes | Conditional | DOCKER_PUSH=true AND DOCKER_PUSH_ON_BRANCH=true |
Tag v1.2.3 |
Yes | Conditional | DOCKER_PUSH=true AND DOCKER_PUSH_ON_TAG=true |
Safe default: DOCKER_PUSH=false — images are built but never pushed.
Tag Strategy
Controlled by DOCKER_TAG_STRATEGY in .ci/config.env:
semver+latest (default)
- Tag
v1.2.3→ pushes:1.2.3and:latest - Push to
main→ pushes:main
semver
- Tag
v1.2.3→ pushes:1.2.3only - Push to
main→ pushes:main
branch
- Branch pushes only, tagged as
:branchname
Required Secrets
To push images, set these secrets in your Gitea repository (Settings → Actions → Secrets):
| Secret | Description |
|---|---|
REGISTRY_USERNAME |
Gitea username or bot account name |
REGISTRY_TOKEN |
Personal Access Token with package:write scope |
Creating a PAT
- Go to Settings → Applications → Generate New Token
- Name: e.g.,
ci-docker-push - Scopes: select
package(read + write) - Copy the token and add it as
REGISTRY_TOKENin repo secrets
Why PAT instead of job token? Gitea Actions job tokens may not have sufficient permissions for the container registry in all configurations. PATs are the recommended approach.
Detection
The workflow auto-detects how to build:
- Dockerfile →
docker build -t <image>:<tag> . - docker-compose.yml →
docker compose build - Neither → exits 0 with a message (graceful skip)
Enabling Docker Push
- Set
DOCKER_PUSH=truein.ci/config.env - Add
REGISTRY_USERNAMEandREGISTRY_TOKENsecrets - Push a commit or tag — the workflow will build and push
Pulling Images
After pushing, pull images with:
docker pull git.hiddenden.cafe/<owner>/<repo>:latest