Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

fix(assets): Ensure apache2/fpm running as PID 1 #536

Merged
merged 1 commit into from
Aug 29, 2023
Merged
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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ ENV GROUP_ID=

VOLUME [ "/opt/kimai/var" ]

ENTRYPOINT /startup.sh
CMD [ "/startup.sh" ]



Expand Down
3 changes: 1 addition & 2 deletions assets/service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function runServer() {
/opt/kimai/bin/console kimai:reload --env="$APP_ENV"
chown -R $USER_ID:$GROUP_ID /opt/kimai/var
if [ -e /use_apache ]; then
/usr/sbin/apache2ctl -D FOREGROUND
exec /usr/sbin/apache2 -D FOREGROUND
elif [ -e /use_fpm ]; then
exec php-fpm
else
Expand All @@ -59,4 +59,3 @@ function runServer() {
waitForDB
handleStartup
runServer
exit
13 changes: 8 additions & 5 deletions assets/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,14 @@ function handleStartup() {
fi

if [ -e /use_apache ]; then
echo "APACHE_RUN_USER=$(id -nu "$USER_ID")" >> /etc/apache2/envvars
export APACHE_RUN_USER=$(id -nu "$USER_ID")
# This doesn't _exactly_ run as the specified GID, it runs as the GID of the specified user but WTF
echo "APACHE_RUN_GROUP=$(id -ng "$USER_ID")" >> /etc/apache2/envvars
tail -n2 /etc/apache2/envvars
export APACHE_RUN_GROUP=$(id -ng "$USER_ID")
export APACHE_PID_FILE=/var/run/apache2/apache2.pid
export APACHE_RUN_DIR=/var/run/apache2
export APACHE_LOCK_DIR=/var/lock/apache2
export APACHE_LOG_DIR=/var/log/apache2
export LANG=C
elif [ -e /use_fpm ]; then
sed -i "s/user = .*/user = $USER_ID/g" /usr/local/etc/php-fpm.d/www.conf
sed -i "s/group = .*/group = $GROUP_ID/g" /usr/local/etc/php-fpm.d/www.conf
Expand All @@ -96,5 +100,4 @@ function handleStartup() {
config
handleStartup

/service.sh
exit
exec /service.sh