Add TeleBot CI/CD pipeline configuration
- Created .gitlab-ci.yml for automated builds and deployment - Added docker-compose.production.yml for VPS deployment - Added .env.production.example for configuration template - Follows LittleShop deployment pattern - Auto-deploy on main branch commits 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
766216e542
commit
fd02836450
21
TeleBot/.env.production.example
Normal file
21
TeleBot/.env.production.example
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# TeleBot Production Environment Variables
|
||||||
|
# Copy this file to /opt/telebot/.env on the VPS and fill in the values
|
||||||
|
|
||||||
|
# Telegram Bot Configuration
|
||||||
|
TELEGRAM_BOT_TOKEN=your_telegram_bot_token_here
|
||||||
|
TELEGRAM_ADMIN_CHAT_ID=your_admin_chat_id_here
|
||||||
|
|
||||||
|
# LittleShop API Configuration
|
||||||
|
LITTLESHOP_API_URL=http://littleshop-admin:8080
|
||||||
|
LITTLESHOP_USERNAME=admin
|
||||||
|
LITTLESHOP_PASSWORD=your_admin_password_here
|
||||||
|
|
||||||
|
# Database Encryption
|
||||||
|
DB_ENCRYPTION_KEY=your_32_character_encryption_key_here
|
||||||
|
|
||||||
|
# Optional: Redis Configuration (if enabled)
|
||||||
|
# REDIS_CONNECTION_STRING=localhost:6379
|
||||||
|
|
||||||
|
# Optional: Tor Configuration (if enabled)
|
||||||
|
# PRIVACY_ENABLE_TOR=false
|
||||||
|
# PRIVACY_TOR_SOCKS_PORT=9050
|
||||||
61
TeleBot/.gitlab-ci.yml
Normal file
61
TeleBot/.gitlab-ci.yml
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
variables:
|
||||||
|
DOCKER_HOST: unix:///var/run/docker.sock
|
||||||
|
|
||||||
|
stages:
|
||||||
|
- build
|
||||||
|
- deploy
|
||||||
|
|
||||||
|
build:
|
||||||
|
stage: build
|
||||||
|
image: docker:24
|
||||||
|
script:
|
||||||
|
- docker build -f TeleBot/Dockerfile -t localhost:5000/telebot:latest ../
|
||||||
|
- docker tag localhost:5000/telebot:latest localhost:5000/telebot:$CI_COMMIT_SHORT_SHA
|
||||||
|
- docker push localhost:5000/telebot:latest
|
||||||
|
- docker push localhost:5000/telebot:$CI_COMMIT_SHORT_SHA
|
||||||
|
rules:
|
||||||
|
- if: '$CI_COMMIT_BRANCH == "main"'
|
||||||
|
- if: '$CI_COMMIT_TAG'
|
||||||
|
|
||||||
|
deploy:vps:
|
||||||
|
stage: deploy
|
||||||
|
image: docker:24
|
||||||
|
before_script:
|
||||||
|
- apk add --no-cache openssh-client bash curl
|
||||||
|
- mkdir -p ~/.ssh
|
||||||
|
- chmod 700 ~/.ssh
|
||||||
|
- echo "$VPS_SSH_KEY_B64" | base64 -d > /tmp/deploy_key
|
||||||
|
- chmod 600 /tmp/deploy_key
|
||||||
|
- ssh-keyscan -p "$VPS_PORT" "$VPS_HOST" >> ~/.ssh/known_hosts 2>/dev/null
|
||||||
|
script:
|
||||||
|
- |
|
||||||
|
# Save and transfer Docker image
|
||||||
|
docker save localhost:5000/telebot:latest | ssh -i /tmp/deploy_key -p "$VPS_PORT" "$VPS_USER@$VPS_HOST" "docker load"
|
||||||
|
|
||||||
|
# Deploy on VPS
|
||||||
|
ssh -i /tmp/deploy_key -p "$VPS_PORT" "$VPS_USER@$VPS_HOST" bash -s << 'EOF'
|
||||||
|
cd /opt/telebot
|
||||||
|
docker-compose down
|
||||||
|
docker-compose up -d
|
||||||
|
|
||||||
|
# Health check
|
||||||
|
for i in 1 2 3 4 5 6; do
|
||||||
|
if pgrep -f "dotnet.*TeleBot" > /dev/null 2>&1; then
|
||||||
|
echo "✅ TeleBot deployment successful"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
echo "Waiting for TeleBot to start... ($i/6)"
|
||||||
|
sleep 10
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "❌ TeleBot deployment failed - health check timeout"
|
||||||
|
docker-compose logs --tail=50
|
||||||
|
exit 1
|
||||||
|
EOF
|
||||||
|
rules:
|
||||||
|
- if: '$CI_COMMIT_BRANCH == "main"'
|
||||||
|
when: on_success
|
||||||
|
- if: '$CI_COMMIT_TAG'
|
||||||
|
when: manual
|
||||||
|
after_script:
|
||||||
|
- rm -f /tmp/deploy_key
|
||||||
43
TeleBot/docker-compose.production.yml
Normal file
43
TeleBot/docker-compose.production.yml
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
version: '3.8'
|
||||||
|
|
||||||
|
services:
|
||||||
|
telebot:
|
||||||
|
image: localhost:5000/telebot:latest
|
||||||
|
container_name: telebot
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
- ASPNETCORE_ENVIRONMENT=Production
|
||||||
|
- Telegram__BotToken=${TELEGRAM_BOT_TOKEN}
|
||||||
|
- Telegram__AdminChatId=${TELEGRAM_ADMIN_CHAT_ID}
|
||||||
|
- Telegram__UseWebhook=false
|
||||||
|
- LittleShop__ApiUrl=${LITTLESHOP_API_URL}
|
||||||
|
- LittleShop__Username=${LITTLESHOP_USERNAME}
|
||||||
|
- LittleShop__Password=${LITTLESHOP_PASSWORD}
|
||||||
|
- Database__EncryptionKey=${DB_ENCRYPTION_KEY}
|
||||||
|
- Logging__LogLevel__Default=Information
|
||||||
|
- Logging__LogLevel__Microsoft=Warning
|
||||||
|
volumes:
|
||||||
|
- ./logs:/app/logs
|
||||||
|
- ./data:/app/data
|
||||||
|
- ./image_cache:/app/image_cache
|
||||||
|
networks:
|
||||||
|
- telebot-network
|
||||||
|
- littleshop_littleshop-network
|
||||||
|
depends_on:
|
||||||
|
- littleshop-admin
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "pgrep", "-f", "dotnet.*TeleBot"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 3
|
||||||
|
start_period: 60s
|
||||||
|
|
||||||
|
networks:
|
||||||
|
telebot-network:
|
||||||
|
driver: bridge
|
||||||
|
ipam:
|
||||||
|
config:
|
||||||
|
- subnet: 172.24.0.0/16
|
||||||
|
|
||||||
|
littleshop_littleshop-network:
|
||||||
|
external: true
|
||||||
Loading…
Reference in New Issue
Block a user