diff options
author | Erlang/OTP <otp@erlang.org> | 2021-02-19 11:38:49 +0100 |
---|---|---|
committer | Erlang/OTP <otp@erlang.org> | 2021-02-19 11:38:49 +0100 |
commit | 4feb126c32ec64745e9d089f0648bd95d556acb6 (patch) | |
tree | 5895f6a267fe3b149aa7caf07f0e746ad5a15ba1 | |
parent | 775806a5363ad496ca573f4baa797628d15d7e2f (diff) | |
parent | 423ad4788841899c03206896b257044567ac7cf0 (diff) | |
download | erlang-4feb126c32ec64745e9d089f0648bd95d556acb6.tar.gz |
Merge branch 'lukas/add-github-actions' into maint-21
* lukas/add-github-actions:
Fix github action base image build
Try to fix buildx caches
-rw-r--r-- | .github/dockerfiles/Dockerfile.cross-compile | 10 | ||||
-rw-r--r-- | .github/dockerfiles/Dockerfile.debian-base | 53 | ||||
-rwxr-xr-x | .github/scripts/base-tag | 4 | ||||
-rw-r--r-- | .github/workflows/main.yaml | 25 | ||||
-rw-r--r-- | .github/workflows/update-base.yaml | 25 |
5 files changed, 60 insertions, 57 deletions
diff --git a/.github/dockerfiles/Dockerfile.cross-compile b/.github/dockerfiles/Dockerfile.cross-compile index 868f8beed1..98f7f0e576 100644 --- a/.github/dockerfiles/Dockerfile.cross-compile +++ b/.github/dockerfiles/Dockerfile.cross-compile @@ -3,9 +3,6 @@ ## FROM docker.pkg.github.com/erlang/otp/i386-debian-base as build -ARG HOST_ARCH=amd64 -ARG HOST_TRIP=x86_64-linux-gnu - ARG MAKEFLAGS=-j4 ENV MAKEFLAGS=$MAKEFLAGS \ ERLC_USE_SERVER=yes \ @@ -21,7 +18,8 @@ WORKDIR /buildroot/otp/ RUN ./configure && make && make install ## Build pre-build tar ball -RUN scripts/build-otp-tar -o /buildroot/otp_clean_src.tar.gz /buildroot/otp_src.tar.gz -b /buildroot/otp/ /buildroot/otp.tar.gz +RUN scripts/build-otp-tar -o /buildroot/otp_clean_src.tar.gz /buildroot/otp_src.tar.gz \ + -b /buildroot/otp/ /buildroot/otp.tar.gz ## Prepare for a new build using pre-built tar ball RUN cd .. && rm -rf otp && tar -xzf ./otp_src.tar.gz @@ -43,7 +41,9 @@ RUN ./configure --prefix=/otp/ --host=$HOST --build=`erts/autoconf/config.guess` ## Build the cross tests RUN ./otp_build tests RUN cd release/tests/test_server && \ - erl -sname test@docker -noshell -eval "ts:install([{cross,\"yes\"},{crossflags,[{\"host\",\"$HOST\"}]},{crossroot,\"/$ERL_TOP\"}])." -s ts compile_testcases -s init stop + erl -sname test@docker -noshell \ + -eval "ts:install([{cross,\"yes\"},{crossflags,[{\"host\",\"$HOST\"}]},{crossroot,\"/$ERL_TOP\"}])." \ + -s ts compile_testcases -s init stop FROM debian as install diff --git a/.github/dockerfiles/Dockerfile.debian-base b/.github/dockerfiles/Dockerfile.debian-base index 1c26677959..416edd97c9 100644 --- a/.github/dockerfiles/Dockerfile.debian-base +++ b/.github/dockerfiles/Dockerfile.debian-base @@ -6,29 +6,38 @@ FROM $BASE ## Need to have a second arg here as the first does not expose the $BASE in the script below ARG BASE=debian -ARG HOST_ARCH=amd64 ARG HOST_TRIP=x86_64-linux-gnu +ENV HOST_TRIP=$HOST_TRIP -ENV INSTALL_LIBS="zlib1g-dev libncurses5-dev libssh-dev unixodbc-dev libgmp3-dev libwxbase3.0-dev libwxgtk3.0-dev libsctp-dev lksctp-tools" +ENV INSTALL_LIBS="zlib1g-dev libncurses5-dev libssh-dev unixodbc-dev libgmp3-dev libwxbase3.0-dev libwxgtk3.0-dev libwxgtk-webview3.0-gtk3-dev libsctp-dev lksctp-tools" ## See https://wiki.debian.org/Multiarch/HOWTO for details on how to install things -RUN if [ "$BASE" = "i386/debian" ]; then BUILD_ARCH=`dpkg --print-architecture` && \ - dpkg --add-architecture $HOST_ARCH && \ - sed -i "s:deb http:deb [arch=$BUILD_ARCH,$HOST_ARCH] http:g" /etc/apt/sources.list; \ - fi - -RUN apt-get update && \ - apt-get -y upgrade && \ - apt-get install -y build-essential m4 autoconf fop xsltproc \ - default-jdk libxml2-utils $INSTALL_LIBS - -RUN if [ "$BASE" = "i386/debian" ]; then apt-get install -y \ - crossbuild-essential-$HOST_ARCH \ - $(for LIB in $INSTALL_LIBS; do echo "$LIB:$HOST_ARCH"; done) && \ - for dir in `find / -type d -name $HOST_TRIP`; do \ - echo -n "$dir: /buildroot/sysroot"; \ - echo `dirname $dir`; \ - mkdir -p /buildroot/sysroot$dir; \ - cp -r `dirname $dir`/* `dirname /buildroot/sysroot$dir`; \ - cp -r $dir/* `dirname /buildroot/sysroot$dir`; \ - done; fi +## +## 1. Install build-essential to get access to dpkg-architecture +## 2. Use dpkg-architecture to figure out what we are runnon on +## 3. If the HOST_TRIP does not equal BUILD_TRIP we should cross compile +RUN apt-get update && apt-get -y upgrade && apt-get install -y build-essential && \ + BUILD_TRIP=`dpkg-architecture -t${HOST_TRIP} -qDEB_BUILD_MULTIARCH` && \ + BUILD_ARCH=`dpkg-architecture -t${HOST_TRIP} -qDEB_BUILD_ARCH` && \ + if [ "$HOST_TRIP" != "$BUILD_TRIP" ]; then \ + HOST_ARCH=`dpkg-architecture -t${HOST_TRIP} -qDEB_HOST_ARCH` && \ + dpkg --add-architecture $HOST_ARCH && \ + sed -i "s:deb http:deb [arch=$BUILD_ARCH,$HOST_ARCH] http:g" /etc/apt/sources.list; \ + fi && \ + apt-get update && \ + apt-get install -y build-essential m4 autoconf fop xsltproc default-jdk libxml2-utils \ + $INSTALL_LIBS && \ + if [ "$HOST_TRIP" != "$BUILD_TRIP" ]; then \ + apt-get install -y \ + crossbuild-essential-$HOST_ARCH \ + $(for LIB in $INSTALL_LIBS; do echo "$LIB:$HOST_ARCH"; done) && \ + for dir in `find / -type d -name $HOST_TRIP`; do \ + echo -n "$dir: /buildroot/sysroot"; \ + echo `dirname $dir`; \ + mkdir -p /buildroot/sysroot$dir; \ + cp -r `dirname $dir`/* `dirname /buildroot/sysroot$dir`; \ + cp -r $dir/* `dirname /buildroot/sysroot$dir`; \ + done; \ + fi && \ + update-alternatives --set wx-config /usr/lib/${BUILD_TRIP}/wx/config/gtk3-unicode-3.0 && \ + rm -rf /var/lib/apt/lists/* diff --git a/.github/scripts/base-tag b/.github/scripts/base-tag index 994192e6d2..6683793762 100755 --- a/.github/scripts/base-tag +++ b/.github/scripts/base-tag @@ -4,7 +4,7 @@ set -x case "$1" in *i386-debian-base) - BASE=i386/debian + BASE="i386/debian" BASE_TYPE=debian-base ;; *debian-base) @@ -12,7 +12,7 @@ case "$1" in BASE_TYPE=debian-base ;; *ubuntu-base) - BASE="debian" + BASE="ubuntu" BASE_TYPE=ubuntu-base ;; esac diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 6c468a6f30..988bf3b07e 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -13,8 +13,8 @@ ## When ghcr.io support using the GITHUB_TOKEN we should migrate ## over to use it instead as that should allow us to use the ## built-in caching mechanisms of docker/build-push-action@v2. -## However as things are now we manually pull the correct image -## from docker.pkg.github.com +## However as things are now we use docker directly to make things +## work. ## name: Build and check Erlang/OTP @@ -68,12 +68,6 @@ jobs: uses: actions/download-artifact@v2 with: name: otp_git_archive - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - with: - driver: docker - ## We need to login to the package registry in order to pull - ## the base debian image. - name: Docker login uses: docker/login-action@v1 with: @@ -88,13 +82,16 @@ jobs: .github/scripts/base-tag "${BASE_TAG}" - name: Pull BASE image run: docker pull ${{ steps.base.outputs.BASE_TAG }} + - name: Build BASE image + run: | + docker build --pull --tag ${{ steps.base.outputs.BASE_TAG }} \ + --cache-from ${{ steps.base.outputs.BASE_TAG }} \ + --file .github/dockerfiles/Dockerfile.${{ steps.base.outputs.BASE_TYPE }} \ + --build-arg BASE=${{ steps.base.outputs.BASE }} . - name: Build ${{ matrix.type }} image - uses: docker/build-push-action@v2 - with: - context: . - tags: otp:latest - file: .github/dockerfiles/Dockerfile.${{ matrix.type }} - build-args: ARCHIVE=otp_src.tar.gz + run: | + docker build --tag otp --file .github/dockerfiles/Dockerfile.${{ matrix.type }} \ + --build-arg ARCHIVE=otp_src.tar.gz . ## Smoke build tests - if: matrix.type == '32-bit' || matrix.type == '64-bit' || matrix.type == 'cross-compile' diff --git a/.github/workflows/update-base.yaml b/.github/workflows/update-base.yaml index 081480492a..6cf2eafac2 100644 --- a/.github/workflows/update-base.yaml +++ b/.github/workflows/update-base.yaml @@ -20,10 +20,6 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - with: - driver: docker - name: Docker login uses: docker/login-action@v1 with: @@ -32,13 +28,14 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Calculate BASE image id: base - run: .github/scripts/base-tag "${{ matrix.type }}" - - name: Build and push base image - uses: docker/build-push-action@v2 - with: - context: . - file: .github/dockerfiles/Dockerfile.${{ steps.base.outputs.BASE_TYPE }} - pull: true - push: true - build-args: BASE=${{ steps.base.outputs.BASE }} - tags: docker.pkg.github.com/${{ github.repository }}/${{ matrix.type }}:latest + run: | + echo "::set-output name=BASE_TAG::docker.pkg.github.com/erlang/otp/${{ matrix.type }}" + .github/scripts/base-tag "${{ matrix.type }}" + - name: Build base image + run: | + docker build --pull --tag ${{ steps.base.outputs.BASE_TAG }} \ + --cache-from ${{ steps.base.outputs.BASE_TAG }} \ + --file .github/dockerfiles/Dockerfile.${{ steps.base.outputs.BASE_TYPE }} \ + --build-arg BASE=${{ steps.base.outputs.BASE }} . + - name: Push base image + run: docker push ${{ steps.base.outputs.BASE_TAG }} |