-
Notifications
You must be signed in to change notification settings - Fork 445
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
Merged
Merged
Changes from all commits
Commits
Show all changes
79 commits
Select commit
Hold shift + click to select a range
ea01871
add ./create-rpm.sh file to build a "frankenphp" rpm package
henderkes a2d3ccd
also build a deb package
henderkes 03da93f
renamed to build-packages
henderkes bee13b7
linter...
henderkes 915ef7e
add depends
henderkes cfdd244
linter again?
henderkes 687cee1
linter number 3
henderkes 152a218
linter number 4
henderkes f65a939
set default locations for ini file, conf files and extensions
henderkes 6bcb790
set unified path for modules that should be ok on all dists
henderkes 496dd70
add default content into "package" folder
henderkes baddcf1
make file executable
henderkes 55141ae
worker is in public folder
henderkes 391f759
what on earth did I do x)
henderkes 0fc0ec8
use same FRANKENPHP_VERSION and make sure to let pr's run the rpm gen…
henderkes 0ded8dc
install ruby, fpm and rpm-build
henderkes 3a0593d
move to after changing base urls because it would fail with packages …
henderkes 1999713
ruby 3 build needs gcc 10
henderkes 8616e69
rpm-build is necessary too...
henderkes dcfb09b
and I forgot to link the package folder
henderkes c241248
create directories if they don't exist
henderkes 6daaacd
copy out all frankenphp* files?
henderkes bd87a12
lint fix
henderkes 6076224
only copy frankenphp-* files
henderkes 5405dce
only copy frankenphp-* files
henderkes e97e429
the .deb file is name frankenphp_1.5.0... - create output folder inst…
henderkes 2fc0a29
update the last two steps to use the gh-output directory
henderkes a363a8b
add post install script to set frankenphp able to bind to port 80 for…
henderkes 9c3554a
dnf over yum, I think the yum alias was removed in RH 9.5
henderkes d945be2
newlines
henderkes 2877985
newlines
henderkes 50f98a9
add text what missing libcap means
henderkes 8b5af4a
copy php.ini-production from php-src, linter, update ruby version
henderkes 0a7df35
move Caddyfile to /etc/frankenphp/Caddyfile
henderkes b5853ff
linter
henderkes 69831c5
fix a copy and paste error
henderkes ddf325a
better describe fallback to 0.0.0
henderkes 2d10fa9
linter
henderkes 2b774cd
copy installation scripts from official caddy packages, change user t…
henderkes e952a9f
bombombom
henderkes 733f890
make files executable
henderkes 29049b1
tabs
henderkes ea0b7c4
linter
henderkes a12ba62
linter again
henderkes c1bcd7c
use empty directory for three different destinations instead of keepi…
henderkes ae8fc10
caddy says the file is incorrectly formatted without these spaces
henderkes 9de7bb3
remove wildcard matcher from root directive
henderkes 3f9388e
Apply suggestions from code review
henderkes c752d7c
Update dev.Dockerfile
henderkes e82a43c
remove misleading comment
henderkes fd2c4c0
update documentation for paths
henderkes 115d4a6
update documentation for paths some more
henderkes d663244
fix musl opcache-jit issue
henderkes 5e7c217
markdown linter
henderkes d0b8338
the damn tab
henderkes acf8365
Merge remote-tracking branch 'dunglas/main' into rpm
henderkes 7b7a63f
Apply suggestions from code review
henderkes e1de7b4
drop dev.Dockerfile php location from config.md
henderkes 19daf64
add php config note to CONTRIBUTING.md
henderkes 807bc0a
dashes instead of asterisks in chinese docs
henderkes c3f432c
fix package building
henderkes 3818289
create frankenphp user in case it doesn't exist for deb packages
henderkes ad59c26
create users if they don't exist, delete them again if they didn't exist
henderkes a41b9d4
satisfy linter
henderkes 1b6ac7f
create the user with the same commands as the postinst/preinstall scr…
henderkes a08911a
Removes toolchain requirements.
AlliBalliBaba e68fcea
trigger
AlliBalliBaba 599c5f8
Removes explicit calls to go get
AlliBalliBaba b840aa1
trigger
AlliBalliBaba fe951ed
setcap by default
henderkes a6c0f74
Merge remote-tracking branch 'dunglas/main' into rpm
henderkes ee90bca
simplify example project
henderkes 73581c7
bring page more in line with the caddy / apache / nginx default page
henderkes 6e20fa4
update to html 5
henderkes 21b3c15
Merge remote-tracking branch 'dunglas/fix/removes-toolchain-reqs' int…
henderkes 6a80939
oopsies
henderkes 6a6f31d
revert style to original
henderkes 5161021
remove https:// (caddy uses http:// on RHEL, :80 on Debian)
henderkes d76b6e0
Merge remote-tracking branch 'dunglas/main' into rpm
henderkes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,4 +8,5 @@ | |
| __debug_bin | ||
| frankenphp.test | ||
| caddy/frankenphp/Build | ||
| package/etc/php.ini | ||
| *.log | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,135 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -o errexit | ||
| set -x | ||
|
|
||
| # Ensure required tools are installed | ||
| if ! command -v rpmbuild &>/dev/null; then | ||
| echo "Error: rpm-build is required to create RPM packages." | ||
| echo "Install it with: sudo dnf install rpm-build" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if ! command -v ruby &>/dev/null; then | ||
| echo "Error: Ruby is required by FPM." | ||
| echo "Install it with: sudo dnf install ruby" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if ! command -v fpm &>/dev/null; then | ||
| echo "Error: FPM (rubygem-fpm) is required to create RPM packages." | ||
| echo "Install it with: sudo gem install fpm" | ||
| exit 1 | ||
| fi | ||
|
|
||
| arch="$(uname -m)" | ||
| os="$(uname -s | tr '[:upper:]' '[:lower:]')" | ||
| bin="frankenphp-${os}-${arch}" | ||
|
|
||
| if [ ! -f "dist/$bin" ]; then | ||
| echo "Error: dist/$bin not found. Run './build-static.sh' first" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ -z "${FRANKENPHP_VERSION}" ]; then | ||
| FRANKENPHP_VERSION="$(git rev-parse --verify HEAD)" | ||
| export FRANKENPHP_VERSION | ||
| elif [ -d ".git/" ]; then | ||
| CURRENT_REF="$(git rev-parse --abbrev-ref HEAD)" | ||
| export CURRENT_REF | ||
|
|
||
| if echo "${FRANKENPHP_VERSION}" | grep -F -q "."; then | ||
| # Tag | ||
|
|
||
| # Trim "v" prefix if any | ||
| FRANKENPHP_VERSION=${FRANKENPHP_VERSION#v} | ||
| export FRANKENPHP_VERSION | ||
|
|
||
| git checkout "v${FRANKENPHP_VERSION}" | ||
| else | ||
| git checkout "${FRANKENPHP_VERSION}" | ||
| fi | ||
| fi | ||
|
|
||
| if [[ ! "${FRANKENPHP_VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | ||
| echo "Warning: FRANKENPHP_VERSION must be set to X.Y.Z (e.g. 1.5.1), got '${FRANKENPHP_VERSION}'" | ||
| echo "Falling back to non-release version 0.0.0" | ||
| FRANKENPHP_VERSION=0.0.0 | ||
| fi | ||
|
|
||
| group_preexists=0 | ||
| user_preexists=0 | ||
|
|
||
| if getent group frankenphp >/dev/null; then | ||
| group_preexists=1 | ||
| else | ||
| groupadd --system frankenphp | ||
| fi | ||
|
|
||
| if getent passwd frankenphp >/dev/null; then | ||
| user_preexists=1 | ||
| else | ||
| useradd --system \ | ||
| --gid frankenphp \ | ||
| --create-home \ | ||
| --home-dir /var/lib/frankenphp \ | ||
| --shell /usr/sbin/nologin \ | ||
| --comment "FrankenPHP web server" \ | ||
| frankenphp | ||
| fi | ||
|
|
||
| mkdir -p package/empty | ||
| mkdir -p package/etc | ||
| [ -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 | ||
|
henderkes marked this conversation as resolved.
|
||
|
|
||
| cd dist | ||
| iteration=1 | ||
| glibc_version=$(ldd -v "$bin" | awk '/GLIBC_/ {gsub(/[()]/, "", $2); print $2}' | grep -v GLIBC_PRIVATE | sort -V | tail -n1) | ||
| cxxabi_version=$(strings "$bin" | grep -oP 'CXXABI_\d+\.\d+(\.\d+)?' | sort -V | tail -n1) | ||
|
|
||
| fpm -s dir -t rpm -n frankenphp -v "${FRANKENPHP_VERSION}" \ | ||
| --config-files /etc/frankenphp/Caddyfile \ | ||
| --config-files /etc/frankenphp/php.ini \ | ||
| --depends "libc.so.6(${glibc_version})(64bit)" \ | ||
| --depends "libstdc++.so.6(${cxxabi_version})(64bit)" \ | ||
| --before-install ../package/rhel/preinstall.sh \ | ||
| --after-install ../package/rhel/postinstall.sh \ | ||
| --before-remove ../package/rhel/preuninstall.sh \ | ||
| --after-remove ../package/rhel/postuninstall.sh \ | ||
| --iteration "${iteration}" \ | ||
| --rpm-user frankenphp --rpm-group frankenphp \ | ||
| "${bin}=/usr/bin/frankenphp" \ | ||
| "../package/rhel/frankenphp.service=/usr/lib/systemd/system/frankenphp.service" \ | ||
| "../package/Caddyfile=/etc/frankenphp/Caddyfile" \ | ||
| "../package/content/=/usr/share/frankenphp" \ | ||
| "../package/etc/php.ini=/etc/frankenphp/php.ini" \ | ||
| "../package/empty/=/etc/frankenphp/php.d" \ | ||
| "../package/empty/=/usr/lib/frankenphp/modules" \ | ||
| "../package/empty/=/var/lib/frankenphp" | ||
|
|
||
| glibc_version=$(ldd -v "$bin" | awk '/GLIBC_/ {gsub(/[()]/, "", $2); print $2}' | grep -v GLIBC_PRIVATE | sed 's/GLIBC_//' | sort -V | tail -n1) | ||
| cxxabi_version=$(strings "$bin" | grep -oP 'CXXABI_\d+\.\d+(\.\d+)?' | sed 's/CXXABI_//' | sort -V | tail -n1) | ||
|
|
||
| fpm -s dir -t deb -n frankenphp -v "${FRANKENPHP_VERSION}" \ | ||
| --config-files /etc/frankenphp/Caddyfile \ | ||
| --config-files /etc/frankenphp/php.ini \ | ||
| --depends "libc6 (>= ${glibc_version})" \ | ||
| --depends "libstdc++6 (>= ${cxxabi_version})" \ | ||
| --after-install ../package/debian/postinst.sh \ | ||
| --before-remove ../package/debian/prerm.sh \ | ||
| --after-remove ../package/debian/postrm.sh \ | ||
| --iteration "${iteration}" \ | ||
| --deb-user frankenphp --deb-group frankenphp \ | ||
| "${bin}=/usr/bin/frankenphp" \ | ||
| "../package/debian/frankenphp.service=/usr/lib/systemd/system/frankenphp.service" \ | ||
| "../package/Caddyfile=/etc/frankenphp/Caddyfile" \ | ||
| "../package/content/=/usr/share/frankenphp" \ | ||
| "../package/etc/php.ini=/etc/frankenphp/php.ini" \ | ||
| "../package/empty/=/etc/frankenphp/php.d" \ | ||
| "../package/empty/=/usr/lib/frankenphp/modules" \ | ||
| "../package/empty/=/var/lib/frankenphp" | ||
|
|
||
| [ "$user_preexists" -eq 0 ] && userdel frankenphp | ||
| [ "$group_preexists" -eq 0 ] && groupdel frankenphp | ||
|
|
||
| cd .. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
We should even error if the format isn't valid.
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.
Then the pull request CI wouldn't build packages and we might not realize when bugs are introduced.