diff --git a/.gitignore b/.gitignore index a725465..2a406c9 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -vendor/ \ No newline at end of file +vendor/ +.Trash-1000/ diff --git a/README.md b/README.md index ca8fbbe..9d76a4e 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,8 @@ Php7 Docker Stack goals is to: + [Create a Branch](./docs/how-to/create_branches.md) + [Open a Merge Request](./docs/how-to/create_a_merge_request.md) + [Uninstall](./docs/how-to/uninstall.md) +* **Demos** + + [Laravel 5.5](./docs/demos/laravel-5.5.md) * **Road Map** + [Milestones](https://gitlab.com/exadra37-docker-compose/php7/docker-stack/milestones) + [Overview](https://gitlab.com/exadra37-docker-compose/php7/docker-stack/boards) diff --git a/bin/docker-pull-from-env-vars.sh b/bin/docker-pull-from-env-vars.sh new file mode 100755 index 0000000..e8408d7 --- /dev/null +++ b/bin/docker-pull-from-env-vars.sh @@ -0,0 +1,98 @@ +#!/bin/bash + +set -e + +######################################################################################################################## +# Sourcing +######################################################################################################################## + + script_dir=$(dirname $(readlink -f $0)) + source "${script_dir}/sudo-exists.sh" + source "${script_dir}/parse-env-var.sh" + + +######################################################################################################################## +# Functions +######################################################################################################################## + + # Docker Pull will always exit with 0 code, once when the images don't exist we will ger + function Docker_Pull() + { + local _docker_image="${1?}" + local _sudo_prefix="$(Sudo_Prefix)" + + "${_sudo_prefix}" docker pull "${_docker_image}" || true # docker pull always exit with 0 + } + + function Pull_Docker_Image_From_Env_File() + { + local _env_var="${1?}" + local _env_file="${2?}" + + if [ -f ".env" ] + then + + local _docker_image="$(Parse_Env_Var_From_Env_File "${_env_var}" "${_env_file}")" + + if [ -z "${_docker_image}" ] + then + return 1 + fi + + printf "\n---> Pulling From Env File : ${_docker_image}\n" + Docker_Pull "${_docker_image}" + fi + + return 0 + } + + function Pull_Docker_Image_From_Docker_Compose() + { + local _env_var="${1?}" + local _docker_compose_file="${2?}" + local _docker_image="$(Parse_Env_Var_From_Docker_Compose "${_env_var}" "${_docker_compose_file}")" + + if [ -z "${_docker_image}" ] + then + return 1 + fi + + printf "\n---> Pulling From Docker Compose : ${_docker_image}\n" + Docker_Pull "${_docker_image}" + + return 0 + } + + function Pull_Docker_Image_From_Env_Var() + { + local _env_var="${1?}" + local _env_file="${2?}" + local _docker_compose_file="${3?}" + + if ! Pull_Docker_Image_From_Env_File "${_env_var}" "${_env_file}" + then + Pull_Docker_Image_From_Docker_Compose "${_env_var}" "${_docker_compose_file}" + fi + + return 0 + } + + function Pull_Docker_Images_From_Env_Vars() + { + local _env_var + local -a _docker_images_env_vars + + IFS=',' read -a _docker_images_env_vars <<< "${1?}" + local _env_file="${2?}" + local _docker_compose_file="${3?}" + + for _env_var in "${_docker_images_env_vars[@]}" + do + Pull_Docker_Image_From_Env_Var "${_env_var}" "${_env_file}" "${_docker_compose_file}" + done + + # add an empty line for layout purposes + echo + + return 0 + } diff --git a/bin/parse-env-var.sh b/bin/parse-env-var.sh new file mode 100755 index 0000000..f31854a --- /dev/null +++ b/bin/parse-env-var.sh @@ -0,0 +1,79 @@ +#!/bin/bash + +set -e + +function Parse_Env_Var_From_Env_File() +{ + local _env_var="${1?}" + + local _env_file="${2?}" + + # TODO: only grep lines that are not commented out. + local _env_var_line="$(grep -i "${_env_var}=" "${_env_file}")" + + # PHP_IMAGE=exadra37/php7-fpm:latest -> exadra37/php7-fpm:latest + local _env_var_default_value="${_env_var_line##*=}" + + echo "${_env_var_default_value}" +} + +function Parse_Env_Var_From_Docker_Compose() +{ + local _env_var="${1?}" + + local _docker_compose_file="${2?}" + + local _env_var_line="$(grep -i "${_env_var}:-" "${_docker_compose_file}")" + + # image: ${PHP_IMAGE:-exadra37/php7-fpm:latest} -> exadra37/php7-fpm:latest + local _env_var_default_value="${_env_var_line##*:-}" + + # removes } from end of string + local _env_var_default_value="${_env_var_default_value::-1}" + + echo "${_env_var_default_value}" +} + +function Parse_Left_Env_Var_Value_From_Env_File() +{ + local _env_var="${1?}" + + local _env_file="${2?}" + + local _env_var_value="$(Parse_Env_Var_From_Env_File "${_env_var}" "${_env_file}")" + + echo "${_env_var_value%:*}" +} + +function Parse_Left_Env_Var_Value_From_Docker_Compose() +{ + local _env_var="${1?}" + + local _docker_compose_file="${2?}" + + local _env_var_value="$(Parse_Env_Var_From_Docker_Compose "${_env_var}" "${_docker_compose_file}")" + + echo "${_env_var_value%:*}" +} + +function Parse_Right_Env_Var_Value_From_Env_File() +{ + local _env_var="${1?}" + + local _env_file="${2?}" + + local _env_var_value="$(Parse_Env_Var_From_Env_File "${_env_var}" "${_env_file}")" + + echo "${_env_var_value#*:}" +} + +function Parse_Right_Env_Var_Value_From_Docker_Compose() +{ + local _env_var="${1?}" + + local _docker_compose_file="${2?}" + + local _env_var_value="$(Parse_Env_Var_From_Docker_Compose "${_env_var}" "${_docker_compose_file}")" + + echo "${_env_var_value#*:}" +} diff --git a/bin/php7-docker-stack-setup.sh b/bin/php7-docker-stack-setup.sh new file mode 100755 index 0000000..74151e4 --- /dev/null +++ b/bin/php7-docker-stack-setup.sh @@ -0,0 +1,75 @@ +#!/bin/bash + +set -e + +######################################################################################################################## +# Functions +######################################################################################################################## + + function Create_Dir_If_Not_Exists() + { + local _dir_path="${1}" + + if [ -n "${_dir_path}" ] && [ ! -d "${_dir_path}" ] + then + printf "\nCreated Dir: ${_dir_path}" + + mkdir -p "${_dir_path}" + + # add an empty line for layout purposes + echo + fi + } + + function Copy_Docker_Dir_To_Project_Root() + { + printf "\n---> Copy Docker Stack Images to Project Root <---" + cp -rn ./vendor/exadra37-docker-compose/php7-docker-stack/src/docker . + } + + function Create_Default_Host_Dirs_From_Env_Vars() + { + local _env_var + local -a _env_vars + + IFS=',' read -a _env_vars <<< "${1?}" + local _env_file="${2?}" + local _docker_compose_file="${3?}" + + printf "\n---> Create Docker Stack Default Host Dirs <---" + + for _env_var in "${_env_vars[@]}" + do + Create_Dir_If_Not_Exists "$(Parse_Left_Env_Var_Value_From_Env_File "${_env_var}" "${_env_file}")" + + Create_Dir_If_Not_Exists "$(Parse_Left_Env_Var_Value_From_Docker_Compose "${_env_var}" "${_docker_compose_file}")" + done + + # add an empty line for layout purposes + echo + + return 0 + } + + function Set_Env_Vars() + { + printf "\n---> Setup Env Vars <---\n\n" + + printf "\nDB_HOST=database" >> .env + printf "\nCACHE_DRIVER=redis" >> .env + printf "\nSESSION_DRIVER=redis" >> .env + printf "\nQUEUE_DRIVER=beanstalkd" >> .env + printf "\nREDIS_HOST=cache" >> .env + printf "\nHTTP_PORT_MAP=8000:80" >> .env + } + + function Setup_Docker_Stack() + { + local _host_dir_env_vars="${1?}" + local _env_file="${2?}" + local _docker_compose_file="${3?}" + + Create_Default_Host_Dirs_From_Env_Vars "${_host_dir_env_vars}" "${_env_file}" "${_docker_compose_file}" + Copy_Docker_Dir_To_Project_Root + Set_Env_Vars + } diff --git a/bin/server b/bin/server index e6c50c6..14b4b82 100755 --- a/bin/server +++ b/bin/server @@ -1,11 +1,179 @@ -#!/bin/sh +#!/bin/bash -# We need to ensure that if Php7 Docker Stack is used in more than 1 project, in same machine, Docker compose is able to -# create unique names for the Docker containers in each project. -PROJECT_NAME=${PWD##*/} +set -e -# we want to use the App root as the project directory for docker-compose so that he can read the .env file. -sudo docker-compose \ - -p "${PROJECT_NAME}" \ - --project-directory "${PWD}" \ - --file vendor/exadra37-docker-compose/php7-docker-stack/src/docker-compose.yml "${@}" +######################################################################################################################## +# Sourcing +######################################################################################################################## + + script_dir=$(dirname $(readlink -f $0)) + source "${script_dir}/sudo-exists.sh" + source "${script_dir}/parse-env-var.sh" + source "${script_dir}/php7-docker-stack-setup.sh" + source "${script_dir}/docker-pull-from-env-vars.sh" + + +######################################################################################################################## +# Defaults +######################################################################################################################## + + sudo_prefix=$(Sudo_Prefix) + env_vars="CACHE_IMAGE,CRON_JOBS_IMAGE,DATABASE_IMAGE,HTTP_IMAGE,LOGGER_IMAGE,MONITOR_IMAGE,PHP_IMAGE,QUEUE_IMAGE,DEV_CLI_IMAGE,DATABASE_CLI_IMAGE" + host_dir_env_vars="DATABASE_VOLUME_MAP,LOGGER_VOLUME_MAP" + + +######################################################################################################################## +# Functions +######################################################################################################################## + + # TODO: + # → Show help by sections + function Show_Help() + { + local _script_dir="${1?}" + + cat "${script_dir}/server-help.txt" + + "${sudo_prefix}" docker-compose --help + + exit 0 + } + + # We need to ensure that if Php7 Docker Stack is used in more than 1 project, in same machine, Docker compose is able to + # create unique names for the Docker containers in each project. + function Get_App_Name() + { + local _env_file="${1?}" + local _app_name="$(Parse_Env_Var_From_Env_File "APP_NAME" "${_env_file}")" + + if [ -z "${_app_name}" ] + then + _app_name=${PWD##*/} + fi + + echo "${_app_name}" + } + + # Unless --skip-pull-docker-images is passed, by default we will pull Docker Images only for docker compose commands: + # → up + # → run + function Is_To_Pull_Docker_Images() + { + local _argument + local _env_file="${1?}" + local _is_to_pull_docker_images="$(Parse_Env_Var_From_Env_File "IS_TO_PULL_DOCKER_IMAGES" "${_env_file}")" + + if [ "${_is_to_pull_docker_images}" == "false" ] + then + return 1 # don't pull docker images + fi + + for _argument in "${@}" + do + if [ "${_argument}" == "--skip-pull-docker-images" ] || [ "${_argument}" == "help" ] + then + return 1 # don't pull docker images + fi + + if [ "${_argument}" == "up" ] || [ "${_argument}" == "run" ] + then + return 0 # pull docker images + fi + done + + return 1 # don't pull docker images + } + + +######################################################################################################################## +# Arguments +######################################################################################################################## + + # TODO: Maybe accept them as optional arguments? + env_file=".env" + docker_compose_file="vendor/exadra37-docker-compose/php7-docker-stack/src/docker-compose.yml" + + if [ -z "${1}" ] + then + Show_Help "${script_dir}" + fi + + for argument in "${@}" + do + case "${argument}" in + --help | -h) + Show_Help "${script_dir}" + ;; + --setup-docker-stack) + Setup_Docker_Stack "${host_dir_env_vars}" "${env_file}" "${docker_compose_file}" + exit 0 + ;; + --update-docker-images) + Pull_Docker_Images_From_Env_Vars "${env_vars}" "${env_file}" "${docker_compose_file}" + exit 0 + ;; + --rebuild-docker-images) + # TODO: + # → rebuild all docker images refreneced by env vars. + printf "\n---> NOT IMPLEMENTED YET... <---\n" + exit 0; + ;; + --remove-docker-images) + # TODO: + # → remove all docker images referenced by env vars that are not being used. + printf "\n---> NOT IMPLEMENTED YET... <---\n" + exit 0; + ;; + --remove-docker-volumes) + # TODO: + # → remove all docker volumes referenced by env vars that are not being used. + printf "\n---> NOT IMPLEMENTED YET... <---\n" + exit 0; + ;; + --remove-docker-stack) + # TODO: + # → remove docker images. + # → remove docker volumes. + # → other leftovers I may remind later... + printf "\n---> NOT IMPLEMENTED YET... <---\n" + exit 0; + ;; + esac + done + + +######################################################################################################################## +# Execution +######################################################################################################################## + + # We want to ensure that the ./docker folder exists in the project in any run, otherwise docker compose will fail + # to run when the required docker image needs to be build locally. + if [ ! -d ./docker ] + then + Setup_Docker_Stack "${host_dir_env_vars}" "${env_file}" "${docker_compose_file}" + fi + + # By default we pull docker images on each server up or server run + if Is_To_Pull_Docker_Images "${env_file}" "${@}" + then + Pull_Docker_Images_From_Env_Vars "${env_vars}" "${env_file}" "${docker_compose_file}" + fi + + # Remove all argument options that belong only to this script, otherwise docker compose will fail. + for argument in "${@}" + do + case "${argument}" in + --skip-pull-docker-images) shift 1 ;; + esac + done + + # TODO: + # → execute `run` commands with `--rm` option. + # → execute `up` commands with `-d` option in production. + # + # we want to use the App root as the project directory for docker-compose so that he can read the .env file. + "${sudo_prefix}" docker-compose \ + -p "$(Get_App_Name "${env_file}")" \ + --project-directory "${PWD}" \ + --file "${docker_compose_file}" \ + "${@}" diff --git a/bin/server-help.txt b/bin/server-help.txt new file mode 100644 index 0000000..ab6c22e --- /dev/null +++ b/bin/server-help.txt @@ -0,0 +1,52 @@ +PHP7 DOCKER STACK + +This is a wrapper bash script for `docker-compose` command to run a Docker Stack +for any Php 7 App. + + +Usage: + + server [wrapper-options] [docker-compose usage here...] + + +Wrapper Options: + + -h, --help Show the wrapper bash script and docker compose help. + + --setup-docker-stack Runs the setup for the Php7 Docker Stack. + By default is auto invoked on first run. + + --update-docker-images Will run docker pull for all docker images being used. + This is the default behavior on each invocation of server up|run. + Will get the latest updates for each docker image. + + --skip-pull-docker-images When we want to run without pull docker images. + Useful also to override the env var IS_TO_PULL_DOCKER_IMAGES. + + +Examples: + + Brings up all services defined in the `docker-compose.yml`: + server up + + Brings up all services, but skips pulling docker images: + server --skip-pull-docker-images up + + Brings up the Http service with all other services it depends on(if in the service definition): + server up http + + Runs a developer shell to work with the Php7 Docker Stack: + server run dev-cli + + Runs a mysql shell to access the Database: + server run database-cli + + Taking all services down: + It will destroy all docker containers. + The data persisted by containers on host is not destroyed. + Run as: + server down + + +DOCKER COMPOSE + diff --git a/bin/sudo-exists.sh b/bin/sudo-exists.sh new file mode 100644 index 0000000..467bd8c --- /dev/null +++ b/bin/sudo-exists.sh @@ -0,0 +1,25 @@ +#!/bin-bash + +# One Liner for testing in shell: +# → if sudo -h > /dev/null 2>&1 ; then echo 'Sudo is enabled.' ; else echo 'Sudo is not enabled' ; fi +function Sudo_Exists() +{ + if sudo -h > /dev/null 2>&1 + then + return 0 # sudo exists + fi + + return 1 # sudo doesn't exist +} + +function Sudo_Prefix() +{ + local _sudo_prefix='' + + if Sudo_Exists + then + local _sudo_prefix='sudo' + fi + + echo "${_sudo_prefix}" +} diff --git a/docs/demos/laravel-5.5.md b/docs/demos/laravel-5.5.md new file mode 100644 index 0000000..83ee141 --- /dev/null +++ b/docs/demos/laravel-5.5.md @@ -0,0 +1,136 @@ +# PHP7 DOCKER STACK DEMO FOR LARAVEL 5.5 + +Let's see how easy is to start a Laravel 5.5 project with Php7 Docker Stack. + +Required to run this demo: + +* A docker version equal or greater than 1.12.0. +* Docker Composer in a version equal or greater than `2.1`. + +> **NOTE:** Please note that this demo is aimed for a 100% docker work-flow, +thus is not necessary to have installed Apache, Nginx, Mysql or any other +dependency than the Docker ones. + + +## Create the Laravel Project + +Let's install first Laravel 5.5 by using a docker composer image for php7. + +In order to avoid type in each composer command `sudo docker run --rm -it -v $PWD/home/composer/app exadra37/php7-composer:php-7.0` +we just need to follow [this instructions](https://gitlab.com/exadra37-docker-images/php7/composer/blob/latest/docs/how-to/install.md#bash-script-alias) to install +a simple bash script in `~/home/$USER/bin` that will allow us to invoke it using +only `dkcompoer`. + +> **NOTE:** If you prefer to not install the bash script alias than, just +replace any occurrence of `dkcomposer` by `sudo docker run --rm -it -v $PWD/home/composer/app exadra37/php7-composer:php-7.0`. + + +##### Type in Shell + +```bash +dkcomposer --php 7.0 create-project laravel/laravel:5.5.0 && cd laravel +``` + +```bash +dkcomposer --php 7.0 require predis/predis:v1.1.1 elasticsearch/elasticsearch:v5.3.0 +``` + +## Install Php7 Docker Stack + +Requiring Php7 Docker Stack as a dev dependency... + +##### Type in Shell + +```bash +dkcomposer --php 7.0 require --dev exadra37-docker-compose/php7-docker-stack +``` + +Before we continue please follow [this instructions](./../how-to-bash-script-alias) in order to +create a bash alias for you shell. + +Now that we have the bash alias `server` for `./vendor/bin/server` let's try +running Laravel on a Php7 Docker Stack... + +> **NOTE:** If you prefer to not create the bash alis then just replace all +occurrences of `server` by `./vendor/bin/server`. + + +## Running Laravel + + +### The Env File + +Before we run Laravel we need to prepare some environment variables... + +Open `.env` file in you text editor... + +#### Env vars to update: + +* `DB_HOST=127.0.0.1` to `DB_HOST=database` +* `CACHE_DRIVER=file` to `CACHE_DRIVER=redis` +* `SESSION_DRIVER=file` to `SESSION_DRIVER=redis` +* `QUEUE_DRIVER=sync` to `QUEUE_DRIVER=beanstalkd` +* `REDIS_HOST=127.0.0.1` to `REDIS_HOST=cache` + +#### Env vars to add: + +* `HTTP_PORT_MAP=8888:80` + + +### Server Upl + +##### Type in Shell: + +```bash +server up http +``` + +### Visit Browser + +Now visit the browser on http://localhost:8888 and you should see the Laravel Home page. + + +### Enable Authentication + +To enable authentication we need to run some Artisan commands and for that we need a Shell inside the Docker Container. + + +##### Type in Shell: + +```bash +server run dev-cli +``` + +Now we should be in a shell inside the Docker Container, where we will run 2 Artisan commands... + +##### Type in Container Shell: + +```bash +php artisan make:auth +``` + +##### The Output: + +```bash +Authentication scaffolding generated successfully. +``` + +##### Type in Container Shell: + +```bash +php artisan migrate +``` + +##### The Output: + +```bash +Migration table created successfully. +Migrating: 2014_10_12_000000_create_users_table +Migrated: 2014_10_12_000000_create_users_table +Migrating: 2014_10_12_100000_create_password_resets_table +Migrated: 2014_10_12_100000_create_password_resets_table +``` + +Visit now the browser on http://localhost:8888/register to create an account. + + diff --git a/docs/how-to/set_env_vars.md b/docs/how-to/set_env_vars.md new file mode 100644 index 0000000..8da7a59 --- /dev/null +++ b/docs/how-to/set_env_vars.md @@ -0,0 +1,48 @@ +# ENV VARS + +Bash Wrapper Script Env Vars: + + IS_TO_PULL_DOCKER_IMAGES Set to `false` in `.env` file to disable default behavior. + + +Docker Compose Env Vars: + + HOST_CODE_DIR The dir with the code we want to map into the container. + Defaults to current dir. + + CONTAINER_CODE_DIR The dir inside the container where to map with the HOST_CODE_DIR. + Defaults to /var/www. + + DATABASE_IMAGE The docker image to be used for the docker compose service: database. + + DATABASE_IMAGE_BUILD_DIR The project dir from where to build the custom docker image. + Only used if the required DATABASE_IMAGE is missing from the registry. + Defaults to ./docker/database/percona/build + + DATABASE_VOLUME_MAP To define how to map the host dir with the container dir. + This allows data to be persisted, even after container has been destroyed. + Defaults to ~/.dockerize/services/database/volumes/mysql:/var/lib/mysql + + HTTP_IMAGE The docker image to be used for the docker compose service: http. + + HTTP_IMAGE_BUILD_DIR The project dir from where to build the custom docker image. + Only used if the required HTTP_IMAGE is missing from the registry. + Defaults to ./docker/http/nginx/build + + HTTP_PORT_MAP To define the port map between the host and the container. + Defaults to 80:80. The php app is available at https://domain.com. + With map 8000:80 the php app is available at https://domain.com:8000 + + LOGGER_IMAGE The docker image to be used for the docker compose service: logger. + + LOGGER_IMAGE_BUILD_DIR The project dir from where to build the custom docker image. + Only used if the required LOGGER_IMAGE is missing from the registry. + Defaults to ./docker/logger/elasticsearch/build + + LOGGER_VOLUME_MAP To define how to map the host dir with the container dir. + This allows data to be persisted, even after container has been destroyed. + Defaults to ~/.dockerize/services/logger/volumes/elasticsearch:/usr/share/elasticsearch/data + + LOGGER_HTTP_PORT_MAP To define the http port map between the host and the container. + Defaults to 9200:9200. The logger is available at https://domain.com:9200. + With map 10200:9200 the logger is available at https://domain.com:10200. diff --git a/src/docker-compose.yml b/src/docker-compose.yml index cd65491..9ad56d3 100644 --- a/src/docker-compose.yml +++ b/src/docker-compose.yml @@ -14,7 +14,7 @@ services: - app_network cache: - build: ${CACHE_IMAGE_BUILD_CONTEXT:-./docker/cache/redis/build} + build: ${CACHE_IMAGE_BUILD_DIR:-./docker/cache/redis/build} image: ${CACHE_IMAGE:-redis:latest} ports: - ${CACHE_PORTS_MAP:-6379:6379} @@ -24,7 +24,7 @@ services: - app_network cron-jobs: - build: ${CRON_JOBS_IMAGE_BUILD_CONTEXT:-./docker/cron-jobs/php7-fpm/build} + build: ${CRON_JOBS_IMAGE_BUILD_DIR:-./docker/cron-jobs/php7-fpm/build} image: ${CRON_JOBS_IMAGE:-exadra37/php7-fpm:latest} depends_on: database: @@ -41,12 +41,12 @@ services: - app_network database: - build: ${DATABASE_IMAGE_BUILD_CONTEXT:-./docker/database/percona/build} + build: ${DATABASE_IMAGE_BUILD_DIR:-./docker/database/percona/build} image: ${DATABASE_IMAGE:-percona:latest} healthcheck: test: "exit 0" volumes: - - ${DATABASE_VOLUME_MAP:-data:/var/lib/mysql} + - ${DATABASE_VOLUME_MAP:-~/.dockerize/services/database/volumes/mysql:/var/lib/mysql} environment: MYSQL_ROOT_PASSWORD: ${DATABASE_ROOT_PASSWORD:-rootsecret} MYSQL_DATABASE: ${DB_DATABASE:-dockerstack} @@ -56,7 +56,7 @@ services: - app_network http: - build: ${HTTP_IMAGE_BUILD_CONTEXT:-./docker/http/nginx/build} + build: ${HTTP_IMAGE_BUILD_DIR:-./docker/http/nginx/build} image: ${HTTP_IMAGE:-exadra37/nginx:latest} ports: - ${HTTP_PORT_MAP:-80:80} @@ -71,14 +71,37 @@ services: - app_network logger: + build: ${LOGGER_IMAGE_BUILD_DIR:-./docker/logger/elasticsearch/build} image: ${LOGGER_IMAGE:-elasticsearch:latest} healthcheck: test: "exit 0" + ports: + - ${LOGGER_HTTP_PORT_MAP:-9200:9200} + environment: + - cluster.routing.allocation.disk.watermark.low=2gb + - cluster.routing.allocation.disk.watermark.high=1gb + volumes: + - ${LOGGER_VOLUME_MAP:-~/.dockerize/services/logger/volumes/elasticsearch:/usr/share/elasticsearch/data} + networks: + - app_network + + monitor: + build: ${MONITOR_IMAGE_BUILD_DIR:-./docker/monitor/kibana/build} + image: ${MONITOR_IMAGE:-kibana:latest} + healthcheck: + test: "exit 0" + ports: + - ${MONITOR_HTTP_PORT_MAP:-5601:5601} + environment: + ELASTICSEARCH_URL: ${MONITOR_LOGGER_URL:-http://logger:9200} + depends_on: + logger: + condition: service_healthy networks: - app_network php: - build: ${PHP_IMAGE_BUILD_CONTEXT:-./docker/php/php7-fpm/build} + build: ${PHP_IMAGE_BUILD_DIR:-./docker/php/php7-fpm/build} image: ${PHP_IMAGE:-exadra37/php7-fpm:latest} working_dir: ${CONTAINER_CODE_DIR:-/var/www} expose: @@ -90,7 +113,7 @@ services: condition: service_healthy cache: condition: service_healthy - logger: + monitor: condition: service_healthy queue: condition: service_healthy @@ -102,7 +125,7 @@ services: - app_network queue: - build: ${QUEUE_IMAGE_BUILD_CONTEXT:-./docker/queue/beanstalkd/build} + build: ${QUEUE_IMAGE_BUILD_DIR:-./docker/queue/beanstalkd/build} image: ${QUEUE_IMAGE:-schickling/beanstalkd:latest} healthcheck: test: "exit 0" @@ -117,7 +140,7 @@ services: ################### dev-cli: - build: ${DEV_CLI_IMAGE_BUILD_CONTEXT:-./docker/dev-cli/php7/build} + build: ${DEV_CLI_IMAGE_BUILD_DIR:-./docker/dev-cli/php7/build} image: ${DEV_CLI_IMAGE:-exadra37/php7-dev-cli:latest} working_dir: ${CONTAINER_CODE_DIR:-/var/www} depends_on: @@ -125,7 +148,7 @@ services: condition: service_healthy cache: condition: service_healthy - logger: + monitor: condition: service_healthy queue: condition: service_healthy @@ -150,7 +173,3 @@ services: networks: app_network: driver: "bridge" - -volumes: - data: - driver: "local" diff --git a/src/docker/logger/elasticsearch/build/Dockerfile b/src/docker/logger/elasticsearch/build/Dockerfile new file mode 100644 index 0000000..f1537f1 --- /dev/null +++ b/src/docker/logger/elasticsearch/build/Dockerfile @@ -0,0 +1,3 @@ +FROM elasticsearch:latest + +# Our custom image diff --git a/src/docker/monitor/kibana/build/Dockerfile b/src/docker/monitor/kibana/build/Dockerfile new file mode 100644 index 0000000..10c5118 --- /dev/null +++ b/src/docker/monitor/kibana/build/Dockerfile @@ -0,0 +1,3 @@ +FROM kibana:latest + +# Our custom image