Update PHP Version

This commit is contained in:
2024-01-06 15:22:20 +01:00
parent 76661a908a
commit 0d50d39002
11 changed files with 116 additions and 88 deletions

View File

@@ -11,6 +11,6 @@ then
docker build -f src/docker/${tag}/Dockerfile -t jkaninda/nginx-php-fpm:$tag . docker build -f src/docker/${tag}/Dockerfile -t jkaninda/nginx-php-fpm:$tag .
else else
echo 'Build latest' echo 'Build latest'
docker build -f src/docker/8.2/Dockerfile -t jkaninda/nginx-php-fpm:$tag . docker build -f src/docker/8.3/Dockerfile -t jkaninda/nginx-php-fpm:$tag .
fi fi

View File

@@ -5,8 +5,10 @@ ENV LARAVEL_PROCS_NUMBER=1
ENV DOMAIN=_ ENV DOMAIN=_
ENV CLIENT_MAX_BODY_SIZE=15M ENV CLIENT_MAX_BODY_SIZE=15M
ENV NODE_VERSION=17.x ENV NODE_VERSION=17.x
ARG HOST_UID=1000 ARG GROUP_ID=1000
ENV USER=www-data ARG USER_ID=1000
ENV USER_NAME=www-data
ARG GROUP_NAME=www-data
# Install system dependencies # Install system dependencies
RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \
git \ git \
@@ -80,10 +82,12 @@ ENTRYPOINT ["entrypoint.sh"]
RUN usermod -u ${HOST_UID} www-data RUN usermod -u ${USER_ID} ${USER_NAME}
RUN groupmod -g ${HOST_UID} www-data RUN groupmod -g ${USER_ID} ${GROUP_NAME}
RUN chown -R ${USER_NAME}:${GROUP_NAME} /var/www && \
RUN chmod -R 755 $WORKDIR chown -R ${USER_NAME}:${GROUP_NAME} /var/log/ && \
RUN chown -R www-data:www-data $WORKDIR chown -R ${USER_NAME}:${GROUP_NAME} /etc/supervisor/conf.d/ && \
EXPOSE 9000 80 chown -R ${USER_NAME}:${GROUP_NAME} $PHP_INI_DIR/conf.d/ && \
chown -R ${USER_NAME}:${GROUP_NAME} /etc/nginx/sites-available/
EXPOSE 80
CMD [ "entrypoint" ] CMD [ "entrypoint" ]

View File

@@ -5,8 +5,10 @@ ENV LARAVEL_PROCS_NUMBER=1
ENV DOMAIN=_ ENV DOMAIN=_
ENV CLIENT_MAX_BODY_SIZE=15M ENV CLIENT_MAX_BODY_SIZE=15M
ENV NODE_VERSION=17.x ENV NODE_VERSION=17.x
ARG HOST_UID=1000 ARG GROUP_ID=1000
ENV USER=www-data ARG USER_ID=1000
ENV USER_NAME=www-data
ARG GROUP_NAME=www-data
# Install system dependencies # Install system dependencies
RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \
git \ git \
@@ -80,11 +82,12 @@ RUN ln -s /usr/local/bin/entrypoint.sh /
ENTRYPOINT ["entrypoint.sh"] ENTRYPOINT ["entrypoint.sh"]
RUN usermod -u ${USER_ID} ${USER_NAME}
RUN usermod -u ${HOST_UID} www-data RUN groupmod -g ${USER_ID} ${GROUP_NAME}
RUN groupmod -g ${HOST_UID} www-data RUN chown -R ${USER_NAME}:${GROUP_NAME} /var/www && \
chown -R ${USER_NAME}:${GROUP_NAME} /var/log/ && \
RUN chmod -R 755 $WORKDIR chown -R ${USER_NAME}:${GROUP_NAME} /etc/supervisor/conf.d/ && \
RUN chown -R www-data:www-data $WORKDIR chown -R ${USER_NAME}:${GROUP_NAME} $PHP_INI_DIR/conf.d/ && \
EXPOSE 9000 80 chown -R ${USER_NAME}:${GROUP_NAME} /etc/nginx/sites-available/
EXPOSE 80
CMD [ "entrypoint" ] CMD [ "entrypoint" ]

