Files
vollversammlung/api/Dockerfile.prod
T

72 lines
2.0 KiB
Docker
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
FROM php:8.3-fpm-alpine AS base
# Install system dependencies (minimal for production)
RUN apk add --no-cache \
curl \
oniguruma-dev \
libpng-dev \
libjpeg-turbo-dev \
libxml2-dev \
zip \
unzip \
imagemagick \
ttf-freefont
# Install PHP extensions (production-safe with --enable-option-checking)
RUN docker-php-ext-configure gd --with-jpeg \
&& docker-php-ext-install \
pdo_pgsql \
gd \
intl \
mbstring \
xmlrpc \
opcache
# Enable OPcache for production
RUN echo "opcache.memory_consumption=256" > /usr/local/etc/php/conf.d/opcache.ini \
&& echo "opcache.max_accelerated_files=32531" >> /usr/local/etc/php/conf.d/opcache.ini \
&& echo "opcache.validate_timestamps=0" >> /usr/local/etc/php/conf.d/opcache.ini \
&& echo "opcache.revalidate_freq=0" >> /usr/local/etc/php/conf.d/opcache.ini
# Install Composer (production stage)
FROM composer:latest AS composer
# ---------------
# Build stage install dependencies
# ---------------
FROM base AS build
WORKDIR /app
COPY composer.json composer.lock ./
RUN composer install --no-dev --optimize-autoloader --classmap-authoritative
COPY . .
RUN chmod +x bin/console \
&& APP_ENV=prod APP_DEBUG=0 COMPOSER_DEV_MODE=0 composer dump-autoload --classmap-authoritative --optimize \
&& php bin/console cache:clear --env=prod \
&& php bin/console assets:install public --env=prod
# ---------------
# Final production image
# ---------------
FROM base AS production
LABEL maintainer="devops@vollversammlung" \
description="Vollversammlung Symfony Production Image"
WORKDIR /app
COPY --from=composer /usr/bin/composer /usr/bin/composer
COPY --from=build /app .
# Create necessary directories with correct permissions
RUN chown -R www-data:www-data var/cache var/log var/sessions public/files \
&& find var/ -type d -exec chmod 750 {} \; \
&& find var/ -type f -exec chmod 640 {} \;
EXPOSE 9000
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["php-fpm", "-F"]