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