View File

@@ -5,8 +5,10 @@ ENV LARAVEL_PROCS_NUMBER=1
ENV DOMAIN=_ ENV DOMAIN=_
ENV CLIENT_MAX_BODY_SIZE=15M ENV CLIENT_MAX_BODY_SIZE=15M
ENV NODE_VERSION=17.x ENV NODE_VERSION=17.x
ARG HOST_UID=1000 ARG GROUP_ID=1000
ENV USER=www-data ARG USER_ID=1000
ENV USER_NAME=www-data
ARG GROUP_NAME=www-data
# Install system dependencies # Install system dependencies
RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \
git \ git \
@@ -80,10 +82,12 @@ ENTRYPOINT ["entrypoint.sh"]
RUN usermod -u ${HOST_UID} www-data RUN usermod -u ${USER_ID} ${USER_NAME}
RUN groupmod -g ${HOST_UID} www-data RUN groupmod -g ${USER_ID} ${GROUP_NAME}
RUN chown -R ${USER_NAME}:${GROUP_NAME} /var/www && \
RUN chmod -R 755 $WORKDIR chown -R ${USER_NAME}:${GROUP_NAME} /var/log/ && \
RUN chown -R www-data:www-data $WORKDIR chown -R ${USER_NAME}:${GROUP_NAME} /etc/supervisor/conf.d/ && \
EXPOSE 9000 80 chown -R ${USER_NAME}:${GROUP_NAME} $PHP_INI_DIR/conf.d/ && \
chown -R ${USER_NAME}:${GROUP_NAME} /etc/nginx/sites-available/
EXPOSE 80
CMD [ "entrypoint" ] CMD [ "entrypoint" ]

View File

@@ -5,8 +5,10 @@ ENV LARAVEL_PROCS_NUMBER=1
ENV DOMAIN=_ ENV DOMAIN=_
ENV CLIENT_MAX_BODY_SIZE=15M ENV CLIENT_MAX_BODY_SIZE=15M
ENV NODE_VERSION=17.x ENV NODE_VERSION=17.x
ARG HOST_UID=1000 ARG GROUP_ID=1000
ENV USER=www-data ARG USER_ID=1000
ENV USER_NAME=www-data
ARG GROUP_NAME=www-data
# Install system dependencies # Install system dependencies
RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \
git \ git \
@@ -91,11 +93,12 @@ RUN ln -s /usr/local/bin/entrypoint.sh /
ENTRYPOINT ["entrypoint.sh"] ENTRYPOINT ["entrypoint.sh"]
RUN usermod -u ${USER_ID} ${USER_NAME}
RUN usermod -u ${HOST_UID} www-data RUN groupmod -g ${USER_ID} ${GROUP_NAME}
RUN groupmod -g ${HOST_UID} www-data RUN chown -R ${USER_NAME}:${GROUP_NAME} /var/www && \
chown -R ${USER_NAME}:${GROUP_NAME} /var/log/ && \
RUN chmod -R 755 $WORKDIR chown -R ${USER_NAME}:${GROUP_NAME} /etc/supervisor/conf.d/ && \
RUN chown -R www-data:www-data $WORKDIR chown -R ${USER_NAME}:${GROUP_NAME} $PHP_INI_DIR/conf.d/ && \
EXPOSE 9000 80 chown -R ${USER_NAME}:${GROUP_NAME} /etc/nginx/sites-available/
EXPOSE 80
CMD [ "entrypoint" ] CMD [ "entrypoint" ]

View File

