feat(docker): add php-fpm and relative log files

This commit is contained in:
Michael 2025-02-13 12:50:01 +01:00
parent 703b69c4a8
commit d7574e2ada
1 changed files with 15 additions and 5 deletions

View File

@ -284,7 +284,7 @@ ENV LIBRETIME_VERSION=$LIBRETIME_VERSION
#======================================================================================#
# Use PHP as the base
FROM php:8.2-cli AS sintonia-webapp-base
FROM php:8.2-fpm AS sintonia-webapp-base
# Arguments defined in docker-compose-dev.yml
ARG sintonia_user=$SINTONIA_USER
@ -308,14 +308,15 @@ RUN set -eux && \
libpng-dev \
git \
libonig-dev \
libpq-dev
libpq-dev && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
RUN docker-php-ext-configure zip && \
docker-php-ext-configure gd --with-freetype --with-jpeg
RUN docker-php-ext-install gd exif pcntl bcmath mysqli pdo_mysql mbstring && \
docker-php-ext-install pdo_pgsql pgsql sockets && \
apt-get clean && rm -rf /var/lib/apt/lists/*
docker-php-ext-install pdo_pgsql pgsql sockets
# Create system user to run Composer and Artisan Commands
RUN set -eux && useradd -G www-data -u $sintonia_uid -d /home/$sintonia_user $sintonia_user && \
@ -345,6 +346,7 @@ ARG libretime_config_filepath=$LIBRETIME_CONFIG_FILEPATH
USER root
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install yq -y
RUN sed -i 's/listen = 127.0.0.1:9000/listen = nginx:9000/g' /usr/local/etc/php-fpm.d/www.conf
USER "$sintonia_user"
WORKDIR $HOME
@ -364,10 +366,18 @@ ENV sintonia_laravel_port=${sintonia_laravel_port}
ENV sintonia_vite_port=${sintonia_vite_port}
USER root
RUN pecl install xdebug && \
docker-php-ext-enable xdebug && \
echo 'xdebug.mode = develop,debug\nxdebug.client_host=host.docker.internal\nxdebug.start_with_request=yes\nxdebug.discover_client_host=1' >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \
echo 'error_reporting=E_ALL' > /usr/local/etc/php/conf.d/error_reporting.ini
RUN touch /usr/local/var/log/fpm-php.access.log /usr/local/var/log/fpm-php.error.log && \
chown $sintonia_user:$sintonia_user /usr/local/var/log/fpm-php.access.log /usr/local/var/log/fpm-php.error.log && \
chmod 660 /usr/local/var/log/fpm-php.access.log /usr/local/var/log/fpm-php.error.log && \
sed -i 's/access.log = \/proc\/self\/fd\/2/access.log = \/usr\/local\/var\/log\/fpm-php.access.log/g' /usr/local/etc/php-fpm.d/docker.conf && \
sed -i 's/error_log = \/proc\/self\/fd\/2/error_log = \/usr\/local\/var\/log\/fpm-php.error.log/g' /usr/local/etc/php-fpm.d/docker.conf
COPY ./dev/sintonia-webapp/php/php-ini-development /usr/local/etc/php/php.ini
USER $sintonia_user
@ -386,7 +396,7 @@ CMD git config --global --add safe.directory /var/www/sintonia_webapp && \
php artisan schedule:run >> /dev/null 2>&1 && \
set -eux && \
npm i && \
php artisan serve --host=0.0.0.0 --port=$sintonia_laravel_port & \
php-fpm -D && \
npx vite --port $sintonia_vite_port --host & \
sleep infinity