Files
davidaragon-portfolio/CI-CD-SETUP.md
T
wh-leader e9be93f24d
CI/CD Pipeline / Build Astro Site (push) Failing after 1m8s
CI/CD Pipeline / Deploy to Portainer (push) Has been skipped
docs: add CI/CD setup instructions
2026-05-11 09:24:08 +02:00

3.4 KiB

CI/CD Setup Instructions

What's Done

  1. Gitea Actions workflow created (.gitea/workflows/ci-cd.yaml)

    • Build job: Verify Astro build works
    • Deploy job: Build Docker image + push to registry + trigger Portainer
  2. Docker files created:

    • Dockerfile - Multi-stage build (Node + nginx)
    • docker-compose.yml - Local testing
    • nginx.conf - SPA routing + cache headers
    • .dockerignore - Optimize build
  3. Pushed to git - CI will run on next push to main branch


🔧 Manual Steps Required

1. Configure Gitea Secrets

Go to: https://gitlab.impresion3d.pro/root/davidaragon-portfolio/settings/secrets

Add these secrets:

DOCKER_USERNAME

root

DOCKER_PASSWORD

<your Gitea personal access token with registry permissions>

PORTAINER_WEBHOOK_URL

<webhook URL from Portainer stack - see step 2>

2. Create Portainer Stack

  1. Go to Portainer: http://192.168.1.30:9000
  2. Navigate to: StacksAdd stack
  3. Name: davidaragon-portfolio
  4. Build method: Git Repository or Web editor

Stack compose file:

version: '3.8'

services:
  portfolio:
    image: gitlab.impresion3d.pro/root/davidaragon-portfolio:latest
    container_name: davidaragon-portfolio
    ports:
      - "8081:80"
    restart: unless-stopped
    environment:
      - NODE_ENV=production
    networks:
      - web

networks:
  web:
    external: true
  1. Deploy the stack
  2. Go to stack Webhooks tab
  3. Create webhook for service portfolio
  4. Copy webhook URL (format: http://192.168.1.30:9000/api/stacks/webhooks/...)
  5. Add this URL as PORTAINER_WEBHOOK_URL secret in Gitea (step 1)

3. Optional: Configure Gitea Runner

If no runners registered yet:

# On server 192.168.1.30 (port 2222)
docker run -d \
  --name gitea-runner-portfolio \
  --restart unless-stopped \
  -e GITEA_INSTANCE_URL=https://gitlab.impresion3d.pro \
  -e GITEA_RUNNER_REGISTRATION_TOKEN=<your_token> \
  -e GITEA_RUNNER_NAME=ubuntu-latest \
  -v /var/run/docker.sock:/var/run/docker.sock \
  gitea/act_runner:latest

Get registration token from: https://gitlab.impresion3d.pro/admin/actions/runners


🚀 How It Works

On Every Push to Main:

  1. Build job runs:

    • Install Node.js 20
    • Install dependencies (npm ci)
    • Build Astro site (npm run build)
    • Upload dist/ artifact
  2. Deploy job runs (only if build succeeds):

    • Download dist/ artifact
    • Build Docker image (multi-stage)
    • Push to Gitea registry: gitlab.impresion3d.pro/root/davidaragon-portfolio:latest
    • Trigger Portainer webhook → Portainer pulls new image and restarts container

Result:


🧪 Test Locally

cd ~/code_ubuntu/davidaragon-portfolio

# Build and run with Docker Compose
docker-compose up --build

# Visit: http://localhost:8080

📝 Next Steps

  1. Configure secrets in Gitea (step 1)
  2. Create Portainer stack (step 2)
  3. Add webhook URL to Gitea secrets
  4. Push any commit to main → CI/CD runs automatically!

🔍 Monitor CI/CD