mirror of
https://github.com/lukaszraczylo/tdlib-telegram-bot-api-docker.git
synced 2026-06-11 23:09:13 +00:00
Improve build process.
This commit is contained in:
@@ -6,7 +6,12 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
name: Build amd64 and arm64 images
|
strategy:
|
||||||
|
matrix:
|
||||||
|
platform:
|
||||||
|
- linux/amd64
|
||||||
|
- linux/arm64
|
||||||
|
name: Build ${{ matrix.platform }} image
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout API repo
|
- name: Checkout API repo
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
@@ -48,13 +53,16 @@ jobs:
|
|||||||
if [ "${{ github.event_name }}" = "schedule" ]; then
|
if [ "${{ github.event_name }}" = "schedule" ]; then
|
||||||
VERSION=nightly
|
VERSION=nightly
|
||||||
fi
|
fi
|
||||||
TAGS="${DOCKER_IMAGE}:${VERSION}"
|
# Platform-specific tag for this build job
|
||||||
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
|
PLATFORM_TAG=$(echo ${{ matrix.platform }} | sed 's/\//-/g')
|
||||||
TAGS="$TAGS,${DOCKER_IMAGE}:latest"
|
TAGS="${DOCKER_IMAGE}:${VERSION}-${PLATFORM_TAG}"
|
||||||
fi
|
TAGS="$TAGS,${DOCKER_IMAGE}:${{ env.GITHUB_SHA }}-${PLATFORM_TAG}"
|
||||||
|
|
||||||
TG_API_VERSION=$(grep "project(TelegramBotApi" /home/runner/work/tdlib-telegram-bot-api-docker/tdlib-telegram-bot-api-docker/tdlib-telegram-bot-api/CMakeLists.txt | awk '{print $3}')
|
TG_API_VERSION=$(grep "project(TelegramBotApi" /home/runner/work/tdlib-telegram-bot-api-docker/tdlib-telegram-bot-api-docker/tdlib-telegram-bot-api/CMakeLists.txt | awk '{print $3}')
|
||||||
TAGS="$TAGS,$DOCKER_IMAGE:${{ env.GITHUB_SHA }},$DOCKER_IMAGE:1.0.${{ env.GITHUB_RUN_ID }},$DOCKER_IMAGE:latest,$DOCKER_IMAGE:api-$TG_API_VERSION"
|
|
||||||
echo ::set-output name=tags::${TAGS}
|
echo ::set-output name=tags::${TAGS}
|
||||||
|
echo ::set-output name=version::${VERSION}
|
||||||
|
echo ::set-output name=tg_api_version::${TG_API_VERSION}
|
||||||
|
echo ::set-output name=image::${DOCKER_IMAGE}
|
||||||
# lowercase the branch name
|
# lowercase the branch name
|
||||||
BRANCH=$(echo ${GITHUB_REF##*/} | tr '[A-Z]' '[a-z]')
|
BRANCH=$(echo ${GITHUB_REF##*/} | tr '[A-Z]' '[a-z]')
|
||||||
LABELS="org.opencontainers.image.revision=$GITHUB_SHA"
|
LABELS="org.opencontainers.image.revision=$GITHUB_SHA"
|
||||||
@@ -69,16 +77,67 @@ jobs:
|
|||||||
run: echo ${{ steps.prep.outputs.tags }}
|
run: echo ${{ steps.prep.outputs.tags }}
|
||||||
- name: Build and push
|
- name: Build and push
|
||||||
id: docker_build
|
id: docker_build
|
||||||
timeout-minutes: 900
|
timeout-minutes: 350
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v2
|
||||||
with:
|
with:
|
||||||
builder: ${{ steps.buildx.outputs.name }}
|
builder: ${{ steps.buildx.outputs.name }}
|
||||||
context: /home/runner/work/tdlib-telegram-bot-api-docker/tdlib-telegram-bot-api-docker/tdlib-telegram-bot-api
|
context: /home/runner/work/tdlib-telegram-bot-api-docker/tdlib-telegram-bot-api-docker/tdlib-telegram-bot-api
|
||||||
file: /home/runner/work/tdlib-telegram-bot-api-docker/tdlib-telegram-bot-api-docker/tdlib-telegram-bot-api/Dockerfile
|
file: /home/runner/work/tdlib-telegram-bot-api-docker/tdlib-telegram-bot-api-docker/tdlib-telegram-bot-api/Dockerfile
|
||||||
platforms: linux/arm64,linux/amd64
|
platforms: ${{ matrix.platform }}
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
tags: ${{ steps.prep.outputs.tags }}
|
tags: ${{ steps.prep.outputs.tags }}
|
||||||
build-args: ${{ steps.prep.outputs.args }}
|
build-args: ${{ steps.prep.outputs.args }}
|
||||||
labels: ${{ steps.prep.outputs.labels }}
|
labels: ${{ steps.prep.outputs.labels }}
|
||||||
cache-from: type=gha
|
cache-from: type=gha,scope=${{ matrix.platform }}
|
||||||
cache-to: type=gha,mode=max
|
cache-to: type=gha,mode=max,scope=${{ matrix.platform }}
|
||||||
|
outputs:
|
||||||
|
version: ${{ steps.prep.outputs.version }}
|
||||||
|
tg_api_version: ${{ steps.prep.outputs.tg_api_version }}
|
||||||
|
image: ${{ steps.prep.outputs.image }}
|
||||||
|
|
||||||
|
create-manifest:
|
||||||
|
needs: build
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
if: github.event_name != 'pull_request'
|
||||||
|
name: Create multi-arch manifest
|
||||||
|
steps:
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
- name: Login to GHCR
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GCHR_PAT }}
|
||||||
|
- name: Get build outputs
|
||||||
|
id: outputs
|
||||||
|
run: |
|
||||||
|
echo "VERSION=${{ needs.build.outputs.version }}" >> $GITHUB_ENV
|
||||||
|
echo "TG_API_VERSION=${{ needs.build.outputs.tg_api_version }}" >> $GITHUB_ENV
|
||||||
|
echo "IMAGE=${{ needs.build.outputs.image }}" >> $GITHUB_ENV
|
||||||
|
- name: Create and push manifest
|
||||||
|
run: |
|
||||||
|
# Create multi-arch manifests for all tags
|
||||||
|
docker buildx imagetools create -t ${IMAGE}:${VERSION} \
|
||||||
|
${IMAGE}:${VERSION}-linux-amd64 \
|
||||||
|
${IMAGE}:${VERSION}-linux-arm64
|
||||||
|
|
||||||
|
docker buildx imagetools create -t ${IMAGE}:${GITHUB_SHA::8} \
|
||||||
|
${IMAGE}:${GITHUB_SHA::8}-linux-amd64 \
|
||||||
|
${IMAGE}:${GITHUB_SHA::8}-linux-arm64
|
||||||
|
|
||||||
|
docker buildx imagetools create -t ${IMAGE}:latest \
|
||||||
|
${IMAGE}:${VERSION}-linux-amd64 \
|
||||||
|
${IMAGE}:${VERSION}-linux-arm64
|
||||||
|
|
||||||
|
docker buildx imagetools create -t ${IMAGE}:1.0.${GITHUB_RUN_NUMBER} \
|
||||||
|
${IMAGE}:${VERSION}-linux-amd64 \
|
||||||
|
${IMAGE}:${VERSION}-linux-arm64
|
||||||
|
|
||||||
|
docker buildx imagetools create -t ${IMAGE}:api-${TG_API_VERSION} \
|
||||||
|
${IMAGE}:${VERSION}-linux-amd64 \
|
||||||
|
${IMAGE}:${VERSION}-linux-arm64
|
||||||
|
- name: Inspect manifest
|
||||||
|
run: |
|
||||||
|
docker buildx imagetools inspect ${IMAGE}:${VERSION}
|
||||||
|
docker buildx imagetools inspect ${IMAGE}:latest
|
||||||
|
|||||||
+9
-3
@@ -1,9 +1,15 @@
|
|||||||
FROM alpine:latest as buildBase
|
FROM alpine:latest as buildBase
|
||||||
RUN apk add --no-cache alpine-sdk linux-headers git zlib-dev openssl-dev gperf php cmake
|
RUN apk add --no-cache alpine-sdk linux-headers git zlib-dev openssl-dev gperf php cmake ccache
|
||||||
ADD . /srv
|
ADD . /srv
|
||||||
WORKDIR /srv
|
WORKDIR /srv
|
||||||
RUN git submodule update --init --recursive && mkdir -p build && cd build && cmake -DCMAKE_INSTALL_PREFIX:PATH=../tdlib -DCMAKE_BUILD_TYPE=Release ..
|
RUN --mount=type=cache,target=/root/.cache/git \
|
||||||
RUN cd /srv/build && cmake --build . --target install
|
git submodule update --init --recursive
|
||||||
|
RUN mkdir -p build && cd build && \
|
||||||
|
cmake -DCMAKE_INSTALL_PREFIX:PATH=../tdlib -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER_LAUNCHER=ccache ..
|
||||||
|
RUN --mount=type=cache,target=/root/.ccache \
|
||||||
|
cd /srv/build && \
|
||||||
|
export CCACHE_DIR=/root/.ccache && \
|
||||||
|
cmake --build . --target install -j$(nproc)
|
||||||
# RUN upx --best /srv/build/telegram-bot-api
|
# RUN upx --best /srv/build/telegram-bot-api
|
||||||
|
|
||||||
FROM alpine:latest
|
FROM alpine:latest
|
||||||
|
|||||||
Reference in New Issue
Block a user