-
-
Notifications
You must be signed in to change notification settings - Fork 301
build .rpm and .deb packages to automatically install and configure frankenphp #1497
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
base: main
Are you sure you want to change the base?
Conversation
even better, once crazywhalecc/static-php-cli#673 is merged, we can --build-shared=xdebug in the glibc command and automatically release Still need to think about how to appropriately handle this in CI though, I'm not sure if FRANKENPHP_VERSION is automatically set as an environment variable, or if the build-static script sets it. Could change the build-static script to export the version and call |
now I'm getting a weird bug where the worker keeps counting $i up twice instead of once. Other than that, it's working well I think. |
success! to get them from the container after building we can run docker run --rm static-builder-gnu sh -c "ls /go/src/app/dist | grep '^frankenphp'" | xargs -I {} sh -c 'docker cp $(docker create static-builder-gnu):/go/src/app/dist/{} ./{}' |
@dunglas I'm happy with this now. Prepared things for when we merge shared extension support into static-php-cli as well. The reason I haven't added a .apk is that alpine doesn't even ship with an init system by default (OpenRC is only included in the full blown desktop version), so I felt it made no sense to write a package that adds no real benefits to a simple binary download. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is AWESOME.
I left some minor comments. I also think we should ensure that the experience is as similar as possible between the Docker images, the Brew package and the Linux packages (demo files, php.ini
, Caddyfile
etc) to simply the maintenance and support.
package/Caddyfile
Outdated
@@ -0,0 +1,53 @@ | |||
# The Caddyfile is an easy way to configure your Caddy web server. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be nice to use the same Caddyfile in every distributions, with the same features enabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it makes sense to enable a worker by default in the docker Caddyfile. There's no example project (and it makes no sense to ship one either).
package/content/example.php
Outdated
@@ -0,0 +1,140 @@ | |||
<?php |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we reduce or remove the provided demo files?
Could we also share them between the Docker images and the packages?
@ginifizz will take a look to the graphic design part.
package/content/example.php
Outdated
@@ -0,0 +1,140 @@ | |||
<?php |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we reduce or remove the provided demo files?
Could we also share them between the Docker images and the packages?
@ginifizz will take a look to the graphic design part.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes we could, but my reasoning behind spinning up this small example is that one of the major advantages has is the easy integration of worker mode. Simply using php_server could as well be replaced by php_fastcgi.
We could unify the index.php and example.php files into one, but it would make for a messy html + php blob. It also showcases the best practise of serving php with an entry point in a subfolder, rather than (potentially) exposing the whole project.
I'll leave this up to you to decide, I just thought simply serving a static html file was a bit pointless.
As for the docker images, I'll have to look how to add files to them.
I had to switch to a frankenphp user, uninstalling frankenphp or caddy would automatically remove the other's user otherwise. |
fi | ||
fi | ||
|
||
HOME=~frankenphp frankenphp trust |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have the faintest idea how caddy works around not having to do this. Or maybe they do and I simply cannot find it in the install scripts.
We've merged dynamic extension support into static-php-cli, by the way. Should I put that into this PR and also build a frankenphp-xdebug package that depends on the frankenphp package? For that, I actually have a question - is it possible to load php with and without xdebug and route the request depending on whether a XDEBUG_SESSION header is set? Right now I check for (pseudocode, can't check atm) route {
@xdebug header *XDEBUG_SESSION*
php_fastcgi @xdebug /path/to/www.sock
php
} where php_fpm has xdebug loaded and frankenphp doesn't. Edit: I think frankenphp-xdebug would be a thing for another PR. Let's get regular frankenphp packages merged first. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks almost good to me, but I'm far from being a specialist of packaging.
We'll have to setup package repositories after that, right?
fi | ||
|
||
mkdir -p package/empty | ||
[ -f ./dist/static-php-cli/source/php-src/php.ini-production ] && cp -f ./dist/static-php-cli/source/php-src/php.ini-production ./package/etc/php.ini |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we also copy php.ini-development
? What php.ini
are using the official packages by default? Maybe should we be in sync with their behaviors?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What php.ini are using the official packages by default? Maybe should we be in sync with their behaviors?
Now here's the kicker, they don't ship the php.ini-production or php.ini-development but create the php.ini file that I initially committed into the package folder.
@@ -0,0 +1,14 @@ | |||
<?php |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
static-builder-gnu.Dockerfile
Outdated
@@ -115,12 +117,27 @@ ENV SPC_LIBC='glibc' | |||
ENV SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS_PROGRAM='-Wl,-O3 -pie' | |||
ENV SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS='-ldl -lpthread -lm -lresolv -lutil -lrt' | |||
ENV SPC_OPT_DOWNLOAD_ARGS='--ignore-cache-sources=php-src' | |||
ENV SPC_OPT_BUILD_ARGS='' | |||
ENV SPC_OPT_BUILD_ARGS='--with-config-file-path=/etc/frankenphp/php.ini --with-config-file-scan-dir=/etc/frankenphp/php.d' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need to change the defaults? If so, we'll have to update the docs too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default for php is /etc/php.ini
and /etc/php.d
or /etc/php/conf.d
depending on the distro. I doubt we wish to use those directories as we'd couple our frankenphp changes to those of the system php package. There are too many reasons why this is a terrible idea.
When compiling php without --with-config-file-path
it chooses /usr/local/etc/php/php.ini
and a different additional path depending on the system it was compiled on. That default is not in line with any system installation you would expect from a rpm/deb package. My only other idea for this was /etc/frankenphp.ini
and /etc/frankenphp.d
, but that would suggest frankenphp is something different than php, which it isn't.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To expand on this, /usr/local/etc/
is the folder for user, not system installations of self-compiled software. FrankenPHP installed from a package should definitely not reside there - what if the user compiles and installs php themselves? Suddenly our frankenphp package is broken.
…ng three empty local directories
Not necessarily.
Alternatively we could follow caddy's approach on distros where other package repositories do not have a caddy package and create our own package registry. Then people would have to |
commit suggested changes to preinstall/postinstall scripts Co-authored-by: Kévin Dunglas <[email protected]>
Co-authored-by: Kévin Dunglas <[email protected]>
I've tried to unify the php paths from the docker images and the static binaries/system installations, but that throws up more problems than it solves. php from the docker images is inherently not built by us and uses all sorts of directories that are different from the ones we (should) use for the static versions. |
As for the default project installed into I think it's easier if you make the changes yourself. You have push access to the branch of this pr. |
see #1459
requires fpm but it works perfectly well to automatically configure frankenphp
we could let this script run in the centos 7 container on deployment.