From 7196141b5b1e3cf2e4004023cbb05fc6d50a94af 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] 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 9995062306..57e9358a6f 100644 --- a/.gitignore +++ b/.gitignore @@ -48,3 +48,4 @@ composer.lock behat.yml .php_cs.cache auth.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 add5126a08..01c30eaea4 100644 --- a/doc/docker-compose/README.md +++ b/doc/docker-compose/README.md @@ -54,7 +54,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 @@ -62,6 +64,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 ba9f8192a9..c7a43774ec 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 - 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 cf52c85052..7907693d2a 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 - 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}