From 8087529ca3f93438026e319dc48ddbcc7db6f3e2 Mon Sep 17 00:00:00 2001 From: Noel Palo Date: Fri, 10 Sep 2021 05:57:22 +0800 Subject: [PATCH] feature/DLT-24-env-file-reimplementation - Reimplement env file to allow multi env configuration --- docker/docker-compose.yml | 15 +++++++++------ docker/environments/config.env | 6 +----- docker/environments/local.env | 22 ++++------------------ 3 files changed, 14 insertions(+), 29 deletions(-) diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index f793b10..c320745 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -35,13 +35,15 @@ services: tty: true ports: - "3306:3306" + env_file: + - ${PATH_ENV_CONFIGS}/${SYS_ENV}.env volumes: - "${DB_VOLUME}:/var/lib/mysql" environment: - MYSQL_DATABASE: "${DB_NAME}" - MYSQL_USER: "${DB_USERNAME}" - MYSQL_PASSWORD: "${DB_PASSWORD}" - MYSQL_ROOT_PASSWORD: "${DB_PASSWORD_ROOT}" +# MYSQL_DATABASE: "${DB_NAME}" +# MYSQL_USER: "${DB_USERNAME}" +# MYSQL_PASSWORD: "${DB_PASSWORD}" +# MYSQL_ROOT_PASSWORD: "${DB_PASSWORD_ROOT}" SERVICE_TAGS: dev SERVICE_NAME: mysql @@ -81,7 +83,7 @@ services: image: node:16-alpine working_dir: /var/www/html volumes: - - "${PATH_PROJECT_SOURCE}:/var/www/html" + - "${PATH_PROJECT_SOURCE}:/var/www/html" entrypoint: ['npm'] # Container: Artisan @@ -94,10 +96,11 @@ services: dockerfile: containers/php/Dockerfile image: artisan:laravel-5.8 env_file: + - ${PATH_ENV_CONFIGS}/config.env - ${PATH_ENV_CONFIGS}/${SYS_ENV}.env working_dir: /var/www/html volumes: - - "${PATH_PROJECT_SOURCE}:/var/www/html" + - "${PATH_PROJECT_SOURCE}:/var/www/html" depends_on: - mysql entrypoint: ['/var/www/html/artisan'] diff --git a/docker/environments/config.env b/docker/environments/config.env index 414c8bb..0761f7d 100644 --- a/docker/environments/config.env +++ b/docker/environments/config.env @@ -1,5 +1,5 @@ # -# Docker Environment - Local +# Docker Environment Config #============================ # ENVIROMENT @@ -16,8 +16,4 @@ PATH_DATABASE=./volumes/mysql DB_DRIVER=mysql DB_VERSION=5.7.22 DB_PORT=3306 -DB_NAME=db_docker_laravel -DB_USERNAME=dbUserDev -DB_PASSWORD=dbUserDev123 -DB_PASSWORD_ROOT=dbUserRoot123 DB_VOLUME=${PATH_DATABASE}/${DB_DRIVER}_${DB_VERSION} \ No newline at end of file diff --git a/docker/environments/local.env b/docker/environments/local.env index 414c8bb..9fc0326 100644 --- a/docker/environments/local.env +++ b/docker/environments/local.env @@ -2,22 +2,8 @@ # Docker Environment - Local #============================ -# ENVIROMENT -SYS_ENV=local - -# DIRECTORIES / VOLUMES / PATHS -PATH_PROJECT_SOURCE=../src -PATH_NGINX=./containers/nginx -PATH_NGINX_CONFIGS=${PATH_NGINX}/conf.d/default.conf -PATH_ENV_CONFIGS=./environments -PATH_DATABASE=./volumes/mysql - # DATABASE -DB_DRIVER=mysql -DB_VERSION=5.7.22 -DB_PORT=3306 -DB_NAME=db_docker_laravel -DB_USERNAME=dbUserDev -DB_PASSWORD=dbUserDev123 -DB_PASSWORD_ROOT=dbUserRoot123 -DB_VOLUME=${PATH_DATABASE}/${DB_DRIVER}_${DB_VERSION} \ No newline at end of file +MYSQL_DATABASE=db_docker_laravel +MYSQL_USER=dbUserDev +MYSQL_PASSWORD=dbUserDev123 +MYSQL_ROOT_PASSWORD=dbUserRoot123 \ No newline at end of file