From fc3adb1efca805e19d35e0ea7f9a6774a560ed83 Mon Sep 17 00:00:00 2001 From: Fl1riX Date: Sat, 23 May 2026 11:28:26 +0300 Subject: [PATCH 1/3] feat(ci): Add Docker image building and pushing to the ghcr registry --- .github/workflows/ci.yml | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 49fa34b..32a6620 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,39 @@ 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 + - + 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 \ No newline at end of file From ccb6ceeb6e3eff11308052d8097aa1e2eb7ed821 Mon Sep 17 00:00:00 2001 From: Fl1riX Date: Sat, 23 May 2026 11:50:18 +0300 Subject: [PATCH 2/3] feat(docker-compose): Add watchtower to query the registry and download dcoker images from there. --- docker-compose.yml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) 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 From 5fc98fc96a267976f8a8dfbe87b6212e652a4b08 Mon Sep 17 00:00:00 2001 From: Fl1riX Date: Sat, 23 May 2026 11:57:28 +0300 Subject: [PATCH 3/3] feat(ci): Add a commit hash tag to Docker images --- .github/workflows/ci.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 32a6620..f571e75 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -107,7 +107,9 @@ jobs: # Задачи context: . file: Dockerfile.api push: true - tags: ghcr.io/fl1rix/steeltime-api:latest + 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 @@ -115,4 +117,6 @@ jobs: # Задачи context: . file: Dockerfile.bot push: true - tags: ghcr.io/fl1rix/steeltime-bot:latest \ No newline at end of file + tags: | + ghcr.io/fl1rix/steeltime-bot:latest + ghcr.io/fl1rix/steeltime-bot:${{ github.sha }} \ No newline at end of file