Build using buildx

This commit is contained in:
Andrea Cavalli 2021-03-15 18:37:35 +01:00
parent 474ad02b1b
commit be377903b3
4 changed files with 57 additions and 150 deletions

View File

@ -1,4 +1,4 @@
name: Docker multi-arch build and push name: Docker multi-arch build
on: on:
push: push:
@ -14,7 +14,17 @@ jobs:
IMAGE_TAG_DH: ${{ secrets.DOCKERHUB_OWNER }}/tdlight-java-natives IMAGE_TAG_DH: ${{ secrets.DOCKERHUB_OWNER }}/tdlight-java-natives
strategy: strategy:
matrix: matrix:
arch: [linux/386, linux/amd64, linux/arm/v6, linux/arm/v7, linux/arm64, linux/ppc64le] include:
- {os: ubuntu-20.04, arch: "linux/386", implementation: "tdlight"}
- {os: ubuntu-20.04, arch: "linux/386", implementation: "tdlib"}
- {os: ubuntu-20.04, arch: "linux/amd64", implementation: "tdlight"}
- {os: ubuntu-20.04, arch: "linux/amd64", implementation: "tdlib"}
- {os: ubuntu-20.04, arch: "linux/arm/v6", implementation: "tdlight"}
- {os: ubuntu-20.04, arch: "linux/arm/v6", implementation: "tdlib"}
- {os: ubuntu-20.04, arch: "linux/arm/v7", implementation: "tdlight"}
- {os: ubuntu-20.04, arch: "linux/arm/v7", implementation: "tdlib"}
- {os: ubuntu-20.04, arch: "linux/arm64", implementation: "tdlight"}
- {os: ubuntu-20.04, arch: "linux/arm64", implementation: "tdlib"}
steps: steps:
- name: Checkout current repo - name: Checkout current repo
@ -79,21 +89,6 @@ jobs:
restore-keys: | restore-keys: |
${{ runner.os }}-buildx-${{ env.SAFE_ARCH }}- ${{ runner.os }}-buildx-${{ env.SAFE_ARCH }}-
- name: Login to ghcr registry
uses: docker/login-action@v1
if: ${{ github.event_name != 'pull_request' }}
with:
registry: ghcr.io
username: ${{ secrets.GH_USERNAME }}
password: ${{ secrets.GH_ACCESS_TOKEN }}
- name: Login to Docker Hub registry
uses: docker/login-action@v1
if: ${{ github.event_name != 'pull_request' }}
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}
- name: Build image - name: Build image
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:
@ -106,129 +101,14 @@ jobs:
load: true load: true
tags: | tags: |
tdlight-java-natives:${{ env.HASH_VERSION }}-${{ env.SAFE_ARCH }} tdlight-java-natives:${{ env.HASH_VERSION }}-${{ env.SAFE_ARCH }}
build-args: |
REVISION=${{ github.run_number }}
GH_MATRIX_OS=${{ matrix.os }}
GH_MATRIX_ARCH=${{ matrix.arch }}
IMPLEMENTATION_NAME=${{ matrix.implementation }}
- name: Tag and push image
if: ${{ github.event_name != 'pull_request' }} - name: Extract jni from docker image
run: | run: |
docker tag tdlight-java-natives:${{ env.HASH_VERSION }}-${{ env.SAFE_ARCH }} ${{ env.IMAGE_TAG }}:${{ env.HASH_VERSION }}-${{ env.SAFE_ARCH }} mkdir generated
docker tag tdlight-java-natives:${{ env.HASH_VERSION }}-${{ env.SAFE_ARCH }} ${{ env.IMAGE_TAG }}:${{ env.VERSION }}-${{ env.SAFE_ARCH }} docker cp $(docker create tdlight-java-natives:${{ env.HASH_VERSION }}-${{ env.SAFE_ARCH }}):/usr/src/tdlight-java-natives/generated/. ./generated/.
docker tag tdlight-java-natives:${{ env.HASH_VERSION }}-${{ env.SAFE_ARCH }} ${{ env.IMAGE_TAG_DH }}:${{ env.HASH_VERSION }}-${{ env.SAFE_ARCH }}
docker tag tdlight-java-natives:${{ env.HASH_VERSION }}-${{ env.SAFE_ARCH }} ${{ env.IMAGE_TAG_DH }}:${{ env.VERSION }}-${{ env.SAFE_ARCH }}
docker push ${{ env.IMAGE_TAG}}:${{ env.HASH_VERSION}}-${{ env.SAFE_ARCH }}
docker push ${{ env.IMAGE_TAG }}:${{ env.VERSION }}-${{ env.SAFE_ARCH }}
docker push ${{ env.IMAGE_TAG_DH }}:${{ env.HASH_VERSION }}-${{ env.SAFE_ARCH }}
docker push ${{ env.IMAGE_TAG_DH }}:${{ env.VERSION }}-${{ env.SAFE_ARCH }}
- name: Save image as tar archive
if: ${{ github.event_name != 'pull_request' }}
run: |
docker save ${{ env.IMAGE_TAG }}:${{ env.HASH_VERSION }}-${{ env.SAFE_ARCH }} -o ${{ env.SAFE_ARCH }}.tar
- name: Save image as tar archive (pull request)
if: ${{ github.event_name == 'pull_request' }}
run: |
docker save tdlight-java-natives:${{ env.HASH_VERSION }}-${{ env.SAFE_ARCH }} -o ${{ env.SAFE_ARCH }}.tar
- name: Upload image as artifact
uses: actions/upload-artifact@v2
with:
name: image_${{ env.SAFE_ARCH }}
path: ${{ env.SAFE_ARCH }}.tar
push-manifest:
name: Create and push multi-arch Docker manifest
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' }}
env:
DOCKER_CLI_EXPERIMENTAL: enabled
needs: build
steps:
- name: Download artifacts
uses: actions/download-artifact@v2
- name: Load environment info and built images
run: |
cat github_env/github.env > $GITHUB_ENV
docker load --input image_linux386/linux386.tar
docker load --input image_linuxamd64/linuxamd64.tar
docker load --input image_linuxarmv6/linuxarmv6.tar
docker load --input image_linuxarmv7/linuxarmv7.tar
docker load --input image_linuxarm64/linuxarm64.tar
docker load --input image_linuxppc64le/linuxppc64le.tar
- name: Login to ghcr registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ secrets.GH_USERNAME }}
password: ${{ secrets.GH_ACCESS_TOKEN }}
- name: Login to Docker Hub registry
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}
- name: Create and push manifest
run: |
# -- Push to ghcr.io
docker manifest create ${{ env.IMAGE_TAG }}:${{ env.HASH_VERSION }} \
--amend ${{ env.IMAGE_TAG }}:${{ env.HASH_VERSION }}-linux386 \
--amend ${{ env.IMAGE_TAG }}:${{ env.HASH_VERSION }}-linuxamd64 \
--amend ${{ env.IMAGE_TAG }}:${{ env.HASH_VERSION }}-linuxarmv6 \
--amend ${{ env.IMAGE_TAG }}:${{ env.HASH_VERSION }}-linuxarmv7 \
--amend ${{ env.IMAGE_TAG }}:${{ env.HASH_VERSION }}-linuxarm64 \
--amend ${{ env.IMAGE_TAG }}:${{ env.HASH_VERSION }}-linuxppc64le
docker manifest push ${{ env.IMAGE_TAG }}:${{ env.HASH_VERSION }}
# Tag images as VERSION (like 'latest')
docker tag ${{ env.IMAGE_TAG }}:${{ env.HASH_VERSION }}-linux386 ${{ env.IMAGE_TAG }}:${{ env.VERSION }}-linux386
docker tag ${{ env.IMAGE_TAG }}:${{ env.HASH_VERSION }}-linuxamd64 ${{ env.IMAGE_TAG }}:${{ env.VERSION }}-linuxamd64
docker tag ${{ env.IMAGE_TAG }}:${{ env.HASH_VERSION }}-linuxarmv6 ${{ env.IMAGE_TAG }}:${{ env.VERSION }}-linuxarmv6
docker tag ${{ env.IMAGE_TAG }}:${{ env.HASH_VERSION }}-linuxarmv7 ${{ env.IMAGE_TAG }}:${{ env.VERSION }}-linuxarmv7
docker tag ${{ env.IMAGE_TAG }}:${{ env.HASH_VERSION }}-linuxarm64 ${{ env.IMAGE_TAG }}:${{ env.VERSION }}-linuxarm64
docker tag ${{ env.IMAGE_TAG }}:${{ env.HASH_VERSION }}-linuxppc64le ${{ env.IMAGE_TAG }}:${{ env.VERSION }}-linuxppc64le
docker manifest create ${{ env.IMAGE_TAG }}:${{ env.VERSION }} \
--amend ${{ env.IMAGE_TAG }}:${{ env.VERSION }}-linux386 \
--amend ${{ env.IMAGE_TAG }}:${{ env.VERSION }}-linuxamd64 \
--amend ${{ env.IMAGE_TAG }}:${{ env.VERSION }}-linuxarmv6 \
--amend ${{ env.IMAGE_TAG }}:${{ env.VERSION }}-linuxarmv7 \
--amend ${{ env.IMAGE_TAG }}:${{ env.VERSION }}-linuxarm64 \
--amend ${{ env.IMAGE_TAG }}:${{ env.VERSION }}-linuxppc64le
docker manifest push ${{ env.IMAGE_TAG }}:${{ env.VERSION }}
# -- Push to Docker Hub
docker tag ${{ env.IMAGE_TAG }}:${{ env.HASH_VERSION }}-linux386 ${{ env.IMAGE_TAG_DH }}:${{ env.VERSION }}-linux386
docker tag ${{ env.IMAGE_TAG }}:${{ env.HASH_VERSION }}-linuxamd64 ${{ env.IMAGE_TAG_DH }}:${{ env.VERSION }}-linuxamd64
docker tag ${{ env.IMAGE_TAG }}:${{ env.HASH_VERSION }}-linuxarmv6 ${{ env.IMAGE_TAG_DH }}:${{ env.VERSION }}-linuxarmv6
docker tag ${{ env.IMAGE_TAG }}:${{ env.HASH_VERSION }}-linuxarmv7 ${{ env.IMAGE_TAG_DH }}:${{ env.VERSION }}-linuxarmv7
docker tag ${{ env.IMAGE_TAG }}:${{ env.HASH_VERSION }}-linuxarm64 ${{ env.IMAGE_TAG_DH }}:${{ env.VERSION }}-linuxarm64
docker tag ${{ env.IMAGE_TAG }}:${{ env.HASH_VERSION }}-linuxppc64le ${{ env.IMAGE_TAG_DH }}:${{ env.VERSION }}-linuxppc64le
docker manifest create ${{ env.IMAGE_TAG_DH }}:${{ env.HASH_VERSION }} \
--amend ${{ env.IMAGE_TAG_DH }}:${{ env.HASH_VERSION }}-linux386 \
--amend ${{ env.IMAGE_TAG_DH }}:${{ env.HASH_VERSION }}-linuxamd64 \
--amend ${{ env.IMAGE_TAG_DH }}:${{ env.HASH_VERSION }}-linuxarmv6 \
--amend ${{ env.IMAGE_TAG_DH }}:${{ env.HASH_VERSION }}-linuxarmv7 \
--amend ${{ env.IMAGE_TAG_DH }}:${{ env.HASH_VERSION }}-linuxarm64 \
--amend ${{ env.IMAGE_TAG_DH }}:${{ env.HASH_VERSION }}-linuxppc64le
docker manifest push ${{ env.IMAGE_TAG_DH }}:${{ env.HASH_VERSION }}
# Tag images as VERSION (like 'latest')
docker tag ${{ env.IMAGE_TAG }}:${{ env.HASH_VERSION }}-linux386 ${{ env.IMAGE_TAG_DH }}:${{ env.VERSION }}-linux386
docker tag ${{ env.IMAGE_TAG }}:${{ env.HASH_VERSION }}-linuxamd64 ${{ env.IMAGE_TAG_DH }}:${{ env.VERSION }}-linuxamd64
docker tag ${{ env.IMAGE_TAG }}:${{ env.HASH_VERSION }}-linuxarmv6 ${{ env.IMAGE_TAG_DH }}:${{ env.VERSION }}-linuxarmv6
docker tag ${{ env.IMAGE_TAG }}:${{ env.HASH_VERSION }}-linuxarmv7 ${{ env.IMAGE_TAG_DH }}:${{ env.VERSION }}-linuxarmv7
docker tag ${{ env.IMAGE_TAG }}:${{ env.HASH_VERSION }}-linuxarm64 ${{ env.IMAGE_TAG_DH }}:${{ env.VERSION }}-linuxarm64
docker tag ${{ env.IMAGE_TAG }}:${{ env.HASH_VERSION }}-linuxppc64le ${{ env.IMAGE_TAG_DH }}:${{ env.VERSION }}-linuxppc64le
docker manifest create ${{ env.IMAGE_TAG_DH }}:${{ env.VERSION }} \
--amend ${{ env.IMAGE_TAG_DH }}:${{ env.VERSION }}-linux386 \
--amend ${{ env.IMAGE_TAG_DH }}:${{ env.VERSION }}-linuxamd64 \
--amend ${{ env.IMAGE_TAG_DH }}:${{ env.VERSION }}-linuxarmv6 \
--amend ${{ env.IMAGE_TAG_DH }}:${{ env.VERSION }}-linuxarmv7 \
--amend ${{ env.IMAGE_TAG_DH }}:${{ env.VERSION }}-linuxarm64 \
--amend ${{ env.IMAGE_TAG_DH }}:${{ env.VERSION }}-linuxppc64le
docker manifest push ${{ env.IMAGE_TAG_DH }}:${{ env.VERSION }}

