From 50f28292ef2fa27ee6dec609e15f1a3db7291292 Mon Sep 17 00:00:00 2001 From: Francesco Picone Date: Sun, 5 Apr 2026 19:30:47 +0200 Subject: [PATCH] Primo commit --- docker/php/Dockerfile | 5 +++ docker/php/entrypoint.sh | 93 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100755 docker/php/entrypoint.sh diff --git a/docker/php/Dockerfile b/docker/php/Dockerfile index e4b36f8..26f45a2 100644 --- a/docker/php/Dockerfile +++ b/docker/php/Dockerfile @@ -55,6 +55,10 @@ COPY php.ini /usr/local/etc/php/conf.d/custom.ini # Copy PHP-FPM pool config (run workers as appuser) COPY www.conf /usr/local/etc/php-fpm.d/www.conf +# Copy entrypoint +COPY entrypoint.sh /usr/local/bin/entrypoint.sh +RUN chmod +x /usr/local/bin/entrypoint.sh + # Set ownership RUN chown -R appuser:appuser /var/www/html @@ -62,4 +66,5 @@ USER appuser EXPOSE 9000 +ENTRYPOINT ["entrypoint.sh"] CMD ["php-fpm"] diff --git a/docker/php/entrypoint.sh b/docker/php/entrypoint.sh new file mode 100755 index 0000000..726cfb3 --- /dev/null +++ b/docker/php/entrypoint.sh @@ -0,0 +1,93 @@ +#!/bin/bash +set -e + +echo "=========================================" +echo " TerManager2 - Entrypoint" +echo "=========================================" + +# ----------------------------------------------- +# 1. Composer install +# ----------------------------------------------- +if [ ! -f vendor/autoload.php ]; then + echo "[*] Installing Composer dependencies..." + composer install --no-interaction --optimize-autoloader +else + echo "[✓] Composer dependencies already installed." +fi + +# ----------------------------------------------- +# 2. .env file +# ----------------------------------------------- +if [ ! -f .env ]; then + echo "[*] Creating .env from .env.example..." + cp .env.example .env +else + echo "[✓] .env file already exists." +fi + +# ----------------------------------------------- +# 3. Application key +# ----------------------------------------------- +if grep -q "^APP_KEY=$" .env; then + echo "[*] Generating application key..." + php artisan key:generate --ansi +else + echo "[✓] Application key already set." +fi + +# ----------------------------------------------- +# 4. NPM install & build assets +# ----------------------------------------------- +if [ ! -d node_modules ]; then + echo "[*] Installing NPM dependencies..." + npm ci +else + echo "[✓] NPM dependencies already installed." +fi + +if [ ! -d public/build ]; then + echo "[*] Building frontend assets..." + npm run build +else + echo "[✓] Frontend assets already built." +fi + +# ----------------------------------------------- +# 5. Storage link +# ----------------------------------------------- +if [ ! -L public/storage ]; then + echo "[*] Creating storage symlink..." + php artisan storage:link +else + echo "[✓] Storage symlink already exists." +fi + +# ----------------------------------------------- +# 6. Create required storage directories +# ----------------------------------------------- +mkdir -p storage/framework/{cache,sessions,views} +mkdir -p storage/logs +mkdir -p bootstrap/cache + +# ----------------------------------------------- +# 7. Run migrations +# ----------------------------------------------- +echo "[*] Running database migrations..." +php artisan migrate --force + +# ----------------------------------------------- +# 8. Cache config/routes/views +# ----------------------------------------------- +echo "[*] Caching configuration..." +php artisan config:cache +php artisan route:cache +php artisan view:cache + +echo "=========================================" +echo " TerManager2 - Ready!" +echo "=========================================" + +# ----------------------------------------------- +# Execute CMD (default: php-fpm) +# ----------------------------------------------- +exec "$@"