- 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>
61 lines
1.7 KiB
YAML
61 lines
1.7 KiB
YAML
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 |