View File

@ -1,16 +1,36 @@
FROM ubuntu:groovy FROM debian:bullseye
ARG REVISION
ARG GH_MATRIX_OS
ARG GH_MATRIX_ARCH
ARG IMPLEMENTATION_NAME
ENV DEBIAN_FRONTEND noninteractive ENV DEBIAN_FRONTEND noninteractive
RUN apt update && apt upgrade -y ENV TZ=Europe/Kiev
RUN apt install -y make git zlib1g-dev libssl-dev gperf cmake clang-10 libc++-10-dev libc++abi-10-dev ccache maven python3 python3-pip php7.4-cli openjdk-15-jdk RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
WORKDIR /usr/src/tdlight-java-natives/scripts/utils RUN apt update && apt upgrade -y
RUN apt install -y sudo openjdk-11-jdk locales
#RUN apt install -y make git zlib1g-dev libssl-dev gperf cmake clang-10 libc++-10-dev libc++abi-10-dev ccache maven python3 python3-pip php7.4-cli openjdk-15-jdk
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
dpkg-reconfigure --frontend=noninteractive locales && \
update-locale LANG=en_US.UTF-8
ENV LANG en_US.UTF-8
ENV JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8
ADD implementations /usr/src/tdlight-java-natives/implementations ADD implementations /usr/src/tdlight-java-natives/implementations
ADD scripts /usr/src/tdlight-java-natives/scripts ADD scripts /usr/src/tdlight-java-natives/scripts
ADD src /usr/src/tdlight-java-natives/src ADD src /usr/src/tdlight-java-natives/src
RUN ./compile-natives-package.sh WORKDIR /usr/src/tdlight-java-natives/
RUN /bin/bash -c "export JAVA_HOME=\"/usr/lib/jvm/$(ls /usr/lib/jvm/ | grep openjdk | head -n 1)/\"; export JAVA_INCLUDE_PATH=\"$JAVA_HOME/include\"; source ./scripts/continuous-integration/github-workflows/setup-variables.sh; source ./scripts/continuous-integration/github-workflows/install-dependencies.sh; source ./scripts/continuous-integration/github-workflows/build-natives.sh"
#WORKDIR /usr/src/tdlight-java-natives/generated/
#RUN echo "aaaa" > test.txt
ENTRYPOINT [ "/bin/bash" ] ENTRYPOINT [ "/bin/bash" ]

