Add Gitea Actions workflow to automatically build and push Docker images to Gitea container registry. New files: - .gitea/workflows/build.yaml: Automated Docker build workflow - Triggers on push to main, tags, and manual dispatch - Builds Docker image from Dockerfile - Tags appropriately (commit SHA, tags, latest) - Pushes to Gitea registry at 10.0.1.10 - CONTAINER_REGISTRY.md: Complete documentation for: - Enabling Gitea container registry - Setting up CI/CD with Gitea Actions - Creating and using personal access tokens - Pulling and pushing images - Troubleshooting common issues The workflow is compatible with the existing Dockerfile and provides automated builds similar to the GitLab CI pipeline. Prerequisites: - Gitea container registry enabled - GITEA_TOKEN secret configured with write:package scope 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
5.1 KiB
Container Registry and CI/CD Setup
This document explains how to build and push Docker images using Gitea Actions and the Gitea Container Registry.
Overview
The SPARC project uses Gitea Actions (GitHub Actions-compatible) to automatically build and push Docker images to the Gitea Container Registry whenever code is pushed to the repository.
Workflow Configuration
The workflow is defined in .gitea/workflows/build.yaml and automatically:
- Builds the Docker image from the
Dockerfile - Tags the image appropriately based on the git ref (branch/tag)
- Pushes to the Gitea Container Registry at
10.0.1.10
Triggers
The workflow runs on:
- Push to main branch: Builds and tags with commit SHA +
latest - Push of tags: Builds and tags with the tag name +
latest - Manual dispatch: Can be triggered manually from Gitea UI
Image Naming
Images are pushed to: 10.0.1.10/0xwheatyz/sparc:<tag>
- Main branch commits:
10.0.1.10/0xwheatyz/sparc:<sha>and10.0.1.10/0xwheatyz/sparc:latest - Tags:
10.0.1.10/0xwheatyz/sparc:<tag-name>and10.0.1.10/0xwheatyz/sparc:latest - Other branches:
10.0.1.10/0xwheatyz/sparc:<branch-name>
Prerequisites
1. Enable Container Registry in Gitea
The Gitea instance must have the Container Registry (Packages) feature enabled:
- Access Gitea as administrator
- Go to Site Administration > Configuration
- Find "Packages" section
- Ensure packages/container registry is enabled
2. Create Personal Access Token
The workflow needs a personal access token with package write permissions:
- In Gitea UI, click your profile → Settings
- Go to Applications → Manage Access Tokens
- Click "Generate New Token"
- Give it a descriptive name (e.g., "Actions Container Registry")
- Select scopes:
write:package(required)read:package(required)
- Click "Generate Token"
- Copy the token immediately (you won't see it again)
3. Add Token as Repository Secret
- Go to your repository in Gitea
- Click Settings → Secrets
- Click "Add Secret"
- Name:
GITEA_TOKEN - Value: Paste the personal access token
- Click "Add Secret"
Usage
Automatic Builds
Once configured, the workflow runs automatically:
# Push to main branch - triggers build
git add .
git commit -m "feat: add new feature"
git push origin main
# Create and push a tag - triggers build with tag
git tag v1.0.0
git push origin v1.0.0
Manual Builds
You can also trigger builds manually:
- Go to repository → Actions
- Click on "Build and Push Docker Image" workflow
- Click "Run workflow"
- Select the branch
- Click "Run workflow"
Monitor Build Progress
- Go to repository → Actions
- Click on the running workflow
- View logs for each step
Pulling Images
Once built, images can be pulled from the registry:
# Log in to registry
docker login 10.0.1.10 -u your-username
# Pull the latest image
docker pull 10.0.1.10/0xwheatyz/sparc:latest
# Pull a specific tag
docker pull 10.0.1.10/0xwheatyz/sparc:v1.0.0
# Pull a specific commit
docker pull 10.0.1.10/0xwheatyz/sparc:abc1234
Troubleshooting
Workflow Fails at Login Step
Error: Error response from daemon: login attempt to http://10.0.1.10/v2/ failed with status: 404 Not Found
Solution: Container registry is not enabled in Gitea. Contact administrator to enable packages feature.
Workflow Fails with 401 Unauthorized
Error: unauthorized: authentication required
Solutions:
- Verify
GITEA_TOKENsecret exists and is correct - Verify token has
write:packageandread:packagescopes - Regenerate token if it has expired
Workflow Fails at Push Step
Error: denied: permission denied
Solutions:
- Ensure your user account has write access to the repository
- Verify the token has the correct permissions
- Check if the repository owner matches the registry path
Image Not Appearing in Packages
Check:
- Go to repository → Packages tab
- If no packages appear, check workflow logs for errors
- Verify the image was successfully pushed (check workflow output)
Advanced Configuration
Using a Different Registry
To push to a different container registry (e.g., Docker Hub, GHCR):
- Update the
REGISTRYvariable in.gitea/workflows/build.yaml - Update the login step with appropriate credentials
- Add registry credentials as secrets
Building Multi-platform Images
To build for multiple architectures:
- name: Build Docker image
run: |
docker buildx build \
--platform linux/amd64,linux/arm64 \
-t ${{ steps.tags.outputs.IMAGE_TAG }} \
--push .
Adding Build Arguments
To pass build arguments:
- name: Build Docker image
run: |
docker build \
--build-arg VERSION=${{ gitea.sha_short }} \
-t ${{ steps.tags.outputs.IMAGE_TAG }} .
References
- Gitea Actions Documentation
- Gitea Packages Documentation
- GitHub Actions Syntax (Gitea Actions compatible)