@@ -5,8 +5,10 @@ ENV LARAVEL_PROCS_NUMBER=1
ENV DOMAIN=_ ENV DOMAIN=_
ENV CLIENT_MAX_BODY_SIZE=15M ENV CLIENT_MAX_BODY_SIZE=15M
ENV NODE_VERSION=17.x ENV NODE_VERSION=17.x
ARG HOST_UID=1000 ARG GROUP_ID=1000
ENV USER=www-data ARG USER_ID=1000
ENV USER_NAME=www-data
ARG GROUP_NAME=www-data
# Install system dependencies # Install system dependencies
RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \
git \ git \
@@ -91,13 +93,13 @@ RUN ln -s /usr/local/bin/entrypoint.sh /
ENTRYPOINT ["entrypoint.sh"] ENTRYPOINT ["entrypoint.sh"]
RUN usermod -u ${USER_ID} ${USER_NAME}
RUN groupmod -g ${USER_ID} ${GROUP_NAME}
RUN usermod -u ${HOST_UID} www-data RUN chown -R ${USER_NAME}:${GROUP_NAME} /var/www && \
RUN groupmod -g ${HOST_UID} www-data chown -R ${USER_NAME}:${GROUP_NAME} /var/log/ && \
chown -R ${USER_NAME}:${GROUP_NAME} /etc/supervisor/conf.d/ && \
RUN chmod -R 755 $WORKDIR chown -R ${USER_NAME}:${GROUP_NAME} $PHP_INI_DIR/conf.d/ && \
RUN chown -R www-data:www-data $WORKDIR chown -R ${USER_NAME}:${GROUP_NAME} /etc/nginx/sites-available/
EXPOSE 80 EXPOSE 80
CMD [ "entrypoint" ] CMD [ "entrypoint" ]

View File

@@ -5,8 +5,10 @@ ENV LARAVEL_PROCS_NUMBER=1
ENV DOMAIN=_ ENV DOMAIN=_
ENV CLIENT_MAX_BODY_SIZE=15M ENV CLIENT_MAX_BODY_SIZE=15M
ENV NODE_VERSION=17.x ENV NODE_VERSION=17.x
ARG HOST_UID=1000 ARG GROUP_ID=1000
ENV USER=www-data ARG USER_ID=1000
ENV USER_NAME=www-data
ARG GROUP_NAME=www-data
# Install system dependencies # Install system dependencies
RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \
git \ git \
@@ -93,11 +95,13 @@ ENTRYPOINT ["entrypoint.sh"]
RUN usermod -u ${HOST_UID} www-data RUN usermod -u ${USER_ID} ${USER_NAME}
RUN groupmod -g ${HOST_UID} www-data RUN groupmod -g ${USER_ID} ${GROUP_NAME}
RUN chown -R ${USER_NAME}:${GROUP_NAME} /var/www && \
RUN chmod -R 755 $WORKDIR chown -R ${USER_NAME}:${GROUP_NAME} /var/log/ && \
RUN chown -R www-data:www-data $WORKDIR chown -R ${USER_NAME}:${GROUP_NAME} /etc/supervisor/conf.d/ && \
chown -R ${USER_NAME}:${GROUP_NAME} $PHP_INI_DIR/conf.d/ && \
chown -R ${USER_NAME}:${GROUP_NAME} /etc/nginx/sites-available/
EXPOSE 80 EXPOSE 80
CMD [ "entrypoint" ] CMD [ "entrypoint" ]

View File