View File

@ -3,8 +3,8 @@ set -e
if [[ "$OPERATING_SYSTEM_NAME" == "linux" ]]; then if [[ "$OPERATING_SYSTEM_NAME" == "linux" ]]; then
echo "==Linux====" echo "==Linux===="
sudo apt install -y make git zlib1g-dev libssl-dev gperf cmake clang-10 \ sudo apt install -y make git zlib1g-dev libssl-dev gperf cmake clang-11 \
libc++-10-dev libc++abi-10-dev ccache maven python3 python3-pip php7.4-cli libc++-11-dev libc++abi-11-dev ccache maven python3 python3-pip php7.4-cli
elif [[ "$OPERATING_SYSTEM_NAME" == "osx" ]]; then elif [[ "$OPERATING_SYSTEM_NAME" == "osx" ]]; then
echo "==OSX======" echo "==OSX======"
export PYTHON=36 export PYTHON=36

View File

@ -87,9 +87,16 @@ elif [[ "$OPERATING_SYSTEM_NAME" == "linux" ]]; then
export CMAKE_EXTRA_ARGUMENTS="-DOPENSSL_USE_STATIC_LIBS=ON -DCMAKE_FIND_LIBRARY_SUFFIXES=\".a\"" export CMAKE_EXTRA_ARGUMENTS="-DOPENSSL_USE_STATIC_LIBS=ON -DCMAKE_FIND_LIBRARY_SUFFIXES=\".a\""
export CXXFLAGS="-static-libgcc -static-libstdc++" export CXXFLAGS="-static-libgcc -static-libstdc++"
fi fi
if [[ "$CPU_ARCHITECTURE_NAME" = "386" ]]; then
export CXXFLAGS="$CXXFLAGS -latomic"
export CMAKE_EXE_LINKER_FLAGS="$CMAKE_EXE_LINKER_FLAGS -latomic"
export LDFLAGS="$LDFLAGS -latomic"
fi
export CPU_CORES=" -- -j${CPU_CORES_NUM}" export CPU_CORES=" -- -j${CPU_CORES_NUM}"
export CC="/usr/bin/clang-10" export CC="/usr/bin/clang-11"
export CXX="/usr/bin/clang++-10" export CXX="/usr/bin/clang++-11"
fi fi
# ====== Print variables # ====== Print variables