Add CI/CD pipeline (Forgejo) and prod docker-compose
Some checks failed
CI/CD Pipeline / build-and-deploy (push) Failing after 28s
Some checks failed
CI/CD Pipeline / build-and-deploy (push) Failing after 28s
This commit is contained in:
parent
d21f4d696d
commit
780e776294
2 changed files with 73 additions and 0 deletions
47
.forgejo/workflows/deploy.yml
Normal file
47
.forgejo/workflows/deploy.yml
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
name: CI/CD Pipeline
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
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 image
|
||||||
|
run: docker build -t 192.168.8.174:3000/vrubel/chess-calc:latest .
|
||||||
|
|
||||||
|
- name: Test containers
|
||||||
|
run: |
|
||||||
|
docker compose up -d
|
||||||
|
sleep 5
|
||||||
|
docker compose logs --tail=20
|
||||||
|
|
||||||
|
- name: Stop containers
|
||||||
|
run: docker compose down
|
||||||
|
|
||||||
|
- 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 image to registry
|
||||||
|
run: docker push 192.168.8.174:3000/vrubel/chess-calc:latest
|
||||||
|
|
||||||
|
- name: Copy docker-compose to prod host
|
||||||
|
run: scp -i /data/.ssh/id_ed25519 -o StrictHostKeyChecking=no docker-compose.prod.yml vrubel@192.168.8.171:~/services/ChessCalcNextTour/docker-compose.yml
|
||||||
|
|
||||||
|
- name: Deploy on prod host
|
||||||
|
run: ssh -i /data/.ssh/id_ed25519 -o StrictHostKeyChecking=no vrubel@192.168.8.171 "cd ~/services/ChessCalcNextTour && docker pull 192.168.8.174:3000/vrubel/chess-calc:latest && docker compose up -d --remove-orphans"
|
||||||
26
docker-compose.prod.yml
Normal file
26
docker-compose.prod.yml
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
---
|
||||||
|
services:
|
||||||
|
client-bot:
|
||||||
|
image: 192.168.8.174:3000/vrubel/chess-calc:latest
|
||||||
|
container_name: chess-calc-client-bot
|
||||||
|
restart: unless-stopped
|
||||||
|
env_file: .env
|
||||||
|
environment:
|
||||||
|
- STATS_DB=/app/data/tournaments.db
|
||||||
|
volumes:
|
||||||
|
- bot-data:/app/data
|
||||||
|
command: ["python3", "-m", "bots.client_bot"]
|
||||||
|
|
||||||
|
admin-bot:
|
||||||
|
image: 192.168.8.174:3000/vrubel/chess-calc:latest
|
||||||
|
container_name: chess-calc-admin-bot
|
||||||
|
restart: unless-stopped
|
||||||
|
env_file: .env
|
||||||
|
environment:
|
||||||
|
- STATS_DB=/app/data/tournaments.db
|
||||||
|
volumes:
|
||||||
|
- bot-data:/app/data
|
||||||
|
command: ["python3", "-m", "bots.admin_bot"]
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
bot-data:
|
||||||
Loading…
Add table
Add a link
Reference in a new issue