From 6eb664a608ed67430470061f051cc6f6b25c094a Mon Sep 17 00:00:00 2001 From: Giuseppe Marino Date: Fri, 6 Nov 2020 01:42:25 +0100 Subject: [PATCH] github actions attempt --- .github/workflows/docker.yml | 52 ++++++++++++++++++++++++++++++++++++ Dockerfile | 26 ++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 .github/workflows/docker.yml create mode 100644 Dockerfile diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..95a8520 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,52 @@ +name: Docker Build + Image Push + +on: + push: + branches: + - master + pull_request: + + +jobs: + build: + name: Build Image + runs-on: ubuntu-latest + env: + IMAGE_id: docker.pkg.github.com/${{ github.repository }}/${{ github.repository }} + + steps: + - name: Checkout current repo + uses: actions/checkout@v2 + with: + submodules: true + + - name: Get Version + run: | + # get telegram bot api version + telegram_bot_api_version=$(git rev-parse --short HEAD) + + # get tdlib version + tdlib_version=$(cd td && git rev-parse --short HEAD) + + # concat tdlib and telegram bot api version + version=$telegram_bot_api_version-$tdlib_version + + # store variable for future use + echo "version=$version" >> $GITHUB_ENV + + - name: Build image + run: | + IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/${{ github.repository }} + docker build \ + --tag tdlight-team/tdlight-telegram-bot-api:latest \ + --tag tdlight-team/tdlight-telegram-bot-api:$version \ + . + + - name: Login to registry + run: | + echo "${{ secrets.GITHUB_ACCESS_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin + + + - name: Push images + run: | + docker push $IMAGE_ID:$version diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d3db905 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +FROM alpine:3.12.1 as builder + +RUN apk --no-cache add \ + build-base \ + cmake \ + openssl-dev \ + zlib-dev \ + gperf \ + linux-headers + +COPY . /src + +WORKDIR /src/build + +RUN cmake -DCMAKE_BUILD_TYPE=Release .. +RUN cmake --build . --target install -- + +FROM alpine:3.12.1 + +RUN apk --no-cache add libstdc++ + +COPY --from=builder /usr/local/bin/telegram-bot-api /usr/local/bin/telegram-bot-api + +HEALTHCHECK CMD curl -f http://localhost:8082/ || exit 1 + +ENTRYPOINT ["/usr/local/bin/telegram-bot-api -s 8082"]