Skip to content

Commit

Permalink
Merge pull request #8 from WyriHaximus/multiple-docker-files
Browse files Browse the repository at this point in the history
Support multiple Dockerfiles
  • Loading branch information
WyriHaximus authored Dec 20, 2024
2 parents b1a46b8 + 5956204 commit d0c23ea
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
21 changes: 21 additions & 0 deletions tests/Dockerfile-nodejs
Original file line number Diff line number Diff line change
@@ -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"]
24 changes: 24 additions & 0 deletions tests/Dockerfile-reactphp
Original file line number Diff line number Diff line change
@@ -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"]

0 comments on commit d0c23ea

Please sign in to comment.