feat: Gitea Actions CI/CD pipeline with container registry builds
Some checks failed
Build and Push Docker Image / Build & push to Gitea registry (push) Has been cancelled
Some checks failed
Build and Push Docker Image / Build & push to Gitea registry (push) Has been cancelled
- .gitea/workflows/docker.yml: builds and pushes image to devops.cloudhost.es/malin/paste.es on every push to main, tags as :latest and :<short-sha>, uses GHA layer cache - docker-compose.yml: updated to pull pre-built image from Gitea container registry instead of building locally - docker-compose.build.yml: new override file for local dev builds (docker compose -f docker-compose.yml -f docker-compose.build.yml up --build) - docker-compose.runner.yml: act_runner service — mount docker socket, auto-registers with RUNNER_REGISTRATION_TOKEN from .env - .env.example: added RUNNER_REGISTRATION_TOKEN section - README.md: document CI/CD setup, runner registration, and updated quick-start to use registry pull workflow Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -117,3 +117,12 @@ HEMMELIG_ANALYTICS_ENABLED=false
|
|||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
# (Los webhooks se configuran desde el panel de administración en /dashboard/instance)
|
# (Los webhooks se configuran desde el panel de administración en /dashboard/instance)
|
||||||
|
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# GITEA ACTIONS RUNNER — Solo necesario si ejecutas el runner en este servidor
|
||||||
|
# Obtén el token en: https://devops.cloudhost.es/Malin/paste.es/settings/actions/runners
|
||||||
|
# Luego arranca con: docker compose -f docker-compose.runner.yml up -d
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# RUNNER_REGISTRATION_TOKEN=
|
||||||
|
|||||||
44
.gitea/workflows/docker.yml
Normal file
44
.gitea/workflows/docker.yml
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
name: Build and Push Docker Image
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Build & push to Gitea registry
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Login to Gitea Container Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: devops.cloudhost.es
|
||||||
|
username: ${{ gitea.actor }}
|
||||||
|
password: ${{ secrets.GITEA_TOKEN }}
|
||||||
|
|
||||||
|
- name: Extract image metadata
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: devops.cloudhost.es/malin/paste.es
|
||||||
|
tags: |
|
||||||
|
type=raw,value=latest,enable={{is_default_branch}}
|
||||||
|
type=sha,prefix=,format=short
|
||||||
|
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
||||||
76
README.md
76
README.md
@@ -34,37 +34,43 @@ Servicio de compartición de secretos efímeros y cifrados para el público hisp
|
|||||||
|
|
||||||
## Inicio rápido
|
## Inicio rápido
|
||||||
|
|
||||||
### Docker Compose (recomendado)
|
### Docker Compose — imagen desde el registro (recomendado en producción)
|
||||||
|
|
||||||
|
Cada push a `main` construye y publica automáticamente la imagen en el registro de contenedores de Gitea. En el servidor de producción solo necesitas hacer pull:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://devops.cloudhost.es/Malin/paste.es.git
|
git clone https://devops.cloudhost.es/Malin/paste.es.git
|
||||||
cd paste.es
|
cd paste.es
|
||||||
|
|
||||||
|
# Autentícate en el registro de Gitea
|
||||||
|
docker login devops.cloudhost.es
|
||||||
|
|
||||||
# Copia y edita el fichero de entorno
|
# Copia y edita el fichero de entorno
|
||||||
cp .env.example .env
|
cp .env.example .env
|
||||||
# Edita .env con tus valores (ver sección Configuración)
|
|
||||||
|
|
||||||
# Construye y arranca
|
# Descarga la imagen y arranca
|
||||||
docker compose up -d --build
|
docker compose pull
|
||||||
|
docker compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
Para actualizar a la última versión:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker compose pull && docker compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
### Docker Compose — compilación local (desarrollo)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone https://devops.cloudhost.es/Malin/paste.es.git
|
||||||
|
cd paste.es
|
||||||
|
cp .env.example .env
|
||||||
|
|
||||||
|
docker compose -f docker-compose.yml -f docker-compose.build.yml up -d --build
|
||||||
```
|
```
|
||||||
|
|
||||||
El servicio quedará disponible en `http://localhost:3000`.
|
El servicio quedará disponible en `http://localhost:3000`.
|
||||||
|
|
||||||
### Docker (imagen directa)
|
|
||||||
|
|
||||||
```bash
|
|
||||||
docker run -d \
|
|
||||||
--name paste-es \
|
|
||||||
-p 3000:3000 \
|
|
||||||
-v paste-data:/app/database \
|
|
||||||
-v paste-uploads:/app/uploads \
|
|
||||||
-e DATABASE_URL="file:/app/database/paste.db" \
|
|
||||||
-e BETTER_AUTH_SECRET="$(openssl rand -base64 32)" \
|
|
||||||
-e BETTER_AUTH_URL="https://paste.es" \
|
|
||||||
-e HEMMELIG_INSTANCE_NAME="paste.es" \
|
|
||||||
ghcr.io/cloudhost-es/paste.es:latest
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Configuración
|
## Configuración
|
||||||
@@ -106,6 +112,38 @@ npm run dev # Terminal 2 — cliente Vite con HMR
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## CI/CD — Gitea Actions + registro de contenedores
|
||||||
|
|
||||||
|
El repositorio incluye un pipeline en `.gitea/workflows/docker.yml` que:
|
||||||
|
|
||||||
|
1. Se activa en cada push a `main` (o manualmente desde la UI de Gitea)
|
||||||
|
2. Construye la imagen Docker con caché de capas
|
||||||
|
3. La publica en el registro de contenedores de Gitea como `devops.cloudhost.es/malin/paste.es:latest` y `devops.cloudhost.es/malin/paste.es:<sha>`
|
||||||
|
|
||||||
|
### Requisitos previos
|
||||||
|
|
||||||
|
**1. Habilitar Gitea Actions** en el repositorio:
|
||||||
|
> Settings → Actions → Enable repository actions
|
||||||
|
|
||||||
|
**2. Arrancar un act_runner** (ejecutor del pipeline). Obtén el token en:
|
||||||
|
> Settings → Actions → Runners → Create Runner Token
|
||||||
|
|
||||||
|
Añádelo a `.env` y arranca el runner:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# En .env:
|
||||||
|
RUNNER_REGISTRATION_TOKEN=<token>
|
||||||
|
|
||||||
|
docker compose -f docker-compose.runner.yml up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
El runner se registra automáticamente y queda disponible para ejecutar workflows.
|
||||||
|
|
||||||
|
**3. El siguiente push a `main`** disparará la build automáticamente. Puedes seguirla en:
|
||||||
|
> Gitea → Actions → Workflows
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Despliegue en producción
|
## Despliegue en producción
|
||||||
|
|
||||||
### Detrás de un proxy inverso (Nginx / Caddy)
|
### Detrás de un proxy inverso (Nginx / Caddy)
|
||||||
|
|||||||
11
docker-compose.build.yml
Normal file
11
docker-compose.build.yml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# Local build override — use this during development instead of pulling from the registry.
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
# docker compose -f docker-compose.yml -f docker-compose.build.yml up -d --build
|
||||||
|
|
||||||
|
services:
|
||||||
|
paste-es:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
image: devops.cloudhost.es/malin/paste.es:latest
|
||||||
26
docker-compose.runner.yml
Normal file
26
docker-compose.runner.yml
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
# Gitea act_runner — CI/CD executor for Gitea Actions
|
||||||
|
#
|
||||||
|
# Setup steps:
|
||||||
|
# 1. Get a runner registration token from:
|
||||||
|
# https://devops.cloudhost.es/Malin/paste.es/settings/actions/runners
|
||||||
|
# 2. Add it to your .env file:
|
||||||
|
# RUNNER_REGISTRATION_TOKEN=<token from Gitea>
|
||||||
|
# 3. Start the runner:
|
||||||
|
# docker compose -f docker-compose.runner.yml up -d
|
||||||
|
#
|
||||||
|
# The runner registers itself automatically on first start.
|
||||||
|
# After that, push to main and the docker.yml workflow will fire.
|
||||||
|
|
||||||
|
services:
|
||||||
|
act-runner:
|
||||||
|
image: gitea/act_runner:latest
|
||||||
|
container_name: paste-es-act-runner
|
||||||
|
restart: unless-stopped
|
||||||
|
volumes:
|
||||||
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
|
- ./data/runner:/data
|
||||||
|
environment:
|
||||||
|
- GITEA_INSTANCE_URL=https://devops.cloudhost.es
|
||||||
|
- GITEA_RUNNER_REGISTRATION_TOKEN=${RUNNER_REGISTRATION_TOKEN}
|
||||||
|
- GITEA_RUNNER_NAME=paste-es-runner
|
||||||
|
- GITEA_RUNNER_LABELS=ubuntu-latest:docker://node:20-bullseye
|
||||||
@@ -1,8 +1,6 @@
|
|||||||
services:
|
services:
|
||||||
paste-es:
|
paste-es:
|
||||||
build:
|
image: devops.cloudhost.es/malin/paste.es:latest
|
||||||
context: .
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
container_name: paste-es
|
container_name: paste-es
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
env_file:
|
env_file:
|
||||||
|
|||||||
Reference in New Issue
Block a user