Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker/enhancement #21

Merged
merged 4 commits into from
Jan 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.git
25 changes: 25 additions & 0 deletions infra/docker/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
RewriteEngine On
# The following rule tells Apache that if the requested filename
# exists, simply serve it.
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
# The following rewrites all other queries to index.php. The
# condition ensures that if you are using Apache aliases to do
# mass virtual hosting, the base path will be prepended to
# allow proper resolution of the index.php file; it will work
# in non-aliased environments as well, providing a safe, one-size
# fits all solution.
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]

# supress php errors
php_flag display_startup_errors off
php_flag display_errors off
php_flag html_errors off

# enable PHP error logging
php_flag log_errors on
php_value error_log /var/app/data/logs/error.log
23 changes: 15 additions & 8 deletions infra/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ FROM php:7.0-apache
RUN ln -sf /usr/share/zoneinfo/Europe/Paris /etc/localtime

# Install last update and php extension
RUN apt-get update && apt-get install -y \
git \
RUN apt-get update && apt-get install -y --no-install-recommends \
vim \
bzip2 \
zip \
unzip \
libbz2-dev \
libmcrypt-dev \
libicu-dev \
&& docker-php-ext-configure mysqli \
&& docker-php-ext-install mysqli pdo_mysql bz2 mcrypt intl
&& docker-php-ext-install mysqli pdo_mysql bz2 mcrypt intl \
&& rm -rf /var/lib/apt/lists/*

# Install composer
RUN curl -sS https://getcomposer.org/installer | php \
Expand All @@ -26,11 +27,17 @@ RUN a2enmod rewrite
COPY infra/docker/vhost.conf /etc/apache2/sites-available/000-default.conf

# Implement application
WORKDIR /var/app
COPY . /var/app/

RUN rm -rf /var/app/.git
RUN cd /var/app; \
/usr/bin/composer update; \
./scripts/post-create-project
# htaccess specific to docker app
COPY infra/docker/.htaccess public/

CMD ["apache2-foreground"]
# Update project
RUN /usr/bin/composer install --no-dev \
&& ./scripts/post-create-project \
&& chown www-data:www-data -R .

COPY infra/docker/entrypoint.sh /

ENTRYPOINT ["/entrypoint.sh", "apache2-foreground"]
11 changes: 11 additions & 0 deletions infra/docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
set -e

chown -R www-data:www-data /var/app/data

if [ -d /mnt/applications ]
then
chown -R www-data:www-data /mnt/applications
fi

exec "$@"