chore: fixed an issue that occurred when nginx did not have permissions on the 'php-fpm8.sock' file

This commit is contained in:
Junior L. Botelho (JLB) 2023-02-12 13:35:16 -03:00
parent 36d8aeeb5b
commit 8b2b8af183
No known key found for this signature in database
GPG Key ID: 6A25840754F2A524
5 changed files with 17 additions and 6 deletions

View File

@ -36,10 +36,8 @@ RUN chmod u+x "${DOCKER_SCRIPTS}/php/prepare.sh" &&\
RUN apk add openrc abuild-rootbld --no-cache
# The following lines import all Dockerfiles from other folders so that they can be built together in the final build
INCLUDE+ docker/php/php.dockerfile
INCLUDE+ docker/server/nginx.dockerfile
RUN apk del -r abuild-rootbld
INCLUDE+ docker/php/php.dockerfile
EXPOSE ${NGINX_PORT}

View File

@ -1,6 +1,11 @@
#!/bin/sh
# Due to an issue with Docker's 'CMD' directive, the following scripts are not executing as expected.
# This workaround has been implemented to resolve the issue for now
sh "docker/php/prepare.sh"
sh "docker/server/prepare.sh"
service php-fpm8 start
service nginx start
exec nginx -g daemon off;
exec nginx -g "daemon off;"

View File

@ -1,5 +1,7 @@
#!/bin/sh
echo "[PREPARE] docker/server/prepare.sh'"
# Load all environment variables from 'attributes.sh' using the command 'source /path/attributes.sh'
source "docker/attributes.sh"

View File

@ -1,3 +1,5 @@
# Install Nginx with FastCGI enabled, optimizing its performance for serving content
RUN apk add nginx
# After executing the 'docker run' command, run the 'prepare.sh' script
CMD [ "/bin/sh", "-c", "docker/server/prepare.sh" ]

View File

@ -1,13 +1,17 @@
#!/bin/sh
echo "[PREPARE] docker/server/prepare.sh'"
# Load all environment variables from 'attributes.sh' using the command 'source /path/attributes.sh'
source "docker/attributes.sh"
# This condition creates the Unix socket if 'php-fpm8.sock' does not already exist.
# This fixes an issue where Nginx starts but does not serve content
if [ ! -d "/run/php8" ] || [ ! -S "/run/php8/php-fpm8.sock" ]; then
mkdir /run/php8
touch /run/php8/php-fpm8.sock
mkdir "/run/php8"
touch "/run/php8/php-fpm8.sock"
chmod 0660 "/run/php8/php-fpm8.sock"
chown nginx:nginx "/run/php8/php-fpm8.sock"
fi
export OPEN_SEARCH_HOST_FOR_NGINX="$(echo "${OPEN_SEARCH_HOST}" | cut -d "/" -f 3 | cut -d ":" -f 1)"