From 9e3decc5d156f12142e9f77273d68f36d6d4699c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kriszti=C3=A1n=20Ferenczi?= Date: Tue, 15 Aug 2017 12:48:58 +0200 Subject: [PATCH 1/5] Change docker workflow - Rename .env to .env.dist - Add host and port support - Update the README.md --- .env.dist | 29 +++++++++++++++++++++++++++++ .gitignore | 1 + bin/docker-compose-setup.sh | 4 ++++ doc/docker-compose/README.md | 6 +++++- doc/docker-compose/base-dev.yml | 4 ++-- doc/docker-compose/base-prod.yml | 4 ++-- 6 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 .env.dist create mode 100755 bin/docker-compose-setup.sh diff --git a/.env.dist b/.env.dist new file mode 100644 index 0000000000..59ef130cf3 --- /dev/null +++ b/.env.dist @@ -0,0 +1,29 @@ +# Allows us to set default values of env variables, see: https://docs.docker.com/compose/env-file/ +# On Docker Compose v1.7.0 file separator if defining several is different from Win and nix, so we just use one for default prod setup +COMPOSE_FILE=doc/docker-compose/base-prod.yml +COMPOSE_DIR=. + +# You'll need to adjust this for Windows and XDB Linux systems: https://getcomposer.org/doc/03-cli.md#composer-home +COMPOSER_HOME=~/.composer +DATABASE_USER=ezp +DATABASE_PASSWORD=SetYourOwnPassword +DATABASE_NAME=ezp + +## Docker images (name and version) +PHP_IMAGE=ezsystems/php:7.1-v1 +PHP_IMAGE_DEV=ezsystems/php:7.1-v1-dev +NGINX_IMAGE=nginx:stable +MYSQL_IMAGE=mariadb:10.1 +SELENIUM_IMAGE=selenium/standalone-firefox:2.53.1 +REDIS_IMAGE=redis + +# HTTP host and port +HTTP_HOST=localhost +HTTP_PORT=8080 + +# App image name for use if you intend to push it to docker registry/hub. +APP_PROD_IMAGE=my-ez-app +APP_DOCKER_FILE=Dockerfile + +# Install config, used by .platform.app.yaml among others +INSTALL_EZ_INSTALL_TYPE=clean diff --git a/.gitignore b/.gitignore index 242e454818..3ed18e6a64 100644 --- a/.gitignore +++ b/.gitignore @@ -49,3 +49,4 @@ behat.yml .php_cs.cache auth.json ide-twig.json +.env diff --git a/bin/docker-compose-setup.sh b/bin/docker-compose-setup.sh new file mode 100755 index 0000000000..1c29c25198 --- /dev/null +++ b/bin/docker-compose-setup.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +cp -i .env.dist .env +docker-compose -f doc/docker-compose/install.yml up --abort-on-container-exit diff --git a/doc/docker-compose/README.md b/doc/docker-compose/README.md index 0e8e7763ff..41fca29c37 100644 --- a/doc/docker-compose/README.md +++ b/doc/docker-compose/README.md @@ -55,7 +55,9 @@ From root of your projects clone of this distribution, [setup composer auth.json #export COMPOSE_FILE=doc/docker-compose/base-prod.yml:doc/docker-compose/blackfire.yml BLACKFIRE_SERVER_ID= BLACKFIRE_SERVER_TOKEN= # First time: Install setup, and generate database dump: -docker-compose -f doc/docker-compose/install.yml up --abort-on-container-exit +bin/docker-compose-setup.sh + +# Edit the .env file! # Boot up full setup: docker-compose up -d --force-recreate @@ -63,6 +65,8 @@ docker-compose up -d --force-recreate After some 5-10 seconds you should be able to browse the site on `localhost:8080` and the backend on `localhost:8080/ez`. +> You can change the host and port in `.env` file. Edit the `HTTP_HOST` and the `HTTP_PORT` parameters. + ### Development "mount" use diff --git a/doc/docker-compose/base-dev.yml b/doc/docker-compose/base-dev.yml index de9bb1bc3a..6352bce2ac 100644 --- a/doc/docker-compose/base-dev.yml +++ b/doc/docker-compose/base-dev.yml @@ -25,14 +25,14 @@ services: volumes_from: - app:ro ports: - - "8080:80" + - "${HTTP_PORT}:80" environment: - SYMFONY_ENV=${SYMFONY_ENV-dev} - MAX_BODY_SIZE=20 - FASTCGI_PASS=app:9000 - TIMEOUT=190 - DOCKER0NET - command: /bin/bash -c "cd /var/www && cp -a doc/nginx/ez_params.d /etc/nginx && bin/vhost.sh --template-file=doc/nginx/vhost.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'" + command: /bin/bash -c "cd /var/www && cp -a doc/nginx/ez_params.d /etc/nginx && bin/vhost.sh --template-file=doc/nginx/vhost.template --host-name=${HTTP_HOST} > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'" db: image: ${MYSQL_IMAGE} diff --git a/doc/docker-compose/base-prod.yml b/doc/docker-compose/base-prod.yml index 8fc2816287..ce4a87556c 100644 --- a/doc/docker-compose/base-prod.yml +++ b/doc/docker-compose/base-prod.yml @@ -25,14 +25,14 @@ services: volumes_from: - app:ro ports: - - "8080:80" + - "${HTTP_PORT}:80" environment: - SYMFONY_ENV=${SYMFONY_ENV-prod} - MAX_BODY_SIZE=20 - FASTCGI_PASS=app:9000 - TIMEOUT=190 - DOCKER0NET - command: /bin/bash -c "cd /var/www && cp -a doc/nginx/ez_params.d /etc/nginx && bin/vhost.sh --template-file=doc/nginx/vhost.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'" + command: /bin/bash -c "cd /var/www && cp -a doc/nginx/ez_params.d /etc/nginx && bin/vhost.sh --template-file=doc/nginx/vhost.template --host-name=${HTTP_HOST} > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'" db: image: ${MYSQL_IMAGE} From 25cc09bfc3e993424c77171ce40f6063de0ac273 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kriszti=C3=A1n=20Ferenczi?= Date: Tue, 15 Aug 2017 12:49:11 +0200 Subject: [PATCH 2/5] Remove .env file --- .env | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 .env diff --git a/.env b/.env deleted file mode 100644 index 285f98ee7b..0000000000 --- a/.env +++ /dev/null @@ -1,30 +0,0 @@ -# Allows us to set default values of env variables, see: https://docs.docker.com/compose/env-file/ -# On Docker Compose v1.7.0 file separator if defining several is different from Win and nix, so we just use one for default prod setup -COMPOSE_FILE=doc/docker-compose/base-prod.yml -COMPOSE_DIR=. - -# You'll need to adjust this for Windows and XDB Linux systems: https://getcomposer.org/doc/03-cli.md#composer-home -COMPOSER_HOME=~/.composer -DATABASE_USER=ezp -DATABASE_PASSWORD=SetYourOwnPassword -DATABASE_NAME=ezp - -## Docker images (name and version) -PHP_IMAGE=ezsystems/php:7.1-v1 -PHP_IMAGE_DEV=ezsystems/php:7.1-v1-dev -NGINX_IMAGE=nginx:stable -MYSQL_IMAGE=mariadb:10.1 -SELENIUM_IMAGE=selenium/standalone-firefox:2.53.1 -REDIS_IMAGE=redis - -# App image name for use if you intend to push it to docker registry/hub. -APP_PROD_IMAGE=my-ez-app -APP_DOCKER_FILE=Dockerfile - -# Install config, used by .platform.app.yaml among others -INSTALL_EZ_INSTALL_TYPE=clean - -# Behat / Selenium config -## web host refer to the tip of the setup, so varnish if that is used. -WEB_HOST=web -SELENIUM_HOST=selenium From 9b990760a9e5a11de00baaea2b29a5420aea4d21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kriszti=C3=A1n=20Ferenczi?= Date: Tue, 15 Aug 2017 12:51:15 +0200 Subject: [PATCH 3/5] Fix --- .env.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.env.dist b/.env.dist index 59ef130cf3..0cb2d1a716 100644 --- a/.env.dist +++ b/.env.dist @@ -5,6 +5,7 @@ COMPOSE_DIR=. # You'll need to adjust this for Windows and XDB Linux systems: https://getcomposer.org/doc/03-cli.md#composer-home COMPOSER_HOME=~/.composer +SYMFONY_ENV=prod DATABASE_USER=ezp DATABASE_PASSWORD=SetYourOwnPassword DATABASE_NAME=ezp From 16e8fcbc59745b9da3ceb4dd1704114e6384daf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kriszti=C3=A1n=20Ferenczi?= Date: Tue, 15 Aug 2017 13:09:16 +0200 Subject: [PATCH 4/5] Fix --- .env.dist | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.env.dist b/.env.dist index 0cb2d1a716..1d76f39a4c 100644 --- a/.env.dist +++ b/.env.dist @@ -5,7 +5,6 @@ COMPOSE_DIR=. # You'll need to adjust this for Windows and XDB Linux systems: https://getcomposer.org/doc/03-cli.md#composer-home COMPOSER_HOME=~/.composer -SYMFONY_ENV=prod DATABASE_USER=ezp DATABASE_PASSWORD=SetYourOwnPassword DATABASE_NAME=ezp @@ -28,3 +27,8 @@ APP_DOCKER_FILE=Dockerfile # Install config, used by .platform.app.yaml among others INSTALL_EZ_INSTALL_TYPE=clean + +# Behat / Selenium config +## web host refer to the tip of the setup, so varnish if that is used. +WEB_HOST=web +SELENIUM_HOST=selenium From 9006a469ee6caf83cbc9eb289dfb144620ce3a06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kriszti=C3=A1n=20Ferenczi?= Date: Tue, 15 Aug 2017 13:14:01 +0200 Subject: [PATCH 5/5] Travis config fix --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 62ef13a525..6ad1e7cd1d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,6 +34,8 @@ before_install: ./bin/.travis/trusty/update_docker.sh before_script: # Internal auth token dedicated to testing with travis+composer on ezsystems repos, not for reuse! - echo "{\"github-oauth\":{\"github.com\":\"d0285ed5c8644f30547572ead2ed897431c1fc09\"}}" > auth.json + # Initialize .env file for docker + - cp .env.dist .env # In case of dev mode we'll need to install composer packages first - docker-compose -f doc/docker-compose/install.yml up --abort-on-container-exit # Run (start containers and execute install command)