Upgrade the Docker setup and dependencies
This commit is contained in:
parent
10b49ace3d
commit
df6286b2e9
3
.gitattributes
vendored
Normal file
3
.gitattributes
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
* text=auto
|
||||||
|
*.sh text eol=lf
|
||||||
|
docker/apache/start_safe_perms text eol=lf
|
16
Dockerfile
16
Dockerfile
@ -3,7 +3,6 @@ FROM php:7.1-fpm-alpine
|
|||||||
RUN apk add --no-cache --virtual .persistent-deps \
|
RUN apk add --no-cache --virtual .persistent-deps \
|
||||||
git \
|
git \
|
||||||
icu-libs \
|
icu-libs \
|
||||||
make \
|
|
||||||
zlib
|
zlib
|
||||||
|
|
||||||
ENV APCU_VERSION 5.1.8
|
ENV APCU_VERSION 5.1.8
|
||||||
@ -23,10 +22,9 @@ RUN set -xe \
|
|||||||
&& docker-php-ext-enable --ini-name 05-opcache.ini opcache \
|
&& docker-php-ext-enable --ini-name 05-opcache.ini opcache \
|
||||||
&& apk del .build-deps
|
&& apk del .build-deps
|
||||||
|
|
||||||
COPY docker/php/php.ini /usr/local/etc/php/php.ini
|
COPY docker/app/php.ini /usr/local/etc/php/php.ini
|
||||||
|
|
||||||
COPY docker/php/install-composer.sh /usr/local/bin/docker-app-install-composer
|
|
||||||
|
|
||||||
|
COPY docker/app/install-composer.sh /usr/local/bin/docker-app-install-composer
|
||||||
RUN chmod +x /usr/local/bin/docker-app-install-composer
|
RUN chmod +x /usr/local/bin/docker-app-install-composer
|
||||||
|
|
||||||
RUN set -xe \
|
RUN set -xe \
|
||||||
@ -42,7 +40,7 @@ ENV COMPOSER_ALLOW_SUPERUSER 1
|
|||||||
RUN composer global require "hirak/prestissimo:^0.3" --prefer-dist --no-progress --no-suggest --optimize-autoloader --classmap-authoritative \
|
RUN composer global require "hirak/prestissimo:^0.3" --prefer-dist --no-progress --no-suggest --optimize-autoloader --classmap-authoritative \
|
||||||
&& composer clear-cache
|
&& composer clear-cache
|
||||||
|
|
||||||
WORKDIR /srv/api-platform
|
WORKDIR /srv/app
|
||||||
|
|
||||||
COPY composer.json ./
|
COPY composer.json ./
|
||||||
COPY composer.lock ./
|
COPY composer.lock ./
|
||||||
@ -63,8 +61,8 @@ COPY web web/
|
|||||||
|
|
||||||
RUN composer dump-autoload --optimize --classmap-authoritative --no-dev
|
RUN composer dump-autoload --optimize --classmap-authoritative --no-dev
|
||||||
|
|
||||||
COPY docker/php/start.sh /usr/local/bin/docker-app-start
|
COPY docker/app/docker-entrypoint.sh /usr/local/bin/docker-app-entrypoint
|
||||||
|
RUN chmod +x /usr/local/bin/docker-app-entrypoint
|
||||||
|
|
||||||
RUN chmod +x /usr/local/bin/docker-app-start
|
ENTRYPOINT ["docker-app-entrypoint"]
|
||||||
|
CMD ["php-fpm"]
|
||||||
CMD ["docker-app-start"]
|
|
||||||
|
@ -3,17 +3,13 @@
|
|||||||
"type": "project",
|
"type": "project",
|
||||||
"license": "proprietary",
|
"license": "proprietary",
|
||||||
"description": "Project description",
|
"description": "Project description",
|
||||||
"minimum-stability": "dev",
|
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^7.1",
|
"php": "^7.1.3",
|
||||||
"symfony/flex": "1.0.x-dev",
|
"symfony/flex": "^1.0",
|
||||||
"symfony/framework-bundle": "3.3.x-dev",
|
"symfony/framework-bundle": "^3.3",
|
||||||
"symfony/yaml": "3.3.x-dev"
|
"symfony/yaml": "^3.3"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"platform": {
|
|
||||||
"php": "7.1"
|
|
||||||
},
|
|
||||||
"preferred-install": {
|
"preferred-install": {
|
||||||
"*": "dist"
|
"*": "dist"
|
||||||
},
|
},
|
||||||
@ -39,11 +35,8 @@
|
|||||||
"@auto-scripts"
|
"@auto-scripts"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"repositories": [
|
|
||||||
{ "type": "vcs", "url": "https://github.com/fabpot/flex" }
|
|
||||||
],
|
|
||||||
"conflict": {
|
"conflict": {
|
||||||
"symfony/symfony": "<3.3",
|
"symfony/symfony": "*",
|
||||||
"symfony/twig-bundle": "<3.3",
|
"symfony/twig-bundle": "<3.3",
|
||||||
"symfony/debug": "<3.3"
|
"symfony/debug": "<3.3"
|
||||||
},
|
},
|
||||||
|
@ -1,36 +1,54 @@
|
|||||||
version: '3'
|
version: '3'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
#db:
|
app:
|
||||||
# image: mysql:5.7
|
build:
|
||||||
# environment:
|
context: .
|
||||||
# MYSQL_DATABASE: symfony
|
dockerfile: ./Dockerfile
|
||||||
# MYSQL_USER: symfony
|
|
||||||
# MYSQL_PASSWORD: symfony
|
|
||||||
# MYSQL_RANDOM_ROOT_PASSWORD: 'true'
|
|
||||||
# volumes:
|
|
||||||
# - db-data:/var/lib/mysql
|
|
||||||
# healthcheck:
|
|
||||||
# test: mysql --user=api_platform --password=api_platform -e "SELECT 1" api_platform
|
|
||||||
|
|
||||||
php:
|
|
||||||
build: .
|
|
||||||
#depends_on:
|
#depends_on:
|
||||||
# - db
|
# - db
|
||||||
|
environment:
|
||||||
|
# Change to prod in production
|
||||||
|
- SYMFONY_ENV=dev
|
||||||
volumes:
|
volumes:
|
||||||
- ./:/srv/api-platform
|
# Comment out the next line in production
|
||||||
env_file:
|
- ./:/srv/app:rw
|
||||||
- .env
|
# This is for assets:install
|
||||||
|
- ./web:/srv/app/web:rw
|
||||||
|
# If you develop on Linux, comment out the following volumes to just use bind-mounted project directory from host
|
||||||
|
- /srv/app/var
|
||||||
|
- /srv/app/var/cache
|
||||||
|
- /srv/app/var/logs
|
||||||
|
- /srv/app/var/sessions
|
||||||
|
- /srv/app/vendor
|
||||||
|
|
||||||
nginx:
|
nginx:
|
||||||
image: nginx:1.11-alpine
|
build:
|
||||||
depends_on:
|
context: ./docker/nginx
|
||||||
- php
|
dockerfile: ./Dockerfile
|
||||||
ports:
|
|
||||||
- '80:80'
|
|
||||||
volumes:
|
volumes:
|
||||||
|
# Comment out the next line in production
|
||||||
- ./docker/nginx/conf.d:/etc/nginx/conf.d:ro
|
- ./docker/nginx/conf.d:/etc/nginx/conf.d:ro
|
||||||
- ./:/srv/api-platform
|
- ./web:/srv/app/web:ro
|
||||||
|
ports:
|
||||||
|
- "80:80"
|
||||||
|
|
||||||
#volumes:
|
# Uncomment the following lines to add a MySQL container
|
||||||
# db-data:
|
#db:
|
||||||
|
# build:
|
||||||
|
# context: ./docker/db
|
||||||
|
# dockerfile: ./Dockerfile
|
||||||
|
# environment:
|
||||||
|
# - MYSQL_DATABASE=app
|
||||||
|
# # You should definitely change the password in production
|
||||||
|
# - MYSQL_PASSWORD=symfony
|
||||||
|
# - MYSQL_RANDOM_ROOT_PASSWORD=true
|
||||||
|
# - MYSQL_USER=symfony
|
||||||
|
# volumes:
|
||||||
|
# - db-data:/var/lib/mysql:rw
|
||||||
|
# # You may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data!
|
||||||
|
# # - ./docker/db/data:/var/lib/mysql:rw
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
app-web: {}
|
||||||
|
#db-data: {}
|
||||||
|
24
docker/app/docker-entrypoint.sh
Executable file
24
docker/app/docker-entrypoint.sh
Executable 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 "$@"
|
@ -1,5 +1,9 @@
|
|||||||
#!/bin/sh
|
#!/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)
|
EXPECTED_SIGNATURE=$(wget -q -O - https://composer.github.io/installer.sig)
|
||||||
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
|
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
|
||||||
ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', 'composer-setup.php');")
|
ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', 'composer-setup.php');")
|
10
docker/db/.dockerignore
Normal file
10
docker/db/.dockerignore
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
**/*.log
|
||||||
|
**/*.md
|
||||||
|
**/*.sql.gz
|
||||||
|
**/._*
|
||||||
|
**/.DS_Store
|
||||||
|
**/.gitignore
|
||||||
|
**/Thumbs.db
|
||||||
|
.dockerignore
|
||||||
|
data/
|
||||||
|
Dockerfile
|
1
docker/db/.gitignore
vendored
Normal file
1
docker/db/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
data/
|
6
docker/db/Dockerfile
Normal file
6
docker/db/Dockerfile
Normal 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
30
docker/db/docker-healthcheck.sh
Executable 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
|
8
docker/nginx/.dockerignore
Normal file
8
docker/nginx/.dockerignore
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
**/*.log
|
||||||
|
**/*.md
|
||||||
|
**/._*
|
||||||
|
**/.DS_Store
|
||||||
|
**/.gitignore
|
||||||
|
**/Thumbs.db
|
||||||
|
.dockerignore
|
||||||
|
Dockerfile
|
3
docker/nginx/Dockerfile
Normal file
3
docker/nginx/Dockerfile
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
FROM nginx:1.11-alpine
|
||||||
|
|
||||||
|
COPY conf.d /etc/nginx/conf.d/
|
@ -1,12 +1,13 @@
|
|||||||
server {
|
server {
|
||||||
root /srv/api-platform/web;
|
root /srv/app/web;
|
||||||
|
resolver 127.0.0.11;
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
# try to serve file directly, fallback to app.php
|
# try to serve file directly, fallback to app.php
|
||||||
try_files $uri /index.php$is_args$args;
|
try_files $uri /index.php$is_args$args;
|
||||||
}
|
}
|
||||||
location ~ ^/index\.php(/|$) {
|
location ~ ^/index\.php(/|$) {
|
||||||
fastcgi_pass php:9000;
|
fastcgi_pass app:9000;
|
||||||
fastcgi_split_path_info ^(.+\.php)(/.*)$;
|
fastcgi_split_path_info ^(.+\.php)(/.*)$;
|
||||||
include fastcgi_params;
|
include fastcgi_params;
|
||||||
# When you are using symlinks to link the document root to the
|
# When you are using symlinks to link the document root to the
|
||||||
@ -29,7 +30,4 @@ server {
|
|||||||
location ~ \.php$ {
|
location ~ \.php$ {
|
||||||
return 404;
|
return 404;
|
||||||
}
|
}
|
||||||
|
|
||||||
error_log /var/log/nginx/app_error.log;
|
|
||||||
access_log /var/log/nginx/app_access.log;
|
|
||||||
}
|
}
|
||||||
|
@ -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
|
|
@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use App\Kernel;
|
use App\Kernel;
|
||||||
use Symfony\Component\Dotenv\Dotenv;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\Debug\Debug;
|
use Symfony\Component\Debug\Debug;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user