Files
michaelschiemer/docker/php/Dockerfile
Michael Schiemer c8b47e647d feat(Docker): Upgrade to PHP 8.5.0RC3 with native ext-uri support
BREAKING CHANGE: Requires PHP 8.5.0RC3

Changes:
- Update Docker base image from php:8.4-fpm to php:8.5.0RC3-fpm
- Enable ext-uri for native WHATWG URL parsing support
- Update composer.json PHP requirement from ^8.4 to ^8.5
- Add ext-uri as required extension in composer.json
- Move URL classes from Url.php85/ to Url/ directory (now compatible)
- Remove temporary PHP 8.4 compatibility workarounds

Benefits:
- Native URL parsing with Uri\WhatWg\Url class
- Better performance for URL operations
- Future-proof with latest PHP features
- Eliminates PHP version compatibility issues
2025-10-27 09:31:28 +01:00

112 lines
3.5 KiB
Docker

# Dockerfile für PHP-FPM
FROM php:8.5.0RC3-fpm AS base
# System-Abhängigkeiten: Werden selten geändert, daher ein eigener Layer
RUN apt-get update && apt-get install -y \
git \
unzip \
libzip-dev \
zip \
libpng-dev \
libjpeg-dev \
libfreetype6-dev \
libwebp-dev \
libavif-dev \
libxpm-dev \
libsodium-dev \
libpq-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN docker-php-ext-configure gd \
--with-freetype \
--with-jpeg \
--with-webp \
--with-avif \
--with-xpm \
&& docker-php-ext-install -j$(nproc) gd
# Install PHP extensions
RUN docker-php-ext-install -j$(nproc) \
zip \
pdo \
pdo_mysql \
pdo_pgsql \
pcntl \
posix \
shmop \
bcmath
# Enable ext-uri for PHP 8.5 WHATWG URL support
RUN docker-php-ext-enable uri
# Install PECL extensions
RUN pecl install apcu redis \
&& docker-php-ext-enable apcu redis
RUN echo "apc.enable_cli=1" >> /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini \
&& echo "apc.shm_size=128M" >> /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini
# Composer installieren
RUN curl -sS https://getcomposer.org/installer | php \
&& mv composer.phar /usr/local/bin/composer
# Installiere Xdebug nur im Entwicklungsmodus
ARG ENV=prod
RUN if [ "$ENV" = "dev" ]; then \
pecl install xdebug \
&& docker-php-ext-enable xdebug; \
fi
WORKDIR /var/www/html
# Composer Dependencies (für besseres Caching)
COPY composer.json ./
COPY composer.lock* ./
RUN composer install --no-scripts --no-autoloader --ignore-platform-reqs || \
(composer install --no-scripts --no-autoloader --no-dev --ignore-platform-reqs || \
echo "Composer install failed, continuing without dependencies")
# Kopiere PHP-Konfigurationen
COPY docker/php/php.common.ini /usr/local/etc/php/php.common.ini
COPY docker/php/php.${ENV}.ini /usr/local/etc/php/php.ini
# Kopiere PHP-FPM Pool-Konfiguration
COPY docker/php/zz-docker.conf /usr/local/etc/php-fpm.d/zz-docker.conf
# Xdebug-Konfiguration nur wenn dev
RUN if [ "$ENV" = "dev" ] && [ -f docker/php/xdebug.ini ]; then \
cp docker/php/xdebug.ini /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; \
fi
# Kopiere den Rest des Projekts
COPY . .
# Optimiere Autoloader
RUN composer dump-autoload --optimize
# <<--- ALLE zusätzlichen System-Dateien und chmod noch als root!
COPY docker/php/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
# Remove entire storage directory tree copied from COPY . .
# But we MUST create the empty parent directory so Docker can mount subdirectories
RUN rm -rf /var/www/html/storage && mkdir -p /var/www/html/storage
# CRITICAL: The storage directory must exist as an empty directory in the image
# This allows Docker to mount Named Volumes to subdirectories (storage/cache, storage/logs, etc.)
# without needing to create the parent directory at runtime (which fails due to read-only overlay)
# Create appuser but DON'T switch yet - let entrypoint handle volumes first
RUN groupadd -g 1000 appuser && useradd -u 1000 -g appuser -m appuser
RUN chown -R appuser:appuser /var/www/html
# Install gosu for secure user switching in entrypoint (Debian alternative to su-exec)
RUN apt-get update && apt-get install -y gosu && apt-get clean && rm -rf /var/lib/apt/lists/*
# Note: USER switch happens in entrypoint AFTER volumes are mounted
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
CMD ["php-fpm"]