From d8a138cd641de8e8a5d7058d6a37c2d970a912fb Mon Sep 17 00:00:00 2001 From: Shin <2082119+shinsenter@users.noreply.github.com> Date: Wed, 14 Aug 2024 07:27:48 +0900 Subject: [PATCH] Simplify Dockerfile (#960) * Simplify Dockerfile * Update test-dockerfile.yml --- .github/workflows/test-dockerfile.yml | 9 +++++++-- Dockerfile | 11 +++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test-dockerfile.yml b/.github/workflows/test-dockerfile.yml index 31c71a6..59fb05e 100644 --- a/.github/workflows/test-dockerfile.yml +++ b/.github/workflows/test-dockerfile.yml @@ -22,11 +22,16 @@ jobs: run: docker save --output /tmp/image.tar test:latest - name: Extract layer - run: tar -C /tmp -x -f /tmp/image.tar --wildcards '*layer.tar' --strip-components=1 + run: | + tar -C /tmp -x -f /tmp/image.tar --strip-components=1 + if [ ! -d /tmp/sha256 ]; then + echo 'Cannot extract docker archive.' + exit 1 + fi - name: Check layer contents run: | - ENTRY="$(tar -v -t -f /tmp/layer.tar --wildcards '*bin/install-php-extensions')" + ENTRY="$(find /tmp/sha256 -type f -exec tar -vtf {} \; 2>/dev/null | grep install-php-extensions)" if [ -z "$ENTRY" ]; then echo 'File not found' exit 1 diff --git a/Dockerfile b/Dockerfile index 0cbb001..ae089a8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,6 @@ -FROM bash AS build - -COPY install-php-extensions /tmp/install-php-extensions -RUN chmod +x /tmp/install-php-extensions - FROM scratch -LABEL org.opencontainers.image.source="https://github.com/mlocati/docker-php-extension-installer" \ - org.opencontainers.image.licenses="MIT" +LABEL org.opencontainers.image.source="https://github.com/mlocati/docker-php-extension-installer" +LABEL org.opencontainers.image.licenses="MIT" -COPY --from=build /tmp/install-php-extensions /usr/bin/install-php-extensions +COPY --chmod=755 install-php-extensions /usr/bin/install-php-extensions