diff --git a/Dockerfile b/Dockerfile index 4546969..5ff55e1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM php:8.3-fpm +FROM php:8.3-cli # Install system dependencies & PHP extensions RUN apt-get update && apt-get install -y \ @@ -21,29 +21,30 @@ COPY --from=composer:2 /usr/bin/composer /usr/bin/composer # Set working directory WORKDIR /var/www -# Copy source +# Copy source code COPY . . COPY .env.example .env -# Set permission -RUN chown -R www-data:www-data /var/www +# Set permissions for Laravel writable directories +RUN mkdir -p storage bootstrap/cache \ + && chown -R www-data:www-data /var/www \ + && chmod -R ug+rwx storage bootstrap/cache +# Use non-root user for installing dependencies USER www-data -# Install dependencies & generate app key +# Install PHP dependencies RUN composer install --no-interaction --prefer-dist --optimize-autoloader -# Uncomment if you want to generate key automatically (optional) -# RUN php artisan key:generate - +# Back to root to ensure runtime permissions USER root -# Set storage & cache permission +# Re-apply permissions to writable folders RUN chown -R www-data:www-data /var/www/storage /var/www/bootstrap/cache \ && chmod -R 775 /var/www/storage /var/www/bootstrap/cache -# Expose default Laravel serve port +# Expose Laravel development server port EXPOSE 8000 -# Use artisan serve instead of php-fpm +# Run with artisan serve instead of php-fpm CMD ["php", "artisan", "serve", "--host=0.0.0.0", "--port=8000"]