Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: build

on:
pull_request:

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
service: [api, bot, nginx]
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Build ${{ matrix.service }} image
uses: docker/build-push-action@v6
with:
context: ./server/${{ matrix.service }}
push: false
88 changes: 88 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: deploy

on:
push:
branches: [main]

jobs:
to-docker-hub:
runs-on: ubuntu-latest
strategy:
matrix:
instance: [api, nginx, bot]
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Login to Docker Hub
uses: docker/login-action@v4
with:
username: grachevnr
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Build and push
uses: docker/build-push-action@v7
with:
context: "server/${{ matrix.instance }}"
push: true
tags: "grachevnr/eat_log_${{ matrix.instance }}:latest"

to-server:
needs: to-docker-hub
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Poweroff old services
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
password: ${{ secrets.SERVER_PASSWORD }}
script: |
mkdir -p ~/eatlog
cd ~/eatlog
docker compose down || true
- name: Copy docker-compose to server
uses: appleboy/scp-action@v1
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
password: ${{ secrets.SERVER_PASSWORD }}
source: "./server/docker-compose.yaml"
target: "~/eatlog/"
strip_components: 1
- name: Create .env on server
uses: appleboy/ssh-action@v1
env:
DB_HOST: ${{ secrets.DB_HOST }}
DB_PORT: ${{ secrets.DB_PORT }}
DB_NAME: ${{ secrets.DB_NAME }}
DB_USER: ${{ secrets.DB_USER }}
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
password: ${{ secrets.SERVER_PASSWORD }}
envs: DB_HOST,DB_PORT,DB_NAME,DB_USER,DB_PASSWORD,BOT_TOKEN
script: |
cat > ~/eatlog/.env <<EOF
DB_HOST=${DB_HOST}
DB_PORT=${DB_PORT}
DB_NAME=${DB_NAME}
DB_USER=${DB_USER}
DB_PASSWORD=${DB_PASSWORD}
BOT_TOKEN=${BOT_TOKEN}
EOF
- name: Pull and restart services
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
password: ${{ secrets.SERVER_PASSWORD }}
script: |
cd ~/eatlog
docker compose pull
docker compose up -d
docker image prune -f
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: ci
name: lint

on:
pull_request:
Expand Down
3 changes: 0 additions & 3 deletions README.MD
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
Привязка тг бота
Настройка уведомлений

Обновить логику обновления Meal. Обновлять может только тот, кто его создал если другой хочет обновить, он может написать заявку на обновление она придет к пользователю кто создал это обновление с кнопками Одобрить Отклонить. При Одобрении обновление в БД. finally ответ отправляем тому, кто создал заявку.

Поддержка HTTPS


4 changes: 4 additions & 0 deletions server/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
docker-compose.dev.yaml
__pycache__/
.venv/
.ruff_cache/
.mypy_cache/
7 changes: 0 additions & 7 deletions server/api/.env.example

This file was deleted.

5 changes: 0 additions & 5 deletions server/api/.gitignore

This file was deleted.

2 changes: 0 additions & 2 deletions server/api/src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,3 @@
DATABASE_URL = (
f"postgresql+asyncpg://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{DB_PORT}/{DB_NAME}"
)

BOT_TOKEN = os.getenv("BOT_TOKEN", "")
1 change: 0 additions & 1 deletion server/bot/.env.example

This file was deleted.

5 changes: 0 additions & 5 deletions server/bot/.gitignore

This file was deleted.

28 changes: 23 additions & 5 deletions server/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
services:
api:
build: ./api/
env_file: ./api/.env
image: grachevnr/eat_log_api:latest
environment:
DB_HOST: ${DB_HOST}
DB_PORT: ${DB_PORT}
DB_NAME: ${DB_NAME}
DB_USER: ${DB_USER}
DB_PASSWORD: ${DB_PASSWORD}
healthcheck:
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:5285/health')"]
interval: 5s
Expand All @@ -10,17 +15,30 @@ services:
start_period: 5s

bot:
build: ./bot/
env_file: ./bot/.env
image: grachevnr/eat_log_bot:latest
environment:
BOT_TOKEN: ${BOT_TOKEN}
depends_on:
api:
condition: service_healthy
healthcheck:
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://api:5285/health')"]
interval: 5s
timeout: 5s
retries: 5
start_period: 5s

nginx:
build: ./nginx/
image: grachevnr/eat_log_nginx:latest
ports:
- "80:80"
- "443:443"
depends_on:
api:
condition: service_healthy
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost/healthz"]
interval: 5s
timeout: 5s
retries: 5
start_period: 5s
6 changes: 6 additions & 0 deletions server/nginx/default.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
server {
listen 80;
listen [::]:80;
server_name api.eat-log.ru;

location = /healthz {
access_log off;
return 200 "ok\n";
}

location / {
proxy_pass http://api:5285;
}
Expand Down
Loading