From 521152497513c58870a32c029e4651b4a5650ce4 Mon Sep 17 00:00:00 2001 From: DivByZero Date: Sun, 31 Aug 2025 13:52:59 +0400 Subject: [PATCH 1/2] Set up multi-stage Docker build for application --- Dockerfile | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..bff3d8325 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM ubuntu as BUILD + +WORKDIR /app + +COPY . . + +RUN apt update && apt install libssl-dev gperf git build-essential cmake zlib1g-dev ccache git -y +RUN git submodule update --init --recursive +RUN mkdir build +RUN cd build && cmake -DCMAKE_BUILD_TYPE=Release .. && cmake --build . --target install + +FROM ubuntu as DIST +WORKDIR /app +COPY --from=BUILD /app/build/telegram-bot-api api +RUN chmod +x api +CMD ["./api"] From 9215bfd53c755a1bbd5e35b0961521dfe35b93b9 Mon Sep 17 00:00:00 2001 From: DivByZero Date: Sun, 31 Aug 2025 13:55:32 +0400 Subject: [PATCH 2/2] Create docker-image.yml --- .github/workflows/docker-image.yml | 56 ++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 .github/workflows/docker-image.yml diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 000000000..92e65ec6f --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,56 @@ +name: Create and publish a Docker image + +on: + release: + types: [published] + push: + branches: + - master + workflow_dispatch: + + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + ${{ github.event_name == 'release' && github.event.release.tag_name == 'latest' && 'latest' || '' }} + ${{ github.sha }} + type=ref,event=branch + type=pep440,pattern={{version}} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and push Docker image + uses: docker/build-push-action@v6 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max