1+ # Use PHP 8.3 (8.4 not supported yet)
2+ FROM php:8.3-apache@sha256:6be4ef702b2dd05352f7e5fe14667696a4ad091c9d2ad9083becbee4300dc3b1
3+
4+ # Install system dependencies and PHP extensions in one layer
5+ RUN apt-get update && apt-get install -y --no-install-recommends \
6+ git \
7+ unzip \
8+ libicu-dev \
9+ inkscape \
10+ fonts-dejavu-core \
11+ curl \
12+ && docker-php-ext-configure intl \
13+ && docker-php-ext-install intl \
14+ && apt-get clean \
15+ && rm -rf /var/lib/apt/lists/*
16+
17+ # Install Composer
18+ COPY --from=composer/composer:latest-bin@sha256:c9bda63056674836406cacfbbdd8ef770fb4692ac419c967034225213c64e11b /composer /usr/bin/composer
19+
20+ # Set working directory
21+ WORKDIR /var/www/html
22+
23+ # Copy composer files and install dependencies
24+ COPY composer.json composer.lock ./
25+ COPY src/ ./src/
26+ RUN composer install --no-dev --optimize-autoloader --no-scripts
27+
28+ # Configure Apache to serve from src/ directory and pass environment variables
29+ RUN a2enmod rewrite headers && \
30+ echo 'ServerTokens Prod\n \
31+ ServerSignature Off\n \
32+ PassEnv TOKEN\n \
33+ <VirtualHost *:80>\n \
34+ ServerAdmin webmaster@localhost\n \
35+ DocumentRoot /var/www/html/src\n \
36+ <Directory /var/www/html/src>\n \
37+ Options -Indexes\n \
38+ AllowOverride None\n \
39+ Require all granted\n \
40+ Header always set Access-Control-Allow-Origin "*"\n \
41+ Header always set Content-Type "image/svg+xml" "expr=%{REQUEST_URI} =~ m#\\ .svg$#i"\n \
42+ Header always set Content-Security-Policy "default-src ' none'; style-src ' unsafe-inline'; img-src data:;" "expr=%{REQUEST_URI} =~ m#\\ .svg$#i"\n \
43+ Header always set Referrer-Policy "no-referrer-when-downgrade"\n \
44+ Header always set X-Content-Type-Options "nosniff"\n \
45+ </Directory>\n \
46+ ErrorLog ${APACHE_LOG_DIR}/error.log\n \
47+ CustomLog ${APACHE_LOG_DIR}/access.log combined\n \
48+ </VirtualHost>' > /etc/apache2/sites-available/000-default.conf
49+
50+ # Set secure permissions
51+ RUN chown -R www-data:www-data /var/www/html && \
52+ find /var/www/html -type d -exec chmod 755 {} \; && \
53+ find /var/www/html -type f -exec chmod 644 {} \;
54+
55+ # Health check
56+ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
57+ CMD curl -f http://localhost/demo/ || exit 1
58+
59+ # Expose port
60+ EXPOSE 80
61+
62+ # Start Apache
63+ CMD ["apache2-foreground" ]
0 commit comments