diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 49fa34b..f571e75 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,7 +2,7 @@ name: CI # Название, которое будет отображаться on: # События. Запускаются при пуше в main или develop, или при создании pull request в main push: - branches: [main, develop] + branches: [ main ] pull_request: branches: [ main ] @@ -80,3 +80,43 @@ jobs: # Задачи with: github-token: ${{ secrets.GITHUB_TOKEN }} path-to-lcov: ./coverage.xml + + build-and-push: # Собираем образ проекта и пушим а реестр + runs-on: ubuntu-latest + needs: tests + # ограничиваем запуск только на push в main + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + steps: + - + uses: actions/checkout@v4 # Скачивает код из репы на виртуалку. + - + name: Login to GitHub Container Registry + uses: docker/login-action@v4 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - + name: Set up Docker Build + + uses: docker/setup-buildx-action@v4 + - + name: Build and Push API + uses: docker/build-push-action@v7 + with: + context: . + file: Dockerfile.api + push: true + tags: | + ghcr.io/fl1rix/steeltime-api:latest + ghcr.io/fl1rix/steeltime-api:${{ github.sha }} + - + name: Build and Push Bot + uses: docker/build-push-action@v7 + with: + context: . + file: Dockerfile.bot + push: true + tags: | + ghcr.io/fl1rix/steeltime-bot:latest + ghcr.io/fl1rix/steeltime-bot:${{ github.sha }} \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index cb6a669..43d9469 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,11 +18,7 @@ services: mem_reservation: 256m api: - build: - context: . - dockerfile: Dockerfile.api - args: # Кэш для быстрой сборки - - BUILDKIT_INLINE_CACHE=1 + image: ghcr.io/fl1rix/steeltime-api:latest ports: - "8000:8000" # Формат: порт на пк: порт в контейнере env_file: @@ -42,11 +38,7 @@ services: bot: - build: - context: . - dockerfile: Dockerfile.bot - args: # Кэш для быстрой сборки - - BUILDKIT_INLINE_CACHE=1 + image: ghcr.io/fl1rix/steeltime-bot:latest restart: unless-stopped env_file: - .env @@ -58,6 +50,12 @@ services: mem_limit: 256m cpus: 0.25 + watchtower: + image: containrrr/watchtower + volumes: + - /var/run/docker.sock:/var/run/docker.sock + command: --interval 300 + volumes: postgres_data: driver: local