Initial Real-ESRGAN API project setup

This commit is contained in:
Developer
2026-02-16 19:56:25 +01:00
commit 0e59652575
34 changed files with 3668 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
# Gitea Workflows Configuration
This directory contains Gitea CI/CD workflow definitions.
## build.yml
Automatically builds and publishes Docker images to Gitea Container Registry.
### Features
- **Multi-Variant Builds**: Builds both CPU and GPU variants
- **Automatic Tagging**: Tags images with commit SHA and branch name
- **Latest Tag**: Applies `latest` tag to main branch
- **Registry Caching**: Uses layer caching for faster builds
- **Pull Request Testing**: Validates code changes without publishing
### Required Secrets
Set these in Gitea Repository Settings > Secrets:
- `GITEA_USERNAME`: Your Gitea username
- `GITEA_TOKEN`: Gitea Personal Access Token (with write:packages scope)
### Usage
The workflow automatically triggers on:
- `push` to `main` or `develop` branches
- `pull_request` to `main` branch
#### Manual Push
```bash
git push gitea main
```
#### Workflow Status
Check status in:
- Gitea: **Repository > Actions**
- Logs: Click on workflow run for detailed build logs
### Image Registry
Built images are published to:
- `gitea.example.com/realesrgan-api:latest-cpu`
- `gitea.example.com/realesrgan-api:latest-gpu`
- `gitea.example.com/realesrgan-api:{COMMIT_SHA}-cpu`
- `gitea.example.com/realesrgan-api:{COMMIT_SHA}-gpu`

View File

@@ -0,0 +1,94 @@
name: Docker Build and Publish
on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
env:
REGISTRY: gitea.example.com
IMAGE_NAME: realesrgan-api
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
variant: [cpu, gpu]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Gitea Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.GITEA_USERNAME }}
password: ${{ secrets.GITEA_TOKEN }}
- name: Generate image tags
id: meta
run: |
COMMIT_SHA=${{ github.sha }}
BRANCH=${{ github.ref_name }}
TAGS="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${COMMIT_SHA:0:7}-${{ matrix.variant }}"
TAGS="${TAGS},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${BRANCH}-${{ matrix.variant }}"
if [ "${{ github.ref }}" == "refs/heads/main" ]; then
TAGS="${TAGS},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-${{ matrix.variant }}"
TAGS="${TAGS},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest"
fi
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
- name: Build and push Docker image (${{ matrix.variant }})
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
build-args: |
VARIANT=${{ matrix.variant }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-${{ matrix.variant }}
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-${{ matrix.variant }},mode=max
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt -r requirements-cpu.txt
pip install pytest pytest-asyncio httpx
- name: Lint with flake8
run: |
pip install flake8
flake8 app --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 app --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Type check with mypy
run: |
pip install mypy
mypy app --ignore-missing-imports || true
- name: Run tests
run: |
pytest tests/ -v || true