Add CI/CD pipeline and production docker-compose
Some checks failed
Build and Deploy MikroTik Bot / build-and-deploy (push) Has been cancelled

This commit is contained in:
stakost 2025-06-01 11:53:40 +03:00
parent 521bb90611
commit 2b813f229c
2 changed files with 57 additions and 30 deletions

View File

@ -0,0 +1,38 @@
name: Build and Deploy MikroTik Bot
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Registry
uses: docker/login-action@v2
with:
registry: 10.10.30.121:5000
username: admin
password: admin
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: true
tags: 10.10.30.121:5000/mikrotik-bot:latest
- name: Deploy to production
run: |
# Здесь будет команда для обновления контейнера в production
echo "Deployment step - will be configured with Portainer API"

View File

@ -1,34 +1,23 @@
version: '3.8' version: '3.8'
services: services:
telegram-bot: mikrotik-bot:
build: . image: 10.10.30.121:5000/mikrotik-bot:latest
container_name: mikrotik-telegram-bot container_name: mikrotik-bot
env_file:
- .env
restart: unless-stopped restart: unless-stopped
environment:
- BOT_TOKEN=your_bot_token_here
- ROUTER_HOST=your_router_ip_here
- ROUTER_USER=your_router_user_here
- ROUTER_PASSWORD=your_router_password_here
- DATABASE_PATH=/app/data/bot.db
volumes: volumes:
- ./data:/app/data # Сохранение данных бота (например, SQLite база) - ./data:/app/data
healthcheck: ports:
# Используем curl, который установлен в Dockerfile - "8000:8000" # FastAPI health endpoint
test: ["CMD", "curl", "-f", "http://localhost:8080/health"] networks:
interval: 30s - bot-network
timeout: 10s
retries: 3
start_period: 5s # Даем время на запуск
# Если боту нужно общаться с роутером по IP в локальной сети:
# network_mode: "host"
# Или настройте пользовательскую bridge-сеть Docker, если требуется
# networks:
# - my_local_network
# Пример определения пользовательской сети (если не используется host) networks:
# networks: bot-network:
# my_local_network: driver: bridge
# driver: bridge
# ipam:
# config:
# - subnet: 172.20.0.0/16 # Пример подсети
# Если нужно пробросить прокси/порт, добавь:
# ports:
# - "8080:8080"