diff --git a/docker/php/Dockerfile b/docker/php/Dockerfile index b158ca1..3266e00 100644 --- a/docker/php/Dockerfile +++ b/docker/php/Dockerfile @@ -1,5 +1,5 @@ # ========================= -# Stage 1: Dependencies +# Stage 1: Composer build # ========================= FROM composer:2 AS vendor @@ -7,32 +7,27 @@ WORKDIR /app COPY . . -# install dependencies cleanly (NO MIRROR, NO DEV) RUN composer install \ --no-dev \ --prefer-dist \ --no-interaction \ - --optimize-autoloader \ - --no-scripts + --optimize-autoloader # ========================= -# Stage 2: Runtime +# Stage 2: Runtime image # ========================= FROM php:8.2-fpm-bookworm WORKDIR /var/www/html -# system deps RUN apt-get update && apt-get install -y \ git unzip libzip-dev curl \ && docker-php-ext-install pdo pdo_mysql zip \ && rm -rf /var/lib/apt/lists/* -# copy vendor from stage 1 +# 👇 کل پروژه + vendor از stage قبل COPY --from=vendor /app /var/www/html - -# permissions RUN chown -R www-data:www-data /var/www/html COPY ./docker/php/entrypoint.sh /entrypoint.sh @@ -40,6 +35,3 @@ RUN chmod +x /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] CMD ["php-fpm"] - -EXPOSE 9000 -CMD ["php-fpm"] diff --git a/docker/php/entrypoint.sh b/docker/php/entrypoint.sh index c9632d1..7106988 100644 --- a/docker/php/entrypoint.sh +++ b/docker/php/entrypoint.sh @@ -7,15 +7,7 @@ if [ ! -f .env ]; then cp .env.example .env fi -if [ ! -f vendor/autoload.php ]; then - echo "[ERROR] vendor missing - rebuild image" - exit 1 -fi +# فقط اگر key وجود نداشت +grep -q "APP_KEY=" .env || php artisan key:generate --force -if ! grep -q "APP_KEY=base64" .env; then - echo "[+] Generating APP KEY" - php artisan key:generate --force -fi - -echo "[+] Starting PHP-FPM" exec php-fpm