Use Docker's actions to build Docker image

This commit is contained in:
Ilya Fedin 2025-05-08 02:54:37 +04:00 committed by John Preston
parent ce010653d5
commit f2920ddefb
2 changed files with 30 additions and 50 deletions

View file

@ -1,46 +0,0 @@
name: Docker.
on:
push:
paths:
- '.github/workflows/docker.yml'
- 'Telegram/build/docker/centos_env/**'
pull_request:
paths:
- '.github/workflows/docker.yml'
- 'Telegram/build/docker/centos_env/**'
jobs:
docker:
name: Ubuntu
runs-on: ubuntu-latest
env:
IMAGE_TAG: ghcr.io/${{ github.repository }}/centos_env:latest
steps:
- name: Clone.
uses: actions/checkout@v4
with:
submodules: recursive
- name: First set up.
run: |
sudo apt update
curl -sSL https://install.python-poetry.org | python3 -
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin
- name: Free up some disk space.
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be
with:
tool-cache: true
- name: Docker image build.
run: |
cd Telegram/build/docker/centos_env
poetry install
DEBUG= LTO= poetry run gen_dockerfile | DOCKER_BUILDKIT=1 docker build -t $IMAGE_TAG -
- name: Push the Docker image.
if: ${{ github.ref_name == github.event.repository.default_branch }}
run: docker push $IMAGE_TAG

View file

@ -12,6 +12,7 @@ on:
- '!.github/workflows/linux.yml' - '!.github/workflows/linux.yml'
- 'snap/**' - 'snap/**'
- 'Telegram/build/**' - 'Telegram/build/**'
- '!Telegram/build/docker/centos_env/**'
- 'Telegram/Resources/uwp/**' - 'Telegram/Resources/uwp/**'
- 'Telegram/Resources/winrc/**' - 'Telegram/Resources/winrc/**'
- 'Telegram/SourceFiles/platform/win/**' - 'Telegram/SourceFiles/platform/win/**'
@ -30,6 +31,7 @@ on:
- '!.github/workflows/linux.yml' - '!.github/workflows/linux.yml'
- 'snap/**' - 'snap/**'
- 'Telegram/build/**' - 'Telegram/build/**'
- '!Telegram/build/docker/centos_env/**'
- 'Telegram/Resources/uwp/**' - 'Telegram/Resources/uwp/**'
- 'Telegram/Resources/winrc/**' - 'Telegram/Resources/winrc/**'
- 'Telegram/SourceFiles/platform/win/**' - 'Telegram/SourceFiles/platform/win/**'
@ -52,6 +54,8 @@ jobs:
env: env:
UPLOAD_ARTIFACT: "true" UPLOAD_ARTIFACT: "true"
ONLY_CACHE: "false"
IMAGE_TAG: tdesktop:centos_env
steps: steps:
- name: Clone. - name: Clone.
@ -61,11 +65,32 @@ jobs:
- name: First set up. - name: First set up.
run: | run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin sudo apt update
docker pull ghcr.io/$GITHUB_REPOSITORY/centos_env curl -sSL https://install.python-poetry.org | python3 -
docker tag ghcr.io/$GITHUB_REPOSITORY/centos_env tdesktop:centos_env cd Telegram/build/docker/centos_env
poetry install
DOCKERFILE=$(DEBUG= LTO= poetry run gen_dockerfile)
echo "$DOCKERFILE" > Dockerfile
- name: Free up some disk space.
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be
with:
tool-cache: true
- name: Set up Docker Buildx.
uses: docker/setup-buildx-action@v3
- name: Libraries.
uses: docker/build-push-action@v6
with:
context: Telegram/build/docker/centos_env
load: ${{ env.ONLY_CACHE == 'false' }}
tags: ${{ env.IMAGE_TAG }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Telegram Desktop build. - name: Telegram Desktop build.
if: env.ONLY_CACHE == 'false'
run: | run: |
DEFINE="" DEFINE=""
if [ -n "${{ matrix.defines }}" ]; then if [ -n "${{ matrix.defines }}" ]; then
@ -80,7 +105,7 @@ jobs:
-u $(id -u) \ -u $(id -u) \
-v $PWD:/usr/src/tdesktop \ -v $PWD:/usr/src/tdesktop \
-e CONFIG=Debug \ -e CONFIG=Debug \
tdesktop:centos_env \ $IMAGE_TAG \
/usr/src/tdesktop/Telegram/build/docker/centos_env/build.sh \ /usr/src/tdesktop/Telegram/build/docker/centos_env/build.sh \
-D CMAKE_CONFIGURATION_TYPES=Debug \ -D CMAKE_CONFIGURATION_TYPES=Debug \
-D CMAKE_C_FLAGS_DEBUG="" \ -D CMAKE_C_FLAGS_DEBUG="" \
@ -94,6 +119,7 @@ jobs:
$DEFINE $DEFINE
- name: Check. - name: Check.
if: env.ONLY_CACHE == 'false'
run: | run: |
filePath="out/Debug/Telegram" filePath="out/Debug/Telegram"
if test -f "$filePath"; then if test -f "$filePath"; then