Files
api/Dockerfile
T
Jeppe Bundgaard d7a8fc1d1c Add Nginx TLS configuration, structured logging, PHP-FPM upstream, and Filebeat integration
- Configure Nginx to use structured JSON access logs and add request ID headers.
- Define upstream pool for PHP-FPM with load-balancing support.
- Integrate Filebeat for log ingestion across Nginx and PHP logs.
- Add `.env.example` and README for local TLS setup guidance.
- Extend Dockerfile with PHP extensions (GD, Redis, etc.) and Composer dependency installs.
- Add custom PHP configuration for Redis-backed session storage.
2026-02-13 21:10:50 +01:00

68 lines
2.0 KiB
Docker

# Base image: PHP 8.2 with FPM
FROM php:8.2-fpm
# Install necessary system dependencies
RUN apt-get update && apt-get install -y \
git \
unzip \
libonig-dev \
libpq-dev \
libzip-dev \
libcurl4-openssl-dev \
libpng-dev \
libjpeg62-turbo-dev \
libfreetype6-dev \
libxml2-dev \
default-mysql-client \
redis-server \
nginx \
&& docker-php-ext-install \
mysqli \
pdo \
pdo_mysql \
zip \
bcmath \
sockets
# Build and enable common extensions required by Composer dependencies
RUN docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) gd mbstring dom simplexml
# Install and enable PHP Redis extension for session storage
RUN pecl install redis \
&& docker-php-ext-enable redis
# Set working directory
WORKDIR /var/www/html
# Copy application code
COPY . /var/www/html
# Copy Nginx configuration file
COPY nginx.conf /etc/nginx/nginx.conf
# Install Composer
COPY --from=composer:2.6 /usr/bin/composer /usr/bin/composer
# Install PHP dependencies through Composer (only where composer.json exists)
# Main app dependencies
RUN set -e \
&& if [ -f /var/www/html/services/nginx/app/composer.json ]; then \
COMPOSER_ALLOW_SUPERUSER=1 composer install --no-dev --optimize-autoloader -d /var/www/html/services/nginx/app; \
else \
echo "No composer.json in /var/www/html/services/nginx/app — skipping"; \
fi \
&& if [ -f /var/www/html/services/nginx/app/modules/washcertificates/composer.json ]; then \
COMPOSER_ALLOW_SUPERUSER=1 composer install --no-dev --optimize-autoloader -d /var/www/html/services/nginx/app/modules/washcertificates; \
else \
echo "No composer.json in washcertificates module — skipping"; \
fi
# Set permissions for the web server
RUN chown -R www-data:www-data /var/www/html && chmod -R 755 /var/www/html
# Expose port 80 (HTTP) and 443 (HTTPS)
EXPOSE 80 443
# Start services (Nginx and Redis) when the container starts
CMD service redis-server start && nginx -g "daemon off;" && php-fpm