Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/bin/sh
set -e
if ! getent group "$APACHE_RUN_USER" >/dev/null 2>&1; then
groupadd --gid ${APACHE_RUN_USER_GID} ${APACHE_RUN_USER}
fi
if ! id "$APACHE_RUN_USER" >/dev/null 2>&1; then
useradd --uid ${APACHE_RUN_USER_UID} --gid ${APACHE_RUN_USER_GID} --create-home ${APACHE_RUN_USER}
fi
# first arg is `-f` or `--some-option`
if [ "${1#-}" != "$1" ]; then
set -- apache2-foreground "$@"
fi
exec "$@"
FROM php:7.1-apache
ENV DEBIAN_FRONTEND=noninteractive
ENV DEBCONF_NONINTERACTIVE_SEEN=true
RUN apt-get update -q \
&& apt-get install unzip git libicu-dev curl libcurl4-gnutls-dev libmcrypt-dev -y --no-install-recommends
RUN docker-php-ext-install intl sockets curl pdo_mysql \
# xdebug is installed, but not enabled
# to enable it, load .docker/apache/web-dev.ini using volumes as /usr/local/etc/php/php.ini
&& pecl install xdebug
ENV TIMEZONE=Europe/Prague
RUN echo ${TIMEZONE} > /etc/timezone \
&& dpkg-reconfigure -f noninteractive tzdata
ENV COMPOSER_ALLOW_SUPERUSER=1
ENV COMPOSER_NO_INTERACTION=1
ENV COMPOSER_HOME=/usr/local/share/composer
RUN mkdir -p /usr/local/share/composer \
&& curl -o /tmp/composer-setup.php https://getcomposer.org/installer \
# Make sure we're installing what we think we're installing!
# https://composer.github.io/pubkeys.html
&& echo "669656bab3166a7aff8a7506b8cb2d1c292f042046c5a994c43155c0be6190fa0355160742ab2e1c88d40d5be660b410" > /tmp/composer-setup.sig \
&& php -r "if (hash('SHA384', file_get_contents('/tmp/composer-setup.php')) !== trim(file_get_contents('/tmp/composer-setup.sig'))) { unlink('/tmp/composer-setup.php'); echo 'Invalid installer' . PHP_EOL; exit(1); }" \
&& php /tmp/composer-setup.php --no-ansi --install-dir=/usr/local/bin --filename=composer --snapshot \
&& rm -f /tmp/composer-setup.*
ENV APACHE_RUN_USER=www-data
RUN a2enmod rewrite
ENV PRODUCTION=true
COPY ./.docker/apache/docker-php-entrypoint /usr/local/bin/
COPY ./.docker/apache/web-prod.conf /etc/apache2/sites-available/000-default.conf
COPY ./.docker/apache/php-prod.ini /usr/local/etc/php/php.ini
COPY ./.docker/wait-for-it /usr/local/bin/
ENV VHOST_SERVER_NAME=localhost
WORKDIR /var/www/project
# The composer install should not run if the composer files do not change
COPY composer.json composer.lock /var/www/project/
RUN composer install --no-scripts --no-autoloader --no-suggest --no-ansi
# Application bootstrap
COPY ./ /var/www/project
RUN mkdir -p var/cache/ var/logs/ var/sessions/ \
# Run with symfony bootstrap scripts and generate autoloader
&& composer install --no-ansi \
# There is some problem in symfony v3.2.7, let's not bother right now
&& rm -rf var/cache/dev \
# Make sure the app is owned by the right user
&& chown -R www-data:www-data /var/www/project \
# Make sure composer can modify it's homedir
&& chown -R www-data:www-data /usr/local/share/composer
# xdebug
EXPOSE 9000
USER www-data
date.timezone = ${TIMEZONE}
memory_limit = 96M
[xdebug]
zend_extension = xdebug.so
xdebug.remote_enable = 1
date.timezone = ${TIMEZONE}
memory_limit = 96M
ServerName localhost
<VirtualHost *:80>
ServerName ${VHOST_SERVER_NAME}
DocumentRoot "/var/www/project/www"
DirectoryIndex index.php
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.