Skip to content

Commit

Permalink
[CE-320] Change .env file generate method
Browse files Browse the repository at this point in the history
Use envsubst instead sed to replace variable in env template.

Change-Id: Ib4b71a06fefd3de2678f0e1bdcb6c2d7c2295df7
Signed-off-by: Haitao Yue <hightall@me.com>
  • Loading branch information
hightall committed Mar 23, 2018
1 parent 377b139 commit c1c84fe
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 39 deletions.
11 changes: 6 additions & 5 deletions .makerc/email
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# SPDX-License-Identifier: Apache-2.0
# smtp server for send email to user
SMTP_SERVER?=
export SMTP_SERVER?=
# smtp port
SMTP_PORT?=587
export SMTP_PORT?=587
# auth for smtp
SMTP_AUTH_USERNAME?=
SMTP_AUTH_PASSWORD?=
export SMTP_AUTH_USERNAME?=
export SMTP_AUTH_PASSWORD?=
# email address where sent from
FROM_EMAIL?=
export FROM_EMAIL?=
10 changes: 4 additions & 6 deletions .makerc/operator-dashboard
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
# SPDX-License-Identifier: Apache-2.0

# Theme name for admin dashboard basic/vue/react
THEME?=basic
STATIC_FOLDER?=themes\/${THEME}\/static
TEMPLATE_FOLDER?=themes\/${THEME}\/templates
export THEME?=basic
# npm registry repo
NPM_REGISTRY?=https://registry.npmjs.org
export NPM_REGISTRY?=https://registry.npmjs.org
# service running dev/production mode
DEV?=False
export DEV?=False
# whether enable user active, if enable user must be active to use user dashboard
ENABLE_EMAIL_ACTIVE?=False
export ENABLE_EMAIL_ACTIVE?=False

NPM_REGISTRY_REPLACE=$(subst $(SLASH),$(REPLACE_SLASH),$(NPM_REGISTRY))

Expand Down
3 changes: 2 additions & 1 deletion .makerc/user-dashboard
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# SPDX-License-Identifier: Apache-2.0
# web site url for user active link
ROOT_URL?=
export ROOT_URL?=
WEBROOT=$(subst $(SLASH),$(REPLACE_SLASH),$(ROOT_URL))
15 changes: 1 addition & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -189,20 +189,7 @@ image-clean: clean ##@Clean all existing images to rebuild
docker images | grep "hyperledger/cello-" | awk '{print $3}' | xargs docker rmi -f

initial-env: ##@Configuration Initial Configuration for dashboard
cp default.env .env
$(SED) 's/\(STATIC_FOLDER=\).*/\1${STATIC_FOLDER}/' .env
$(SED) 's/\(TEMPLATE_FOLDER=\).*/\1${TEMPLATE_FOLDER}/' .env
$(SED) 's/\(NPM_REGISTRY=\).*/\1${NPM_REGISTRY_REPLACE}/' .env
$(SED) 's/\(DEV=\).*/\1${DEV}/' .env
$(SED) 's/\(ROOT_PATH=\).*/\1${ROOT_PATH_REPLACE}/' .env
$(SED) 's/\(ENABLE_EMAIL_ACTIVE=\).*/\1${ENABLE_EMAIL_ACTIVE}/' .env
$(SED) 's/\(SMTP_SERVER=\).*/\1${SMTP_SERVER}/' .env
$(SED) 's/\(SMTP_PORT=\).*/\1${SMTP_PORT}/' .env
$(SED) 's/\(SMTP_AUTH_USERNAME=\).*/\1${SMTP_AUTH_USERNAME}/' .env
$(SED) 's/\(SMTP_AUTH_PASSWORD=\).*/\1${SMTP_AUTH_PASSWORD}/' .env
$(SED) 's/\(FROM_EMAIL=\).*/\1${FROM_EMAIL}/' .env
$(SED) 's/\(WEBROOT=\).*/\1${WEBROOT}/' .env
$(SED) 's/\(THEME=\).*/\1${THEME}/' .env
@envsubst < env.tmpl > .env

start: ##@Service Start service
@$(MAKE) $(START_OPTIONS)
Expand Down
13 changes: 0 additions & 13 deletions default.env

This file was deleted.

14 changes: 14 additions & 0 deletions env.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# SPDX-License-Identifier: Apache-2.0
STATIC_FOLDER=themes/$THEME/static
TEMPLATE_FOLDER=themes/$THEME/templates
NPM_REGISTRY=$NPM_REGISTRY
DEV=$DEV
ROOT_PATH=$ROOT_PATH
ENABLE_EMAIL_ACTIVE=$ENABLE_EMAIL_ACTIVE
SMTP_SERVER=$SMTP_SERVER
SMTP_PORT=$SMTP_PORT
SMTP_AUTH_USERNAME=$SMTP_AUTH_USERNAME
SMTP_AUTH_PASSWORD=$SMTP_AUTH_PASSWORD
FROM_EMAIL=$FROM_EMAIL
WEBROOT=$ROOT_URL
THEME=$THEME

0 comments on commit c1c84fe

Please sign in to comment.