Hi Chris, we have a working solution for our local development environment. We just tell Nginx and PHP-FPM to run as »chrisallen«. Below you can have a look at a simplified version of our Dockerfile.
# Define base imageFROM php:8.1-fpm-alpine# Define build argumentsARG USER_IDARG GROUP_ID# Define environment variablesENV USER_NAME=chrisallenENV GROUP_NAME=chrisallenENV USER_ID=$USER_IDENV GROUP_ID=$GROUP_IDENV USER_ID=${USER_ID:-1001}ENV GROUP_ID=${GROUP_ID:-1001}# Add group and user based on build argumentsRUN addgroup --gid${GROUP_ID}${GROUP_NAME}RUN adduser --disabled-password--gecos''--uid${USER_ID}--ingroup${GROUP_NAME}${USER_NAME}# Set user and group of working directoryRUN chown-R chrisallen:chrisallen /var/www/html
# Update and install packages# […]# Install PHP extensions# […]# Set nginx and PHP-FPM userRUN sed-ri-e"s!user nginx!user ${USER_NAME}!g" /etc/nginx/nginx.conf
RUN sed-ri-e"s!user = www-data!user = ${USER_NAME}!g" /usr/local/etc/php-fpm.d/www.conf
RUN sed-ri-e"s!group = www-data!group = ${GROUP_NAME}!g" /usr/local/etc/php-fpm.d/www.conf
# Manualy expose port 80 for outside access to nginx# […]# Copy configuration to application container# […]# Start nginx and PHP-FPM# […]
Hi Chris, we have a working solution for our local development environment. We just tell Nginx and PHP-FPM to run as »chrisallen«. Below you can have a look at a simplified version of our Dockerfile.
I hope this will help you.
Happy coding :)
This is such a huge help, thanks for the personalised script ;) I'll try it out on the next setup.