3.4 KiB
3.4 KiB
CI/CD Setup Instructions
✅ What's Done
-
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
-
Docker files created:
Dockerfile- Multi-stage build (Node + nginx)docker-compose.yml- Local testingnginx.conf- SPA routing + cache headers.dockerignore- Optimize build
-
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
- Go to Portainer: http://192.168.1.30:9000
- Navigate to: Stacks → Add stack
- Name:
davidaragon-portfolio - 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
- Deploy the stack
- Go to stack Webhooks tab
- Create webhook for service
portfolio - Copy webhook URL (format:
http://192.168.1.30:9000/api/stacks/webhooks/...) - Add this URL as
PORTAINER_WEBHOOK_URLsecret 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:
-
Build job runs:
- Install Node.js 20
- Install dependencies (
npm ci) - Build Astro site (
npm run build) - Upload
dist/artifact
-
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
- Download
Result:
- Site auto-deployed to http://192.168.1.30:8081
- No manual intervention needed after initial setup
🧪 Test Locally
cd ~/code_ubuntu/davidaragon-portfolio
# Build and run with Docker Compose
docker-compose up --build
# Visit: http://localhost:8080
📝 Next Steps
- Configure secrets in Gitea (step 1)
- Create Portainer stack (step 2)
- Add webhook URL to Gitea secrets
- Push any commit to main → CI/CD runs automatically!