@@ -1,12 +1,14 @@
FROM php:8.3.0-fpm FROM php:8.3.1-fpm
ARG WORKDIR=/var/www/html ARG WORKDIR=/var/www/html
ENV DOCUMENT_ROOT=${WORKDIR} ENV DOCUMENT_ROOT=${WORKDIR}
ENV LARAVEL_PROCS_NUMBER=1 ENV LARAVEL_PROCS_NUMBER=1
ENV DOMAIN=_ ENV DOMAIN=_
ENV CLIENT_MAX_BODY_SIZE=15M ENV CLIENT_MAX_BODY_SIZE=15M
ENV NODE_VERSION=17.x ENV NODE_VERSION=17.x
ARG HOST_UID=1000 ARG GROUP_ID=1000
ENV USER=www-data ARG USER_ID=1000
ENV USER_NAME=www-data
ARG GROUP_NAME=www-data
# Install system dependencies # Install system dependencies
RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \
git \ git \
@@ -93,11 +95,14 @@ ENTRYPOINT ["entrypoint.sh"]
RUN usermod -u ${HOST_UID} www-data RUN usermod -u ${USER_ID} ${USER_NAME}
RUN groupmod -g ${HOST_UID} www-data RUN groupmod -g ${USER_ID} ${GROUP_NAME}
RUN chown -R ${USER_NAME}:${GROUP_NAME} /var/www && \
RUN chmod -R 755 $WORKDIR chown -R ${USER_NAME}:${GROUP_NAME} /var/log/ && \
RUN chown -R www-data:www-data $WORKDIR chown -R ${USER_NAME}:${GROUP_NAME} /etc/supervisor/conf.d/ && \
chown -R ${USER_NAME}:${GROUP_NAME} $PHP_INI_DIR/conf.d/ && \
chown -R ${USER_NAME}:${GROUP_NAME} /etc/nginx/sites-available/
#USER ${USER_NAME}
EXPOSE 80 EXPOSE 80
CMD [ "entrypoint" ] CMD [ "entrypoint" ]

View File

