Skip to content

Instantly share code, notes, and snippets.

@rahulvramesh
Last active January 26, 2020 17:39
Show Gist options
  • Save rahulvramesh/f9390aece384a48f47188563131c439c to your computer and use it in GitHub Desktop.
Save rahulvramesh/f9390aece384a48f47188563131c439c to your computer and use it in GitHub Desktop.
Lumen + PHP 7.0 + Apache + Docker
# see http://sources.debian.net/src/apache2/2.4.10-1/debian/config-dir/apache2.conf
Mutex file:/var/lock/apache2 default
PidFile /var/run/apache2/apache2.pid
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
User www-data
Group www-data
HostnameLookups Off
ErrorLog /proc/self/fd/2
LogLevel warn
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf
# Include list of ports to listen on
Include ports.conf
<Directory />
Options FollowSymLinks
AllowOverride All
Require all denied
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
DocumentRoot /var/www/html/public
<Directory /var/www/html/public>
AllowOverride All
Require all granted
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]
</IfModule>
</Directory>
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log combined
AccessFileName .htaccess
<FilesMatch "^\.ht">
Require all denied
</FilesMatch>
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
CustomLog /proc/self/fd/1 combined
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
IncludeOptional conf-enabled/*.conf
IncludeOptional sites-enabled/*.conf
FROM php:7.0-apache
RUN apt-get update && apt-get install -y software-properties-common python-software-properties git
RUN apt-get update && apt-get -y upgrade && DEBIAN_FRONTEND=noninteractive && apt-get install -y libpq-dev zip unzip \
&& docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
&& docker-php-ext-install pdo pdo_pgsql pgsql bcmath
RUN a2enmod rewrite
# Manually set up the apache environment variables
ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2
ENV APACHE_LOCK_DIR /var/lock/apache2
ENV APACHE_PID_FILE /var/run/apache2.pid
# Download and Install Composer
RUN curl -s http://getcomposer.org/installer | php \
&& mv composer.phar /usr/local/bin/composer
RUN rm /etc/apache2/sites-available/000-default.conf
RUN rm /etc/apache2/sites-enabled/000-default.conf
RUN rm /etc/apache2/apache2.conf
#Config Files
ADD docker-supports/apache/apache2.conf /etc/apache2/apache2.conf
# Copy this repo into place.
ONBUILD COPY composer.json composer.lock /var/www/html/
ONBUILD COPY database /var/www/html/database/
# Test For Speed
ONBUILD RUN composer global require hirak/prestissimo
ONBUILD RUN composer install --optimize-autoloader --no-dev --profile -vvv
ONBUILD COPY . /var/www/html
ONBUILD RUN rm -Rf tests/
# Configure directory permissions for the web server
ONBUILD RUN chown -R www-data:www-data /var/www/html/storage/
# Copy env
ONBUILD RUN cp .env.example /var/www/html/.env
# Configure data volume
ONBUILD VOLUME /var/www/html/storage
ONBUILD EXPOSE 80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment