Merge pull request #1 from tdlight-team/docker

Add dockerfile and github actions script
This commit is contained in:
Andrea Cavalli 2020-11-06 11:42:03 +01:00 committed by GitHub
commit fe3d95fcac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 78 additions and 0 deletions

52
.github/workflows/docker.yml vendored Normal file
View File

@ -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

26
Dockerfile Normal file
View File

@ -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"]