@@ -1,32 +1,41 @@
#!/bin/sh #!/bin/sh
Red='\033[0;31m' # Red
Green='\033[0;32m' # Green
echo "" echo ""
echo "***********************************************************" echo "***********************************************************"
echo " Starting NGINX PHP-FPM Docker Container " echo " Starting NGINX PHP-FPM Docker Container "
echo "***********************************************************" echo "***********************************************************"
set -e set -e
set -e
info() {
{ set +x; } 2> /dev/null
echo '[INFO] ' "$@"
}
warning() {
{ set +x; } 2> /dev/null
echo '[WARNING] ' "$@"
}
fatal() {
{ set +x; } 2> /dev/null
echo '[ERROR] ' "$@" >&2
exit 1
}
## Check if the artisan file exists ## Check if the artisan file exists
if [ -f /var/www/html/artisan ]; then if [ -f /var/www/html/artisan ]; then
echo "${Green} artisan file found, creating laravel supervisor config" info "Artisan file found, creating laravel supervisor config"
# Set DocumentRoot to the Laravel project directory # Set DocumentRoot to the Laravel project directory
export DOCUMENT_ROOT=/var/www/html/public export DOCUMENT_ROOT=/var/www/html/public
##Create Laravel Scheduler process ##Create Laravel Scheduler process
TASK=/etc/supervisor/conf.d/laravel-worker.conf TASK=/etc/supervisor/conf.d/laravel-worker.conf
touch $TASK touch $TASK
cat > "$TASK" <<EOF cat > "$TASK" <<EOF
[supervisord]
nodaemon=true
user=root
[program:Laravel-scheduler] [program:Laravel-scheduler]
process_name=%(program_name)s_%(process_num)02d process_name=%(program_name)s_%(process_num)02d
command=/bin/sh -c "while [ true ]; do (php /var/www/html/artisan schedule:run --verbose --no-interaction &); sleep 60; done" command=/bin/sh -c "while [ true ]; do (php /var/www/html/artisan schedule:run --verbose --no-interaction &); sleep 60; done"
autostart=true autostart=true
autorestart=true autorestart=true
numprocs=1 numprocs=1
user=www-data user=$USER_NAME
stdout_logfile=/var/log/laravel_scheduler.out.log stdout_logfile=/var/log/laravel_scheduler.out.log
redirect_stderr=true redirect_stderr=true
@@ -36,30 +45,30 @@ if [ -f /var/www/html/artisan ]; then
autostart=true autostart=true
autorestart=true autorestart=true
numprocs=$LARAVEL_PROCS_NUMBER numprocs=$LARAVEL_PROCS_NUMBER
user=www-data user=$USER_NAME
redirect_stderr=true redirect_stderr=true
stdout_logfile=/var/log/laravel_worker.log stdout_logfile=/var/log/laravel_worker.log
EOF EOF
echo "${Green} Laravel supervisor config created" info "Laravel supervisor config created"
else else
echo "${Red} artisan file not found" info "artisan file not found"
fi fi
# Enable custom nginx config files if they exist # Enable custom nginx config files if they exist
if [ -f /var/www/html/conf/nginx/nginx.conf ]; then if [ -f /var/www/html/conf/nginx/nginx.conf ]; then
cp /var/www/html/conf/nginx/nginx.conf /etc/nginx/nginx.conf cp /var/www/html/conf/nginx/nginx.conf /etc/nginx/nginx.conf
echo "Using custom nginx.conf" info "Using custom nginx.conf"
fi fi
if [ -f /var/www/html/conf/nginx/nginx-site.conf ]; then if [ -f /var/www/html/conf/nginx/nginx-site.conf ]; then
echo "Custom nginx site config found" info "Custom nginx site config found"
rm /etc/nginx/sites-available/default rm /etc/nginx/sites-available/default
cp /var/www/html/conf/nginx/nginx-site.conf /etc/nginx/sites-available/default cp /var/www/html/conf/nginx/nginx-site.conf /etc/nginx/sites-available/default
echo "${Green} Start nginx with custom server config..." info "Start nginx with custom server config..."
else else
echo "${Red} nginx-site.conf not found" info "Nginx-site.conf not found"
echo "${Green} If you want to use custom configs, create config file in /var/www/html/conf/nginx/nginx-site.conf" info "If you want to use custom configs, create config file in /var/www/html/conf/nginx/nginx-site.conf"
echo "${Green} Start nginx with default config..." info "Start nginx with default config..."
rm -f /etc/nginx/sites-available/default rm -f /etc/nginx/sites-available/default
TASK=/etc/nginx/sites-available/default TASK=/etc/nginx/sites-available/default
touch $TASK touch $TASK
@@ -115,19 +124,13 @@ EOF
fi fi
## Check if the supervisor config file exists ## Check if the supervisor config file exists
if [ -f /var/www/html/conf/worker/supervisor.conf ]; then if [ -f /var/www/html/conf/worker/supervisor.conf ]; then
echo "Custom supervisor config found" info "Custom supervisor config found"
cp /var/www/html/conf/worker/supervisor.conf /etc/supervisor/conf.d/supervisor.conf cp /var/www/html/conf/worker/supervisor.conf /etc/supervisor/conf.d/supervisor.conf
else else
echo "${Red} Supervisor.conf not found" info "Supervisor.conf not found"
echo "${Green} If you want to add more supervisor configs, create config file in /var/www/html/conf/worker/supervisor.conf" info "If you want to add more supervisor configs, create config file in /var/www/html/conf/worker/supervisor.conf"
echo "${Green} Start supervisor with default config..." info "Start supervisor with default config..."
fi fi
echo ""
echo "**********************************"
echo " Starting Supervisord... "
echo "***********************************"
supervisord -c /etc/supervisor/supervisord.conf supervisord -c /etc/supervisor/supervisord.conf

View File

@@ -13,7 +13,7 @@ autorestart=true
stderr_logfile=/var/log/php-fpm_consumer.err.log stderr_logfile=/var/log/php-fpm_consumer.err.log
stdout_logfile=/var/log/php-fpm_consumer.out.log stdout_logfile=/var/log/php-fpm_consumer.out.log
user=root user=root
priority=100 priority=1
[program:nginx] [program:nginx]
command=/usr/sbin/nginx -g "daemon off;" command=/usr/sbin/nginx -g "daemon off;"
@@ -23,7 +23,7 @@ autorestart=true
stderr_logfile=/var/log/nginx.err.log stderr_logfile=/var/log/nginx.err.log
stdout_logfile=/var/log/nginx.out.log stdout_logfile=/var/log/nginx.out.log
user=root user=root
priority=100 priority=2
[include] [include]
files = /etc/supervisor/conf.d/*.conf files = /etc/supervisor/conf.d/*.conf