diff --git a/.github/workflows/containers.yml b/.github/workflows/containers.yml index 5d98a79..36bf843 100644 --- a/.github/workflows/containers.yml +++ b/.github/workflows/containers.yml @@ -146,6 +146,7 @@ jobs: uses: docker/build-push-action@v2 with: target: dev-generic + platforms: linux/amd64,linux/arm64 build-args: | ZEPHYR_VERSION=${{ env.zephyr-version }} no-cache: ${{ env.no-cache == 'true' }} @@ -162,6 +163,7 @@ jobs: uses: docker/build-push-action@v2 with: target: dev-generic + platforms: linux/amd64,linux/arm64 build-args: | ZEPHYR_VERSION=${{ env.zephyr-version }} tags: | @@ -431,14 +433,51 @@ jobs: - name: Stop container shell: bash run: docker stop candidate - - name: Push candidate images to the registry - if: ${{ steps.docker-hub-login.outcome == 'success' }} - shell: bash - run: | - docker image push ${{ steps.paths.outputs.build-candidate }} - docker image push ${{ steps.paths.outputs.build-branch }} - docker image push ${{ steps.paths.outputs.dev-candidate }} - docker image push ${{ steps.paths.outputs.dev-branch }} + - name: Build and push 'build' candidate image (x86_64 and arm64) + uses: docker/build-push-action@v2 + with: + target: build + platforms: linux/amd64,linux/arm64 + build-args: | + ${{ steps.build-args.outputs.list }} + labels: | + ${{ steps.labels.outputs.list }} + tags: | + ${{ steps.paths.outputs.build-candidate }} + ${{ steps.paths.outputs.build-branch }} + cache-from: | + type=local,src=${{ steps.paths.outputs.dev-generic }} + ${{ (env.no-cache == 'false') && format('type=registry,ref={0}', steps.paths.outputs.build-candidate) }} + ${{ (env.no-cache == 'false') && format('type=registry,ref={0}', steps.paths.outputs.build-branch) }} + ${{ (env.no-cache == 'false') && (steps.paths.outputs.build-base != '') && format('type=registry,ref={0}', steps.paths.outputs.build-base) || '' }} + ${{ (env.no-cache == 'false') && format('type=registry,ref={0}', steps.paths.outputs.build-major-minor-branch) }} + ${{ (env.no-cache == 'false') && format('type=registry,ref={0}', steps.paths.outputs.build-branch-upstream) }} + ${{ (env.no-cache == 'false') && format('type=registry,ref={0}', steps.paths.outputs.build-major-minor-branch-upstream) }} + cache-to: type=inline + push: true + - name: Build and push 'dev' candidate image (x86_64 + arm64) + uses: docker/build-push-action@v2 + with: + target: dev + platforms: linux/amd64,linux/arm64 + build-args: | + ${{ steps.build-args.outputs.list }} + labels: | + ${{ steps.labels.outputs.list }} + tags: | + ${{ steps.paths.outputs.dev-candidate }} + ${{ steps.paths.outputs.dev-branch }} + cache-from: | + type=registry,ref=${{ steps.paths.outputs.build-candidate }} + type=local,src=${{ steps.paths.outputs.dev-generic }} + ${{ (env.no-cache == 'false') && format('type=registry,ref={0}', steps.paths.outputs.dev-candidate) }} + ${{ (env.no-cache == 'false') && format('type=registry,ref={0}', steps.paths.outputs.dev-branch) }} + ${{ (env.no-cache == 'false') && (steps.paths.outputs.dev-base != '') && format('type=registry,ref={0}', steps.paths.outputs.dev-base) || '' }} + ${{ (env.no-cache == 'false') && format('type=registry,ref={0}', steps.paths.outputs.dev-major-minor-branch) }} + ${{ (env.no-cache == 'false') && format('type=registry,ref={0}', steps.paths.outputs.dev-branch-upstream) }} + ${{ (env.no-cache == 'false') && format('type=registry,ref={0}', steps.paths.outputs.dev-major-minor-branch-upstream) }} + cache-to: type=inline + push: true release-trigger: if: ${{ startsWith(github.ref, 'refs/tags') }} runs-on: ubuntu-latest diff --git a/Dockerfile b/Dockerfile index 112ee8b..c3e8c3c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,11 +8,12 @@ ARG ZEPHYR_VERSION ENV ZEPHYR_VERSION=${ZEPHYR_VERSION} RUN \ apt-get -y update \ + && if [ "$(uname -m)" = "x86_64" ]; then gcc_multilib="gcc-multilib"; else gcc_multilib=""; fi \ && apt-get -y install --no-install-recommends \ ccache \ file \ gcc \ - gcc-multilib \ + "${gcc_multilib}" \ git \ gperf \ make \ @@ -48,7 +49,6 @@ RUN \ && apt-get -y update \ && apt-get -y install --no-install-recommends \ clang-format \ - g++-multilib \ gdb \ gpg \ gpg-agent \ @@ -86,16 +86,16 @@ FROM common AS build ARG ARCHITECTURE ARG ZEPHYR_SDK_VERSION -ARG ZEPHYR_SDK_SETUP_FILENAME=zephyr-toolchain-${ARCHITECTURE}-${ZEPHYR_SDK_VERSION}-linux-x86_64-setup.run ARG ZEPHYR_SDK_INSTALL_DIR=/opt/zephyr-sdk-${ZEPHYR_SDK_VERSION} RUN \ - apt-get -y update \ + export sdk_file_name="zephyr-toolchain-${ARCHITECTURE}-${ZEPHYR_SDK_VERSION}-linux-$(uname -m)-setup.run" \ + && apt-get -y update \ && apt-get -y install --no-install-recommends \ wget \ xz-utils \ - && wget -q "https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${ZEPHYR_SDK_VERSION}/${ZEPHYR_SDK_SETUP_FILENAME}" \ - && sh ${ZEPHYR_SDK_SETUP_FILENAME} --quiet -- -d ${ZEPHYR_SDK_INSTALL_DIR} \ - && rm ${ZEPHYR_SDK_SETUP_FILENAME} \ + && wget -q "https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${ZEPHYR_SDK_VERSION}/${sdk_file_name}" \ + && sh ${sdk_file_name} --quiet -- -d ${ZEPHYR_SDK_INSTALL_DIR} \ + && rm ${sdk_file_name} \ && apt-get remove -y --purge \ wget \ xz-utils \