From f281b33ea1bf3f27f62eb587d6adfa208b2a6c2a Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 30 Nov 2024 22:05:28 +1100 Subject: [PATCH 1/4] Update dockerfile --- debian/Dockerfile | 3 +++ debian/scripts/init.sh | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/debian/Dockerfile b/debian/Dockerfile index 7b9dd26..e106d26 100644 --- a/debian/Dockerfile +++ b/debian/Dockerfile @@ -136,6 +136,9 @@ RUN mkdir -p \ RUN cp /var/www/html/resources/views/react/index.blade.php /var/www/html/public/index.html +# copy the public/ directory into a separate folder so that we can overwrite the volume later via the entrypoint +RUN mkdir -p /image-original/public && cp -r /var/www/html/public /image-original/public + # Set permissions RUN chown -R www-data:www-data \ /var/www/html/storage \ diff --git a/debian/scripts/init.sh b/debian/scripts/init.sh index 77a37bf..d62cb94 100755 --- a/debian/scripts/init.sh +++ b/debian/scripts/init.sh @@ -46,6 +46,23 @@ chmod -R 775 \ chown -R www-data:www-data /var/www/html/storage +# Ensure symlink for storage/app/public +if [ ! -L /var/www/html/public/storage ]; then + echo "Creating symlink for storage/app/public..." + ln -sfn /var/www/html/storage/app/public /var/www/html/public/storage +fi + +# Clean the existing public/ directory but exclude .js and .css files +if [ -d /var/www/html/public ]; then + echo "Cleaning up stale files in public/ directory, retaining .js and .css files..." + find /var/www/html/public -type f ! -name '*.js' ! -name '*.css' -exec rm -f {} \; +fi + +# Copy the public/ directory from the image to the mounted volume +echo "Copying public/ directory from image to volume..." +cp -r /image-original/public/* /var/www/html/public/ + + # Clear and cache config in production if [ "$APP_ENV" = "production" ]; then gosu www-data php artisan config:cache From c4e1d0e3a5ae30c0b955d230911d1bbf95732cc5 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 3 Dec 2024 14:49:58 +1100 Subject: [PATCH 2/4] Updates for copy files --- debian/docker-compose.yml | 6 +++--- debian/scripts/init.sh | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/debian/docker-compose.yml b/debian/docker-compose.yml index e5b96c0..2a9a34d 100644 --- a/debian/docker-compose.yml +++ b/debian/docker-compose.yml @@ -19,7 +19,7 @@ services: - ./supervisor/supervisord.conf:/etc/supervisor/conf.d/supervisord.conf:ro - app_storage:/var/www/html/storage - app_cache:/var/www/html/bootstrap/cache - - image_public:/var/www/html/public:ro + - image_public:/var/www/html/public networks: - app-network depends_on: @@ -33,11 +33,11 @@ services: image: nginx:alpine restart: unless-stopped ports: - - "80:80" + - "8012:80" volumes: - ./nginx:/etc/nginx/conf.d:ro - app_storage:/var/www/html/storage:ro - - image_public:/var/www/html/public:ro + - image_public:/var/www/html/public networks: - app-network depends_on: diff --git a/debian/scripts/init.sh b/debian/scripts/init.sh index d62cb94..d231146 100755 --- a/debian/scripts/init.sh +++ b/debian/scripts/init.sh @@ -54,13 +54,13 @@ fi # Clean the existing public/ directory but exclude .js and .css files if [ -d /var/www/html/public ]; then - echo "Cleaning up stale files in public/ directory, retaining .js and .css files..." - find /var/www/html/public -type f ! -name '*.js' ! -name '*.css' -exec rm -f {} \; + echo "Cleaning up .js and .css files in public/ directory..." + find /var/www/html/public -type f \( -name '*.js' -o -name '*.css' \) -exec rm -f {} \; fi # Copy the public/ directory from the image to the mounted volume echo "Copying public/ directory from image to volume..." -cp -r /image-original/public/* /var/www/html/public/ +cp -r /image-original/public/* /var/www/html/ # Clear and cache config in production From 5e40e349439b873bec60497cbd8c8603b76e1d50 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 3 Dec 2024 14:59:41 +1100 Subject: [PATCH 3/4] run local init.sh file --- debian/docker-compose.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/debian/docker-compose.yml b/debian/docker-compose.yml index 2a9a34d..eaf37c6 100644 --- a/debian/docker-compose.yml +++ b/debian/docker-compose.yml @@ -13,6 +13,7 @@ services: env_file: - ./.env volumes: + - ./scripts/init.sh:/usr/local/bin/init.sh - ./.env:/var/www/html/.env:ro - ./php/php.ini:/usr/local/etc/php/conf.d/zzz-php.ini:ro - ./php/php-fpm.conf:/usr/local/etc/php-fpm.d/zzz-php-fpm.conf:ro From d5ed1935f7b8a2d7f93a1ef4e5b5d955c901222a Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 3 Dec 2024 15:01:08 +1100 Subject: [PATCH 4/4] set port 80 --- debian/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/docker-compose.yml b/debian/docker-compose.yml index eaf37c6..f00bc1d 100644 --- a/debian/docker-compose.yml +++ b/debian/docker-compose.yml @@ -34,7 +34,7 @@ services: image: nginx:alpine restart: unless-stopped ports: - - "8012:80" + - "80:80" volumes: - ./nginx:/etc/nginx/conf.d:ro - app_storage:/var/www/html/storage:ro