Upgrade the Docker setup and dependencies

This commit is contained in:
Kévin Dunglas
2017-06-12 10:21:33 +02:00
parent 10b49ace3d
commit df6286b2e9
16 changed files with 147 additions and 68 deletions

24
docker/app/docker-entrypoint.sh Executable file
View File

@@ -0,0 +1,24 @@
#!/bin/sh
set -e
# first arg is `-f` or `--some-option`
if [ "${1#-}" != "$1" ]; then
set -- php-fpm "$@"
fi
if [ "$1" = 'php-fpm' ] || [ "$1" = 'bin/console' ]; then
# Detect the host IP
export DOCKER_BRIDGE_IP
DOCKER_BRIDGE_IP=$(ip ro | grep default | cut -d' ' -f 3)
if [ "$SYMFONY_ENV" = 'prod' ]; then
composer install --prefer-dist --no-dev --no-progress --no-suggest --optimize-autoloader --classmap-authoritative --no-interaction
else
composer install --prefer-dist --no-progress --no-suggest --no-interaction
fi
# Permissions hack because setfacl does not work on Mac and Windows
chown -R www-data var
fi
exec docker-php-entrypoint "$@"

View File

@@ -1,5 +1,9 @@
#!/bin/sh
# Copyright (c) Nils Adermann, Jordi Boggiano
# Origin: https://github.com/composer/composer/blob/master/doc/faqs/how-to-install-composer-programmatically.md
# Licence: MIT
EXPECTED_SIGNATURE=$(wget -q -O - https://composer.github.io/installer.sig)
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', 'composer-setup.php');")

10
docker/db/.dockerignore Normal file
View File

@@ -0,0 +1,10 @@
**/*.log
**/*.md
**/*.sql.gz
**/._*
**/.DS_Store
**/.gitignore
**/Thumbs.db
.dockerignore
data/
Dockerfile

1
docker/db/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
data/

6
docker/db/Dockerfile Normal file
View File

@@ -0,0 +1,6 @@
FROM mysql:5.7
COPY docker-healthcheck.sh /usr/local/bin/docker-healthcheck
RUN chmod +x /usr/local/bin/docker-healthcheck
HEALTHCHECK CMD ["docker-healthcheck"]

30
docker/db/docker-healthcheck.sh Executable file
View File

@@ -0,0 +1,30 @@
#!/bin/bash
# Copyright (c) 2014-2016 Docker, Inc.
# Origin: https://github.com/docker-library/healthcheck/blob/master/mysql/docker-healthcheck
# Licence: MIT
set -eo pipefail
if [ "$MYSQL_RANDOM_ROOT_PASSWORD" ] && [ -z "$MYSQL_USER" ] && [ -z "$MYSQL_PASSWORD" ]; then
# there's no way we can guess what the random MySQL password was
echo >&2 'healthcheck error: cannot determine random root password (and MYSQL_USER and MYSQL_PASSWORD were not set)'
exit 0
fi
host="$(hostname --ip-address || echo '127.0.0.1')"
user="${MYSQL_USER:-root}"
export MYSQL_PWD="${MYSQL_PASSWORD:-$MYSQL_ROOT_PASSWORD}"
args=(
# force mysql to not use the local "mysqld.sock" (test "external" connectibility)
-h"$host"
-u"$user"
--silent
)
if select="$(echo 'SELECT 1' | mysql "${args[@]}")" && [ "$select" = '1' ]; then
exit 0
fi
exit 1

View File

@@ -0,0 +1,8 @@
**/*.log
**/*.md
**/._*
**/.DS_Store
**/.gitignore
**/Thumbs.db
.dockerignore
Dockerfile

3
docker/nginx/Dockerfile Normal file
View File

@@ -0,0 +1,3 @@
FROM nginx:1.11-alpine
COPY conf.d /etc/nginx/conf.d/

View File

@@ -1,12 +1,13 @@
server {
root /srv/api-platform/web;
root /srv/app/web;
resolver 127.0.0.11;
location / {
# try to serve file directly, fallback to app.php
try_files $uri /index.php$is_args$args;
}
location ~ ^/index\.php(/|$) {
fastcgi_pass php:9000;
fastcgi_pass app:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
# When you are using symlinks to link the document root to the
@@ -29,7 +30,4 @@ server {
location ~ \.php$ {
return 404;
}
error_log /var/log/nginx/app_error.log;
access_log /var/log/nginx/app_access.log;
}

View File

@@ -1,16 +0,0 @@
#!/bin/sh
set -xe
# Detect the host IP
export DOCKER_BRIDGE_IP=$(ip ro | grep default | cut -d' ' -f 3)
if [ "APP_ENV" = 'prod' ]; then
composer install --prefer-dist --no-dev --no-progress --no-suggest --optimize-autoloader --classmap-authoritative
else
composer install --prefer-dist --no-progress --no-suggest
fi
# Permissions hack because setfacl does not work on Mac and Windows
chown -R www-data var
exec php-fpm