Skip to content

Commit b1acbf2

Browse files
Merge pull request #21 from continuousphp/docker/enhancement
Docker/enhancement
2 parents 24b95ca + 08b2a34 commit b1acbf2

File tree

4 files changed

+52
-8
lines changed

4 files changed

+52
-8
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.git

infra/docker/.htaccess

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
RewriteEngine On
2+
# The following rule tells Apache that if the requested filename
3+
# exists, simply serve it.
4+
RewriteCond %{REQUEST_FILENAME} -s [OR]
5+
RewriteCond %{REQUEST_FILENAME} -l [OR]
6+
RewriteCond %{REQUEST_FILENAME} -d
7+
RewriteRule ^.*$ - [NC,L]
8+
# The following rewrites all other queries to index.php. The
9+
# condition ensures that if you are using Apache aliases to do
10+
# mass virtual hosting, the base path will be prepended to
11+
# allow proper resolution of the index.php file; it will work
12+
# in non-aliased environments as well, providing a safe, one-size
13+
# fits all solution.
14+
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
15+
RewriteRule ^(.*) - [E=BASE:%1]
16+
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]
17+
18+
# supress php errors
19+
php_flag display_startup_errors off
20+
php_flag display_errors off
21+
php_flag html_errors off
22+
23+
# enable PHP error logging
24+
php_flag log_errors on
25+
php_value error_log /var/app/data/logs/error.log

infra/docker/Dockerfile

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,17 @@ FROM php:7.0-apache
44
RUN ln -sf /usr/share/zoneinfo/Europe/Paris /etc/localtime
55

66
# Install last update and php extension
7-
RUN apt-get update && apt-get install -y \
8-
git \
7+
RUN apt-get update && apt-get install -y --no-install-recommends \
98
vim \
109
bzip2 \
1110
zip \
11+
unzip \
1212
libbz2-dev \
1313
libmcrypt-dev \
1414
libicu-dev \
1515
&& docker-php-ext-configure mysqli \
16-
&& docker-php-ext-install mysqli pdo_mysql bz2 mcrypt intl
16+
&& docker-php-ext-install mysqli pdo_mysql bz2 mcrypt intl \
17+
&& rm -rf /var/lib/apt/lists/*
1718

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

2829
# Implement application
30+
WORKDIR /var/app
2931
COPY . /var/app/
3032

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

36-
CMD ["apache2-foreground"]
36+
# Update project
37+
RUN /usr/bin/composer install --no-dev \
38+
&& ./scripts/post-create-project \
39+
&& chown www-data:www-data -R .
40+
41+
COPY infra/docker/entrypoint.sh /
42+
43+
ENTRYPOINT ["/entrypoint.sh", "apache2-foreground"]

infra/docker/entrypoint.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
set -e
3+
4+
chown -R www-data:www-data /var/app/data
5+
6+
if [ -d /mnt/applications ]
7+
then
8+
chown -R www-data:www-data /mnt/applications
9+
fi
10+
11+
exec "$@"

0 commit comments

Comments
 (0)