Add Gitea Actions CI/CD for automated Docker builds

- Add .gitea/workflows/docker.yml: builds and pushes Docker image on Git tags
  with semantic versioning (v0.1.0 → tags 0.1.0, 0.1, latest)
- Add .dockerignore to optimize Docker build context
- Document release process in docs/DEVELOPMENT.md
- Update CHANGELOG.md with v0.1.0 release and Unreleased CI/CD entry

Required Gitea secrets: REGISTRY_USERNAME, REGISTRY_PASSWORD

Co-authored-by: Junie <junie@jetbrains.com>
This commit is contained in:
2026-10-28 23:27:29 +01:00
co-authored by Junie
parent 597d8f380a
commit f3e095dafc
4 changed files with 136 additions and 7 deletions
+27 -7
View File
@@ -1,9 +1,29 @@
# Docker build context exclusions
.git
.github
.gitea
docs
*.md
!.markdownlint.yaml
.idea
**/.idea
**/node_modules
**/dist
**/.gradle
**/.angular
*.iml
node_modules
.gradle
build
dist
.DS_Store
*.log
*.tmp
*.swp
*~
# Frontend build artifacts (built inside Docker)
frontend/dist
frontend/.angular
# Backend build artifacts (built inside Docker)
backend/build
backend/libs
# Test reports
backend/build/reports
# Secrets
.env
.env.*
+50
View File
@@ -0,0 +1,50 @@
name: Docker Build and Push
on:
push:
tags:
- 'v*'
env:
REGISTRY: gitea.jambotron.com
IMAGE_NAME: liosha84/htop-web
jobs:
build-and-push:
runs-on: ubuntu-latest
container:
image: catthehacker/ubuntu:act-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Extract version from tag
id: version
run: |
# Remove 'v' prefix from tag (e.g., v0.1.0 → 0.1.0)
VERSION=$(echo "${{ gitea.ref }}" | sed 's|refs/tags/v||')
echo "version=${VERSION}" >> "${GITEA_OUTPUT}"
# Extract major.minor for minor tag (e.g., 0.1.0 → 0.1)
MINOR=$(echo "${VERSION}" | sed 's/\.[0-9]*$//')
echo "minor=${MINOR}" >> "${GITEA_OUTPUT}"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Gitea Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }}
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.minor }}
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
+6
View File
@@ -6,6 +6,12 @@ This project has not yet established a versioned changelog. Add entries as relea
## Unreleased
- **CI/CD with Gitea Actions** — automated Docker image build and push on Git tags. Each release produces three tags: full version (`0.2.0`), minor version (`0.2`), and `latest`. Configure `REGISTRY_USERNAME` and `REGISTRY_PASSWORD` secrets in Gitea repository settings.
- **Docker build optimization** — added `.dockerignore` to exclude unnecessary files from the build context, reducing build time and image size.
- **Release documentation** — added detailed release process guide in `docs/DEVELOPMENT.md` with Semantic Versioning workflow.
## v0.1.0
- **Multi-stage Docker build** — the Dockerfile now compiles both the Angular frontend and Spring Boot backend inside Docker using three stages (Node.js → Gradle → JRE). Build the entire application with a single `docker build` command — no local Java or Node.js required.
- **Security hardening** — replaced full host root mount (`/:/host/root:ro`) with specific directory mounts (`/proc`, `/sys`, `/etc/hostname`, `/etc/os-release`, `/var`, `/home`, `/opt`, `/tmp`, `/srv`, `/usr`) to minimize the attack surface.
- **Host metrics consistency** — `LinuxMemoryService` and `CpuDetailsService` now read host metrics from `/host/proc` instead of container metrics from OSHI.
+53
View File
@@ -91,6 +91,59 @@ docker run -d \
htop-web
```
## Release process
### Prerequisites
- Gitea Actions runner must be configured and running.
- Repository secrets `REGISTRY_USERNAME` and `REGISTRY_PASSWORD` must be set in **Settings → Secrets** of the Gitea repository. These credentials are used to authenticate with the Gitea Container Registry.
### Creating a release
1. **Update `CHANGELOG.md`** with changes for the new version.
2. **Commit and push** your changes:
```bash
git add -A
git commit -m "Prepare release v0.2.0"
git push origin master
```
3. **Create and push a Git tag** with Semantic Versioning:
```bash
git tag -a v0.2.0 -m "Release v0.2.0: new features and fixes"
git push origin v0.2.0
```
4. **Gitea Actions** will automatically:
- Build the Docker image using the multi-stage Dockerfile
- Tag it with the version (`0.2.0`), minor version (`0.2`), and `latest`
- Push all three tags to the Gitea Container Registry
### Docker image tags
Each release produces three Docker image tags:
| Tag | Example | Description |
|-----|---------|-------------|
| Full version | `gitea.jambotron.com/liosha84/htop-web:0.2.0` | Exact version, use in production |
| Minor version | `gitea.jambotron.com/liosha84/htop-web:0.2` | Latest patch of 0.2.x |
| Latest | `gitea.jambotron.com/liosha84/htop-web:latest` | Most recent stable release |
### Using a specific version in production
In `docker-compose.yml`, always pin to a specific version:
```yaml
services:
htop-web:
image: gitea.jambotron.com/liosha84/htop-web:0.2.0
```
Avoid using `:latest` in production — it makes rollbacks impossible and breaks reproducibility.
## Contribution guidelines
- Keep changes focused and reviewable.