Skip to content

Commit

Permalink
Merge pull request #22 from Studio-Yandex-Practicum/feature/deploy_to…
Browse files Browse the repository at this point in the history
…_server

Compose и Workflow для деплоя dev на сервер
  • Loading branch information
Marker-bit authored Aug 17, 2024
2 parents 42ff040 + c099d69 commit 2a8a134
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 12 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Main Workflow

on:
push:
branches:
- dev

jobs:
# test:
# runs-on: ubuntu-24.04

# services:
# postgres:
# image: postgres:16
# env:
# POSTGRES_USER: ${{ secrets.POSTGRES_USER }}
# POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
# POSTGRES_DB: ${{ secrets.POSTGRES_DB }}
# ports:
# - 5432:5432
# options: >-
# --health-cmd "pg_isready -U ${{ secrets.POSTGRES_USER }}"
# --health-interval 10s
# --health-timeout 5s
# --health-retries 5

# adminer:
# image: adminer:4.8.1
# ports:
# - 8080:8080

# steps:
# - name: Checkout code
# uses: actions/checkout@v3

# - name: Set up Python
# uses: actions/setup-python@v4
# with:
# python-version: '3.12'

# - name: Install dependencies
# run: |
# python -m pip install --upgrade pip
# pip install -r requirements.txt

# - name: Run tests
# env:
# DATABASE_URL: postgres://postgres:${{ secrets.POSTGRES_PASSWORD }}@localhost:5432/${{ secrets.POSTGRES_DB }}
# run: |
# pytest

deploy:
runs-on: ubuntu-24.04
# needs: test
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Deploy to server
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USER }}
key: ${{ secrets.SSH_KEY }}
passphrase: ${{ secrets.SSH_PASSPHRASE }}
script: |
cd /Privet_Logoped_team_4/
git pull origin dev
source /Privet_Logoped_team_4/src/telegram_bot/venv/bin/activate
pip install -r src/telegram_bot/requirements.txt
alembic upgrade head
deactivate
source /Privet_Logoped_team_4/src/vk_bot/venv/bin/activate
pip install -r src/vk_bot/requirements.txt
deactivate
sudo systemctl restart docker-compose-db.service
sudo systemctl restart telegram-bot.service
sudo systemctl restart vk-bot.service
35 changes: 23 additions & 12 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,33 @@
version: '3'

services:

db:
image: postgres
restart: always
shm_size: 128mb
volumes:
- db-data:/var/lib/postgresql/data
env_file: .env
postgres:
image: postgres:16
container_name: postgres_db
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
ports:
- "5433:5432"
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
networks:
- db_network

adminer:
image: adminer
restart: always
image: adminer:4.8.1
container_name: adminer
ports:
- "8080:8080"
networks:
- db_network
depends_on:
- postgres

volumes:
db-data:
postgres_data:

networks:
db_network:
driver: bridge

0 comments on commit 2a8a134

Please sign in to comment.