From c5daa761024f799ee4d918e157062d49cbac7ada Mon Sep 17 00:00:00 2001 From: Jonathan Bernard Date: Sun, 9 Feb 2020 00:30:38 -0600 Subject: [PATCH] web: Parameterize build process with env-dependent config files. --- api/src/main/nim/personal_measure_api.nim | 2 +- web/.env.dev | 3 +++ web/.env.prod | 1 + web/.env.production | 2 +- web/Makefile | 22 +++++----------------- 5 files changed, 11 insertions(+), 19 deletions(-) create mode 100644 web/.env.dev create mode 120000 web/.env.prod diff --git a/api/src/main/nim/personal_measure_api.nim b/api/src/main/nim/personal_measure_api.nim index 0b8120f..a45864e 100644 --- a/api/src/main/nim/personal_measure_api.nim +++ b/api/src/main/nim/personal_measure_api.nim @@ -47,7 +47,7 @@ proc loadConfig*(args: Table[string, docopt.Value] = initTable[string, docopt.Va port: parseInt(cfg.getVal("port", "8080")), pwdCost: cast[int8](parseInt(cfg.getVal("pwd-cost", "11"))), knownOrigins: toSeq(knownOriginsArray).mapIt(it.getStr)) - + proc initContext(args: Table[string, docopt.Value]): PMApiContext = var cfg: PMApiConfig diff --git a/web/.env.dev b/web/.env.dev new file mode 100644 index 0000000..c9f9d44 --- /dev/null +++ b/web/.env.dev @@ -0,0 +1,3 @@ +VUE_APP_PM_API_BASE=https://pmapi-dev.jdb-labs.com/api +VUE_APP_LOG_LEVEL=INFO +VUE_APP_API_LOG_LEVEL=ERROR diff --git a/web/.env.prod b/web/.env.prod new file mode 120000 index 0000000..f4b7f93 --- /dev/null +++ b/web/.env.prod @@ -0,0 +1 @@ +.env.production \ No newline at end of file diff --git a/web/.env.production b/web/.env.production index 67ce248..6563647 100644 --- a/web/.env.production +++ b/web/.env.production @@ -1,3 +1,3 @@ -VUE_APP_PM_API_BASE=https://pm.jdb-labs.com/api +VUE_APP_PM_API_BASE=https://pmapi.jdb-labs.com/api VUE_APP_LOG_LEVEL=INFO VUE_APP_API_LOG_LEVEL=ERROR diff --git a/web/Makefile b/web/Makefile index 2581faa..9ae1766 100644 --- a/web/Makefile +++ b/web/Makefile @@ -1,23 +1,11 @@ -API_LOG_LEVEL='WARN' -LOG_LEVEL='TRACE' - -build-dev: - npm run build-dev - build: + pwd; \ + . .env.${TARGET_ENV}; \ + echo "Using API URL: ${VUE_APP_PM_API_BASE}"; \ npm run build serve: VUE_APP_PM_API_BASE=/api \ - VUE_APP_API_LOG_LEVEL=${API_LOG_LEVEL} \ - VUE_APP_LOG_LEVEL=${LOG_LEVEL} \ + VUE_APP_API_LOG_LEVEL=WARN \ + VUE_APP_LOG_LEVEL=TRACE \ npm run serve - -serve-dev: build-dev - (cd dist && npx live-server . --port=8080 --entry-file=index.html --proxy=/api:http://localhost:8081/api --no-browser) - -serve-ssl: build-dev - (cd dist && \ - (local-ssl-proxy --source=8443 --target=8080 & \ - echo `pwd` && \ - npx live-server . --port=8080 --entry-file=index.html --proxy=/api:http://localhost:8081/api --no-browser))