frankenphp icon indicating copy to clipboard operation
frankenphp copied to clipboard

WiP: One Dockerfile to rule them all

Open back-2-95 opened this issue 3 years ago • 14 comments

  • 2 distros: bullseye and alpine 3.16
  • One multistage Dockerfile
  • Bake definition file updated for ^^ + changed targets to be named with PHP minor versions
  • .dockerignore file updated
  • Some comments added to Dockerfile

TODO

  • Create GHA workflow with bake

Notes

  • in Dockerfile you cannot use dots in AS names. E.g. alpine3.16 - use need to name like alpine316
  • Additional PHP minor versions could be added to docker-bake.hcl when needed

Testing

Show what is about to go down:

docker buildx bake -f docker-bake.hcl --print

Build all images locally for arm64 arch (with --load and --set "*.platform=linux/arm64" flags):

docker buildx bake -f docker-bake.hcl --pull --load --set "*.platform=linux/arm64"

Same as previous but build only 1 target from docker-bake.hcl:

docker buildx bake -f docker-bake.hcl --pull --load --set "*.platform=linux/arm64" bullseye

Build locally and override image name:

IMAGE_NAME=my/frankenphp docker buildx bake -f docker-bake.hcl --pull --load --set "*.platform=linux/arm64" --progress plain

Build and push all images with override image name (needs you logged in to Docker Hub or some other registry):

IMAGE_NAME=my/frankenphp docker buildx bake -f docker-bake.hcl --pull --push

back-2-95 avatar Oct 24 '22 06:10 back-2-95

I got all 4 variants build with docker buildx bake... but buster variant:

docker run --rm --name frankenphp-demo \
    -e FRANKENPHP_CONFIG="worker ./public/index.php" \
    -e APP_RUNTIME=Runtime\\FrankenPhpSymfony\\Runtime \
    -v $PWD:/app \
    -p 80:80 -p 443:443 \
    dunglas/frankenphp:buster

...fails with following error:

frankenphp: error while loading shared libraries: libphp.so: cannot open shared object file: No such file or directory

@dunglas do you have any idea before I go through the rabbit hole?

back-2-95 avatar Oct 25 '22 07:10 back-2-95

@withinboredom WDYT about this one?

dunglas avatar Oct 26 '22 21:10 dunglas

@dunglas, if #48 is correct, my gut feeling is to wait for the next RC cut from php-src (probably one more in the next week or two before the actual release later next month -- 24 November) and rip out all the custom PHP build. I think this is a good idea, but maybe wait a bit before optimizing the Dockerfile?

withinboredom avatar Oct 26 '22 22:10 withinboredom

I would also wait with this one. I'll keep it updated with main in a meanwhile.

About Debian Buster, I don't if that error ^^ above is gonna be fixed with new stuff from php-src. Build itself goes through but running the image fails.

And this one needs "bake" version of GHA workflow.

back-2-95 avatar Oct 27 '22 07:10 back-2-95

@back-2-95, tbh, I wouldn't worry about a buster version.

Build itself goes through but running the image fails.

Despite regular updates (mostly security related), most of the code/libraries in that image is written for a pretty old kernel version. Linux isn't exactly known for a stable ABI... so all kinds of exciting things might break when running that image on a newer kernel via Docker. It still might be a good idea to build it for people running older kernels, but I feel that if you're willing to run FrankenPHP, you're probably not running an older kernel.

withinboredom avatar Oct 27 '22 07:10 withinboredom

@withinboredom I'm more than willing to cut out older stuff but I was in an impression that we should/could/would support the same distros as the main php docker library? @dunglas ?

back-2-95 avatar Oct 27 '22 07:10 back-2-95

As FrankenPHP is still very experimental stuff, I'm also in favor of not supporting older distros.

dunglas avatar Oct 27 '22 07:10 dunglas

Maybe cutting out Buster and Alpine3.15 then?

back-2-95 avatar Oct 27 '22 07:10 back-2-95

Oh The next release will be the fifth release candidate (RC 5), planned for 27 October 2022. - that's today

back-2-95 avatar Oct 27 '22 11:10 back-2-95

@dunglas & @withinboredom this is now with RC5 and buster+alpine3.15 commented out from bake definition (they still can be build but not by default)

back-2-95 avatar Oct 28 '22 04:10 back-2-95

Excellent! ! I will check your PR more closely. I may suggest some changes since https://github.com/docker-library/php/pull/1331 hasn't been merged yet, so we will still need to rebuild PHP, but it will be far more straightforward than what exists currently.

withinboredom avatar Oct 28 '22 06:10 withinboredom

Possible GHA action to use: https://github.com/docker/bake-action

I know @crazy-max has done lots of bake stuff so might be worth trying.

back-2-95 avatar Oct 28 '22 16:10 back-2-95

Have not been able to continue this. I have been sick the whole week and still going on... 🤧

back-2-95 avatar Nov 05 '22 08:11 back-2-95

I'm gonna wait for the time we can ditch the build phase until updating this PR. I was also thinking about just creating a test repo to test bake build/push with Github Actions.

back-2-95 avatar Nov 07 '22 07:11 back-2-95

Superseded by https://github.com/dunglas/frankenphp/pull/133

back-2-95 avatar Jan 14 '23 16:01 back-2-95