diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..9dd69c2 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +.git +.github +README.md +LICENSE diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 5489313..b29f159 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -26,7 +26,7 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Log into GitHub Container Registry - # if: github.event_name != 'pull_request' + if: github.event_name != 'pull_request' uses: docker/login-action@v3 with: registry: ghcr.io @@ -37,13 +37,14 @@ jobs: id: build-and-push uses: docker/build-push-action@v5 with: - context: . + context: ./zephyr-base file: ./zephyr-base/Dockerfile - # push: ${{ github.event_name != 'pull_request' }} - push: true + push: ${{ github.event_name != 'pull_request' }} platforms: linux/amd64,linux/arm64 provenance: false tags: ghcr.io/${{ github.repository_owner }}/zephyr:base-${{ matrix.sdk }}SDK + cache-from: type=gha,scope=zephyr-base-${{ matrix.sdk }} + cache-to: type=gha,mode=max,scope=zephyr-base-${{ matrix.sdk }} build-args: | ZEPHYR_SDK_VERSION=${{ matrix.sdk }} @@ -166,7 +167,7 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Log into GitHub Container Registry - # if: github.event_name != 'pull_request' + if: github.event_name != 'pull_request' uses: docker/login-action@v3 with: registry: ghcr.io @@ -177,13 +178,14 @@ jobs: id: build-and-push uses: docker/build-push-action@v5 with: - context: . + context: ./zephyr file: ./zephyr/Dockerfile - # push: ${{ github.event_name != 'pull_request' }} - push: true + push: ${{ github.event_name != 'pull_request' }} platforms: linux/amd64,linux/arm64 provenance: false tags: ghcr.io/${{ github.repository_owner }}/zephyr:${{ matrix.toolchain.nick }}-${{ matrix.sdk }}SDK + cache-from: type=gha,scope=zephyr-arch-${{ matrix.sdk }}-${{ matrix.toolchain.nick }} + cache-to: type=gha,mode=max,scope=zephyr-arch-${{ matrix.sdk }}-${{ matrix.toolchain.nick }} build-args: | BASE_IMAGE=ghcr.io/embeddedcontainers/zephyr:base-${{ matrix.sdk }}SDK ZEPHYR_SDK_TOOLCHAINS=-t ${{ matrix.toolchain.arch }} @@ -210,7 +212,7 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Log into GitHub Container Registry - # if: github.event_name != 'pull_request' + if: github.event_name != 'pull_request' uses: docker/login-action@v3 with: registry: ghcr.io @@ -221,13 +223,14 @@ jobs: id: build-and-push uses: docker/build-push-action@v5 with: - context: . + context: ./zephyr file: ./zephyr/Dockerfile - # push: ${{ github.event_name != 'pull_request' }} - push: true + push: ${{ github.event_name != 'pull_request' }} platforms: linux/amd64,linux/arm64 provenance: false - tags: ghcr.io/${{ github.repository_owner }}/zephyr:llvm${{ matrix.sdk }}SDK + tags: ghcr.io/${{ github.repository_owner }}/zephyr:llvm-${{ matrix.sdk }}SDK + cache-from: type=gha,scope=zephyr-llvm-${{ matrix.sdk }} + cache-to: type=gha,mode=max,scope=zephyr-llvm-${{ matrix.sdk }} build-args: | BASE_IMAGE=ghcr.io/embeddedcontainers/zephyr:base-${{ matrix.sdk }}SDK ZEPHYR_SDK_TOOLCHAINS=-l @@ -254,7 +257,7 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Log into GitHub Container Registry - # if: github.event_name != 'pull_request' + if: github.event_name != 'pull_request' uses: docker/login-action@v3 with: registry: ghcr.io @@ -265,13 +268,14 @@ jobs: id: build-and-push uses: docker/build-push-action@v5 with: - context: . + context: ./zephyr-posix file: ./zephyr-posix/Dockerfile - # push: ${{ github.event_name != 'pull_request' }} - push: true + push: ${{ github.event_name != 'pull_request' }} platforms: linux/amd64 provenance: false tags: ghcr.io/${{ github.repository_owner }}/zephyr:posix-${{ matrix.sdk }}SDK + cache-from: type=gha,scope=zephyr-posix-${{ matrix.sdk }} + cache-to: type=gha,mode=max,scope=zephyr-posix-${{ matrix.sdk }} build-args: | BASE_IMAGE=ghcr.io/embeddedcontainers/zephyr:base-${{ matrix.sdk }}SDK ZEPHYR_SDK_VERSION=${{ matrix.sdk }} diff --git a/zephyr-base/Dockerfile b/zephyr-base/Dockerfile index d09edff..110bd2b 100644 --- a/zephyr-base/Dockerfile +++ b/zephyr-base/Dockerfile @@ -1,11 +1,14 @@ +# syntax=docker/dockerfile:1.7 FROM debian:stable-slim -ARG ZEPHYR_SDK_VERSION=0.16.4 +ARG ZEPHYR_SDK_VERSION=1.0.0 ARG ZEPHYR_SDK_INSTALL_DIR=/opt/toolchains/zephyr-sdk-${ZEPHYR_SDK_VERSION} # OS dependencies and packages -RUN \ +ENV VIRTUAL_ENV=/opt/venv +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt/lists,sharing=locked \ apt-get -y update \ && apt-get -y install --no-install-recommends \ ca-certificates \ @@ -13,12 +16,21 @@ RUN \ device-tree-compiler \ git \ ninja-build \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* + python3 \ + python3-pip \ + python3-venv \ + && python3 -m venv $VIRTUAL_ENV +ENV PATH="$VIRTUAL_ENV/bin:$PATH" + +# West + +RUN --mount=type=cache,target=/root/.cache/pip,sharing=locked \ + pip install wheel west # Zephyr SDK -RUN \ +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt/lists,sharing=locked \ export sdk_file_name="zephyr-sdk-${ZEPHYR_SDK_VERSION}_linux-$(uname -m)_minimal.tar.xz" \ && apt-get -y update \ && apt-get -y install --no-install-recommends \ @@ -32,21 +44,6 @@ RUN \ && apt-get remove -y --purge \ wget \ xz-utils \ + && apt-get autoremove -y \ && apt-get clean \ - && rm -rf /var/lib/apt/lists/* - -# Python - -ENV VIRTUAL_ENV=/opt/venv -RUN \ - apt-get -y update \ - && apt-get -y install --no-install-recommends \ - python3 \ - python3-pip \ - python3-venv \ - && python3 -m venv $VIRTUAL_ENV -ENV PATH="$VIRTUAL_ENV/bin:$PATH" - -# West - -RUN pip install --no-cache-dir wheel west \ No newline at end of file + && rm -rf /var/lib/apt/lists/* \ No newline at end of file diff --git a/zephyr-posix/Dockerfile b/zephyr-posix/Dockerfile index aa7d434..d9eeecc 100644 --- a/zephyr-posix/Dockerfile +++ b/zephyr-posix/Dockerfile @@ -1,29 +1,24 @@ -ARG ZEPHYR_SDK_VERSION=0.17.0 +# syntax=docker/dockerfile:1.7 +ARG ZEPHYR_SDK_VERSION=1.0.0 ARG ZEPHYR_SDK_INSTALL_DIR=/opt/toolchains/zephyr-sdk-${ZEPHYR_SDK_VERSION} ARG BASE_IMAGE="zephyr:base-${ZEPHYR_SDK_VERSION}SDK" FROM ${BASE_IMAGE} -# OS dependencies and packages - -RUN \ - apt-get -y update \ - && apt-get -y install --no-install-recommends \ - gcc-multilib \ - make \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* - -# Zephyr SDK +# OS dependencies and Zephyr SDK posix setup ARG ZEPHYR_SDK_INSTALL_DIR -RUN \ +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt/lists,sharing=locked \ apt-get -y update \ && apt-get -y install --no-install-recommends \ + gcc-multilib \ + make \ wget \ && ${ZEPHYR_SDK_INSTALL_DIR}/setup.sh -c \ && apt-get remove -y --purge \ wget \ + && apt-get autoremove -y \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* \ No newline at end of file diff --git a/zephyr/Dockerfile b/zephyr/Dockerfile index ab590f1..7c29403 100644 --- a/zephyr/Dockerfile +++ b/zephyr/Dockerfile @@ -1,3 +1,4 @@ +# syntax=docker/dockerfile:1.7 ARG ZEPHYR_SDK_VERSION=1.0.0 ARG ZEPHYR_SDK_INSTALL_DIR=/opt/toolchains/zephyr-sdk-${ZEPHYR_SDK_VERSION} ARG ZEPHYR_SDK_TOOLCHAINS="-t arm-zephyr-eabi" @@ -10,7 +11,8 @@ FROM ${BASE_IMAGE} ARG ZEPHYR_SDK_INSTALL_DIR ARG ZEPHYR_SDK_TOOLCHAINS -RUN \ +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt/lists,sharing=locked \ apt-get -y update \ && apt-get -y install --no-install-recommends \ xz-utils \ @@ -19,5 +21,6 @@ RUN \ && apt-get remove -y --purge \ wget \ xz-utils \ + && apt-get autoremove -y \ && apt-get clean \ && rm -rf /var/lib/apt/lists/*