diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0230516..d2f32a8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -48,6 +48,10 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - + name: Set up containerd + uses: crazy-max/ghaction-setup-containerd@v2 + - id: image_env run: | @@ -58,6 +62,7 @@ jobs: '${{ matrix.repository }}' docker pull "${SOURCE_IMAGE}" || true + echo "IMAGE_HOME=$(mktemp -d)" >> "$GITHUB_OUTPUT" echo ALPINE_VERSION="${ALPINE_VERSION}" >> "$GITHUB_OUTPUT" echo PYTHON_VERSION="${PYTHON_VERSION}" >> "$GITHUB_OUTPUT" @@ -78,7 +83,10 @@ jobs: context: "." file: Dockerfile.alpine target: buildroot + cache-to: | + type=gha cache-from: | + type=gha type=registry,ref=${{ steps.image_env.outputs.IMAGE_TAG }}-buildroot type=registry,ref=${{ steps.image_env.outputs.SOURCE_IMAGE }}@${{ steps.image_env.outputs.BASE_IMAGE_DIGEST }} build-args: | @@ -88,6 +96,7 @@ jobs: SOURCE_IMAGE=${{ steps.image_env.outputs.SOURCE_IMAGE }} BUILD_ROOT=/d tags: "${{ steps.image_env.outputs.IMAGE_TAG }}-buildroot" + outputs: type=oci,dest=${{ steps.image_env.outputs.IMAGE_HOME }}/buildroot.tar - name: distroless uses: docker/build-push-action@v6 @@ -100,9 +109,12 @@ jobs: file: Dockerfile.alpine # target: distroless-python cache-from: | + type=gha type=registry,ref=${{ steps.image_env.outputs.IMAGE_TAG }} type=registry,ref=${{ steps.image_env.outputs.IMAGE_TAG }}-buildroot type=registry,ref=${{ steps.image_env.outputs.SOURCE_IMAGE }}@${{ steps.image_env.outputs.BASE_IMAGE_DIGEST }} + cache-to: | + type=gha build-args: | ALPINE_VERSION=${{ steps.image_env.outputs.ALPINE_VERSION }} BASE_IMAGE_DIGEST=${{ steps.image_env.outputs.BASE_IMAGE_DIGEST }} @@ -110,6 +122,14 @@ jobs: SOURCE_IMAGE=${{ steps.image_env.outputs.SOURCE_IMAGE }} BUILD_ROOT=/d tags: "${{ steps.image_env.outputs.IMAGE_TAG }}" + outputs: type=oci,dest=${{ steps.image_env.outputs.IMAGE_HOME }}/image.tar + + - + name: Import image in containerd + run: | + sudo apt-get -y install skopeo + skopeo copy 'oci-archive:${{ steps.image_env.outputs.IMAGE_HOME }}/buildroot.tar' 'docker://${{ steps.image_env.outputs.IMAGE_TAG }}-buildroot' + skopeo copy 'oci-archive:${{ steps.image_env.outputs.IMAGE_HOME }}/image.tar' 'docker://${{ steps.image_env.outputs.IMAGE_TAG }}' - name: examples/simple-flask @@ -121,12 +141,19 @@ jobs: linux/arm64/v7 linux/arm64/v8 cache-from: | + type=gha type=registry,ref=${{ steps.image_env.outputs.IMAGE_TAG }} type=registry,ref=${{ steps.image_env.outputs.IMAGE_TAG }}-buildroot type=registry,ref=${{ steps.image_env.outputs.SOURCE_IMAGE }}@${{ steps.image_env.outputs.BASE_IMAGE_DIGEST }} build-args: | SOURCE_IMAGE=${{ steps.image_env.outputs.IMAGE_TAG }} tags: "${{ steps.image_env.outputs.IMAGE_TAG }}-example1-amd64" + outputs: type=oci,dest=${{ steps.image_env.outputs.IMAGE_HOME }}/example1.tar + + - + name: Import image in containerd + run: | + sudo ctr images import --base-name '${{ steps.image_env.outputs.IMAGE_TAG }}-example1-amd64' --digests --all-platforms '${{ steps.image_env.outputs.IMAGE_HOME }}/example1.tar' - name: Login to GitHub Container Registry @@ -157,7 +184,10 @@ jobs: context: "." file: Dockerfile.alpine target: buildroot + cache-to: | + type=gha cache-from: | + type=gha type=registry,ref=${{ steps.image_env.outputs.IMAGE_TAG }}-buildroot type=registry,ref=${{ steps.image_env.outputs.SOURCE_IMAGE }}@${{ steps.image_env.outputs.BASE_IMAGE_DIGEST }} build-args: | @@ -180,7 +210,10 @@ jobs: linux/arm64/v7 linux/arm64/v8 file: Dockerfile.alpine + cache-to: | + type=gha cache-from: | + type=gha type=registry,ref=${{ steps.image_env.outputs.IMAGE_TAG }} type=registry,ref=${{ steps.image_env.outputs.IMAGE_TAG }}-buildroot type=registry,ref=${{ steps.image_env.outputs.SOURCE_IMAGE }}@${{ steps.image_env.outputs.BASE_IMAGE_DIGEST }}