From 59562043569cdb5500c40f2c4fd2acd8edb56812 Mon Sep 17 00:00:00 2001 From: Cees-Jan Kiewiet Date: Fri, 20 Dec 2024 10:58:09 +0100 Subject: [PATCH] Support multiple Dockerfiles --- .github/workflows/ci.yml | 4 ++++ action.yaml | 4 ++-- tests/Dockerfile-nodejs | 21 +++++++++++++++++++++ tests/Dockerfile-reactphp | 24 ++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 tests/Dockerfile-nodejs create mode 100644 tests/Dockerfile-reactphp diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b1f8f18..982bc2e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,6 +29,10 @@ jobs: expected: '["linux/arm64","linux/amd64"]' with: image: ghcr.io/home-assistant/home-assistant:2024.12.2,ghcr.io/wyrihaximusnet/php:8.3-zts-alpine-dev + - name: Multiple Dockerfiles + expected: '["linux/amd64","linux/arm64"]' + with: + dockerfile: tests/Dockerfile* steps: - uses: actions/checkout@v4 - name: OCI Image Supported Platforms diff --git a/action.yaml b/action.yaml index 6491399..173cfd3 100644 --- a/action.yaml +++ b/action.yaml @@ -5,7 +5,7 @@ branding: color: 'blue' inputs: dockerfile: - description: The Dockerfile to get its supported platforms + description: The Dockerfile to get its supported platforms, support patterns that work in both git's sparse checkout and bash. (The pattern needs to work in both.) required: false default: 'Dockerfile' image: @@ -32,7 +32,7 @@ runs: if: inputs.image == '' shell: bash run: | - printf "from=%s" $(cat ${{ inputs.dockerfile }} | grep FROM | tail -n 1 | docker run -q -i --rm ghcr.io/wyrihaximusnet/php:8.3-nts-alpine-slim php -r 'echo explode(" ", trim(fgets(STDIN)))[1];') >> $GITHUB_OUTPUT + printf "from=%s" $(cat ${{ inputs.dockerfile }} | grep FROM | xargs -I % docker run -q -i --rm ghcr.io/wyrihaximusnet/php:8.3-nts-alpine-slim php -r 'echo explode(" ", trim("%"))[1], ",";' | head -c -1) >> $GITHUB_OUTPUT - name: Image 🧙 id: image shell: bash diff --git a/tests/Dockerfile-nodejs b/tests/Dockerfile-nodejs new file mode 100644 index 0000000..8859d11 --- /dev/null +++ b/tests/Dockerfile-nodejs @@ -0,0 +1,21 @@ +FROM node:22-alpine3.20 + +RUN set -x \ + && addgroup -g 666 app \ + && adduser -u 666 -D -G app app + +EXPOSE 7132 +EXPOSE 7133 + +RUN mkdir -p /opt/app +WORKDIR /opt/app + +COPY ./ /opt/app/ + +USER root +RUN chown app:app /opt/app/ -Rfv +USER app + +RUN npm install + +ENTRYPOINT ["node", "/opt/app/app.js"] diff --git a/tests/Dockerfile-reactphp b/tests/Dockerfile-reactphp new file mode 100644 index 0000000..04cac2a --- /dev/null +++ b/tests/Dockerfile-reactphp @@ -0,0 +1,24 @@ +FROM wyrihaximusnet/php:8.4-nts-alpine-slim-dev AS install-dependencies + +WORKDIR /opt/app +USER root +RUN mkdir /opt/app/vendor && chown app:app /opt/app -Rfv +USER app + +COPY ./composer.* /opt/app/ +RUN composer install --ansi --no-interaction --prefer-dist --no-dev -o + +FROM wyrihaximusnet/php:8.4-nts-alpine-slim + +EXPOSE 7132 +EXPOSE 7133 +WORKDIR /opt/app + +COPY ./ /opt/app/ +COPY --from=install-dependencies /opt/app/vendor/ /opt/app/vendor/ + +USER root +RUN chown app:app /opt/app/ -Rf +USER app + +ENTRYPOINT ["php", "/opt/app/app.php"]