1- FROM php:8.4 -apache
1+ FROM php:8.2 -apache
22
3- # System deps and PHP extensions
3+ # Install system dependencies first
4+ RUN apt-get update && apt-get install -y \
5+ ca-certificates \
6+ curl \
7+ gnupg \
8+ lsb-release \
9+ && apt-get clean \
10+ && rm -rf /var/lib/apt/lists/*
11+
12+ # Install required system packages and development libraries
413RUN apt-get update && apt-get install -y \
514 libfreetype6-dev \
615 libjpeg62-turbo-dev \
@@ -9,11 +18,21 @@ RUN apt-get update && apt-get install -y \
918 libpq-dev \
1019 libxml2-dev \
1120 libicu-dev \
21+ libonig-dev \
22+ libcurl4-openssl-dev \
23+ pkg-config \
24+ libssl-dev \
1225 unzip \
1326 git \
1427 netcat-openbsd \
15- && docker-php-ext-configure gd --with-freetype --with-jpeg \
28+ wget \
29+ && apt-get clean \
30+ && rm -rf /var/lib/apt/lists/*
31+
32+ # Configure and install PHP extensions
33+ RUN docker-php-ext-configure gd --with-freetype --with-jpeg \
1634 && docker-php-ext-configure intl \
35+ && docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
1736 && docker-php-ext-install -j$(nproc) \
1837 gd \
1938 mysqli \
@@ -29,26 +48,36 @@ RUN apt-get update && apt-get install -y \
2948 iconv \
3049 intl \
3150 opcache \
51+ curl \
52+ fileinfo \
53+ exif \
3254 && a2enmod rewrite \
33- && apt-get clean \
34- && rm -rf /var/lib/apt/lists/*
55+ && a2enmod headers
3556
3657# Composer (use official image for better security)
3758COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
3859
39- # App files
60+ # Set working directory
4061WORKDIR /var/www/html
62+
63+ # Copy application files (excluding lock files via .dockerignore)
4164COPY . /var/www/html
4265
66+ # Install composer dependencies (update to get latest compatible versions)
67+ RUN if [ -f composer.json ]; then \
68+ composer update --no-dev --prefer-dist --no-interaction --optimize-autoloader || true; \
69+ fi \
70+ && if [ -f core/composer.json ]; then \
71+ cd core && composer update --no-dev --prefer-dist --no-interaction --optimize-autoloader && cd ..; \
72+ fi
73+
4374# PHP configuration
4475COPY docker/php.ini /usr/local/etc/php/conf.d/40-custom.ini
4576
46- # Build-time Composer optimisation (root if needed, then core)
47- RUN if [ -f composer.json ]; then composer install --no-dev --prefer-dist --no-interaction --optimize-autoloader; fi \
48- && if [ -f core/composer.json ]; then cd core && composer install --no-dev --prefer-dist --no-interaction --optimize-autoloader && cd - >/dev/null; fi
49-
50- # Permissions (safe defaults; override in runtime if needed)
51- RUN chown -R www-data:www-data storage core/storage assets \
77+ # Create necessary directories and set permissions
78+ RUN mkdir -p storage core/storage assets/cache assets/export assets/files assets/images \
79+ && chown -R www-data:www-data storage core/storage assets \
80+ && chmod -R 755 storage core/storage assets \
5281 || true
5382
5483ENV APACHE_DOCUMENT_ROOT=/var/www/html
0 commit comments