Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend Container build to support multiple PHP version #113

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,15 @@ jobs:
strategy:
matrix:
dockerfile: [ "Dockerfile", "Dockerfile.alpine" ]
php-version:
- 8.2
include:
- dockerfile: Dockerfile
flavor: ""
- dockerfile: Dockerfile.alpine
flavor: "-alpine"
- php-version: 8.2
base-image-tag: 8.2.0RC6-zts
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -69,7 +73,7 @@ jobs:
# list of Docker images to use as base name for tags
images: ${{secrets.IMAGE_NAME}}
flavor: |
suffix=${{matrix.flavor}}
suffix=${{matrix.php-version}}-${{matrix.flavor}}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should also add this to the test workflow as well so we can see what the output is when it builds this PR. I'm not 100% sure, but I believe this change would prevent latest from being updated.

# generate Docker tags based on the following events/attributes
tags: |
type=schedule
Expand Down Expand Up @@ -104,3 +108,4 @@ jobs:
builder: ${{ steps.buildx.outputs.name }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: 'php_base_tag=${{ matrix.base-image-tag }}'
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM php:8.2.0RC6-zts-bullseye AS builder
ARG php_base_tag=8.2.0RC6-zts

FROM php:${php_base_tag}-bullseye AS builder

COPY --from=golang:bullseye /usr/local/go/bin/go /usr/local/bin/go
COPY --from=golang:bullseye /usr/local/go /usr/local/go
Expand Down Expand Up @@ -45,7 +47,7 @@ RUN cd caddy/frankenphp && \

ENTRYPOINT ["/bin/bash","-c"]

FROM php:8.2.0RC6-zts-bullseye AS final
FROM php:${php_base_tag}-bullseye AS final
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using build-args, we should perhaps move the Dockerfiles into a dedicated directory /dockerfiles/8.2/Dockerfile, etc.

If we need to go back to manually building PHP again for some reason, it would be nice if that didn't affect every single PHP version and it may be further complicated if the build steps are different between PHP versions. FWIW, it's likely to be somewhat different for PHP 8.3 due to some changes in Fibers (new build switches), at least for x86.

I think this would also simplify the matrix somewhat.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe should we use the same templating system as official images?

Copy link
Owner

@dunglas dunglas Nov 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/

Expand Down
6 changes: 4 additions & 2 deletions Dockerfile.alpine
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM php:8.2.0RC6-zts-alpine3.16 AS builder
ARG php_base_tag=8.2.0RC6-zts

FROM php:${php_base_tag}-alpine3.16 AS builder

COPY --from=golang:alpine3.16 /usr/local/go/bin/go /usr/local/bin/go
COPY --from=golang:alpine3.16 /usr/local/go /usr/local/go
Expand Down Expand Up @@ -44,7 +46,7 @@ RUN cd caddy/frankenphp && \

ENTRYPOINT ["/bin/sh","-c"]

FROM php:8.2.0RC6-zts-alpine3.16 AS final
FROM php:${php_base_tag}-alpine3.16 AS final

COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/

Expand Down