ci: add Forgejo CI/CD pipeline with docker save/load deploy to prod
All checks were successful
CI/CD Pipeline / build-and-deploy (push) Successful in 1m24s
All checks were successful
CI/CD Pipeline / build-and-deploy (push) Successful in 1m24s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
8828375207
commit
1fe8deb0de
3 changed files with 122 additions and 0 deletions
52
.forgejo/workflows/deploy.yml
Normal file
52
.forgejo/workflows/deploy.yml
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
name: CI/CD Pipeline
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-deploy:
|
||||||
|
runs-on: shell
|
||||||
|
steps:
|
||||||
|
- name: Clone repository
|
||||||
|
run: git clone --depth 1 "http://192.168.8.174:3000/${GITHUB_REPOSITORY}.git" .
|
||||||
|
env:
|
||||||
|
GIT_TERMINAL_PROMPT: '0'
|
||||||
|
|
||||||
|
- name: Ensure Docker CLI
|
||||||
|
run: |
|
||||||
|
apk add --no-cache docker-cli docker-cli-compose openssh-client || true
|
||||||
|
grep -q '^vrubel:' /etc/passwd || echo 'vrubel:x:1000:1000::/data:/bin/sh' >> /etc/passwd
|
||||||
|
|
||||||
|
- name: Setup .env for CI/CD
|
||||||
|
run: cp .env.example .env
|
||||||
|
|
||||||
|
- name: Build Docker images
|
||||||
|
run: docker-compose build
|
||||||
|
|
||||||
|
- name: Login to Gitea Container Registry
|
||||||
|
run: echo "${{ secrets.REGISTRY_TOKEN }}" | docker login http://192.168.8.174:3000 -u "${{ secrets.REGISTRY_USER }}" --password-stdin
|
||||||
|
|
||||||
|
- name: Push images to registry
|
||||||
|
run: |
|
||||||
|
docker push 192.168.8.174:3000/vrubel/lichess-api:latest
|
||||||
|
docker push 192.168.8.174:3000/vrubel/lichess-bot:latest
|
||||||
|
docker push 192.168.8.174:3000/vrubel/lichess-admin:latest
|
||||||
|
docker push 192.168.8.174:3000/vrubel/lichess-web:latest
|
||||||
|
|
||||||
|
- name: Transfer images to prod
|
||||||
|
run: |
|
||||||
|
docker save \
|
||||||
|
192.168.8.174:3000/vrubel/lichess-api:latest \
|
||||||
|
192.168.8.174:3000/vrubel/lichess-bot:latest \
|
||||||
|
192.168.8.174:3000/vrubel/lichess-admin:latest \
|
||||||
|
192.168.8.174:3000/vrubel/lichess-web:latest \
|
||||||
|
| ssh -i /data/.ssh/id_ed25519 -o StrictHostKeyChecking=no root@130.17.6.76 docker load
|
||||||
|
|
||||||
|
- name: Deploy on prod host
|
||||||
|
run: |
|
||||||
|
cat docker-compose.prod.yml | ssh -i /data/.ssh/id_ed25519 -o StrictHostKeyChecking=no root@130.17.6.76 \
|
||||||
|
"cat > ~/services/LichessStatTgWeb/docker-compose.yml"
|
||||||
|
ssh -i /data/.ssh/id_ed25519 -o StrictHostKeyChecking=no root@130.17.6.76 \
|
||||||
|
"cd ~/services/LichessStatTgWeb && docker compose up -d --remove-orphans"
|
||||||
66
docker-compose.prod.yml
Normal file
66
docker-compose.prod.yml
Normal file
|
|
@ -0,0 +1,66 @@
|
||||||
|
services:
|
||||||
|
lichess-api:
|
||||||
|
image: 192.168.8.174:3000/vrubel/lichess-api:latest
|
||||||
|
container_name: lichess-api
|
||||||
|
ports:
|
||||||
|
- "8002:8000"
|
||||||
|
environment:
|
||||||
|
- PYTHONUNBUFFERED=1
|
||||||
|
restart: always
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8000/health').read()"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 3
|
||||||
|
start_period: 40s
|
||||||
|
|
||||||
|
lichess-bot:
|
||||||
|
image: 192.168.8.174:3000/vrubel/lichess-bot:latest
|
||||||
|
container_name: lichess-telegram-bot
|
||||||
|
volumes:
|
||||||
|
- ./data:/app/data
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
environment:
|
||||||
|
- PYTHONPATH=/app
|
||||||
|
- PYTHONUNBUFFERED=1
|
||||||
|
network_mode: "host"
|
||||||
|
restart: always
|
||||||
|
depends_on:
|
||||||
|
- lichess-api
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "python", "-c", "import requests; requests.get('http://localhost:8002/health', timeout=5)"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 3
|
||||||
|
start_period: 40s
|
||||||
|
|
||||||
|
admin-bot:
|
||||||
|
image: 192.168.8.174:3000/vrubel/lichess-admin:latest
|
||||||
|
container_name: lichess-admin-bot
|
||||||
|
volumes:
|
||||||
|
- ./data:/app/data
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
environment:
|
||||||
|
- PYTHONPATH=/app
|
||||||
|
- PYTHONUNBUFFERED=1
|
||||||
|
network_mode: "host"
|
||||||
|
restart: always
|
||||||
|
depends_on:
|
||||||
|
- lichess-api
|
||||||
|
|
||||||
|
web-view:
|
||||||
|
image: 192.168.8.174:3000/vrubel/lichess-web:latest
|
||||||
|
container_name: lichess-web-view
|
||||||
|
ports:
|
||||||
|
- "5000:5000"
|
||||||
|
volumes:
|
||||||
|
- ./data:/app/data:ro
|
||||||
|
restart: always
|
||||||
|
depends_on:
|
||||||
|
- lichess-bot
|
||||||
|
|
||||||
|
networks:
|
||||||
|
default:
|
||||||
|
name: lichess-network
|
||||||
|
|
@ -2,6 +2,7 @@ services:
|
||||||
# Lichess Web Services (API)
|
# Lichess Web Services (API)
|
||||||
lichess-api:
|
lichess-api:
|
||||||
build: ./LichessWebServices
|
build: ./LichessWebServices
|
||||||
|
image: 192.168.8.174:3000/vrubel/lichess-api:latest
|
||||||
container_name: lichess-api
|
container_name: lichess-api
|
||||||
ports:
|
ports:
|
||||||
- "8002:8000"
|
- "8002:8000"
|
||||||
|
|
@ -20,6 +21,7 @@ services:
|
||||||
# Telegram Bot
|
# Telegram Bot
|
||||||
lichess-bot:
|
lichess-bot:
|
||||||
build: ./LichessClientTG_bot
|
build: ./LichessClientTG_bot
|
||||||
|
image: 192.168.8.174:3000/vrubel/lichess-bot:latest
|
||||||
container_name: lichess-telegram-bot
|
container_name: lichess-telegram-bot
|
||||||
volumes:
|
volumes:
|
||||||
- ./LichessClientTG_bot/data:/app/data
|
- ./LichessClientTG_bot/data:/app/data
|
||||||
|
|
@ -45,6 +47,7 @@ services:
|
||||||
build:
|
build:
|
||||||
context: ./LichessClientTG_bot
|
context: ./LichessClientTG_bot
|
||||||
dockerfile: Dockerfile.admin
|
dockerfile: Dockerfile.admin
|
||||||
|
image: 192.168.8.174:3000/vrubel/lichess-admin:latest
|
||||||
container_name: lichess-admin-bot
|
container_name: lichess-admin-bot
|
||||||
volumes:
|
volumes:
|
||||||
- ./LichessClientTG_bot/data:/app/data
|
- ./LichessClientTG_bot/data:/app/data
|
||||||
|
|
@ -62,6 +65,7 @@ services:
|
||||||
# Web View Interface
|
# Web View Interface
|
||||||
web-view:
|
web-view:
|
||||||
build: ./LichessWebView
|
build: ./LichessWebView
|
||||||
|
image: 192.168.8.174:3000/vrubel/lichess-web:latest
|
||||||
container_name: lichess-web-view
|
container_name: lichess-web-view
|
||||||
ports:
|
ports:
|
||||||
- "5000:5000"
|
- "5000:5000"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue