Skip to content

Instantly share code, notes, and snippets.

@LouisBertin
Last active December 5, 2023 02:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save LouisBertin/903a206ba7d80b0360ca3acc590a8f35 to your computer and use it in GitHub Desktop.
Save LouisBertin/903a206ba7d80b0360ca3acc590a8f35 to your computer and use it in GitHub Desktop.
Production ready Dockerfile for PHP and Apache
FROM php:7.4-apache
WORKDIR /app
# update & upgrade
RUN apt-get update -y && apt-get upgrade -y && apt-get install apt-utils -y
# Php extensions
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
RUN install-php-extensions intl bcmath gd pdo_mysql opcache uuid exif pcntl zip
COPY php.ini /usr/local/etc/php/conf.d/app.ini
# Install composer
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
# Apache
COPY vhost.conf /etc/apache2/sites-available/000-default.conf
RUN a2enmod rewrite && \
sed -i \
-e 's~^ServerSignature On$~ServerSignature Off~g' \
-e 's~^ServerTokens OS$~ServerTokens Prod~g' \
/etc/apache2/conf-available/security.conf
COPY index.php .
CMD ["apachectl", "-D", "FOREGROUND"]
date.timezone = Europe/Paris
opcache.enable = 1
opcache.enable_cli = 1
opcache.memory_consumption = 128
opcache.revalidate_freq = 0
apc.enable_cli = On
upload_max_filesize = 16M
post_max_size = 16M
realpath_cache_size = 4096k
realpath_cache_ttl = 7200
display_errors = Off
display_startup_errors = Off
expose_php = Off
<VirtualHost *:80>
DocumentRoot /app
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /app/>
Options -Indexes +FollowSymLinks
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment