Skip to content

Commit

Permalink
Add environment variables from config file
Browse files Browse the repository at this point in the history
  • Loading branch information
meghprkh committed Jan 16, 2018
1 parent 70281e4 commit 6dbac7b
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ def getPassword(portal):
os.chdir('../portals')

portals = [ portal for portal in os.listdir('./') if os.path.isdir(portal) ]
portalconfig = {}

print("\n=============== Reading config ===============\n")
for portal in portals:
print("\n##### " + portal + "\n")
try:
portalconfig[portal] = yaml.load(open(portal + '/config.yml'))
except Exception:
portalconfig[portal] = {}


print("\n=============== Building frontend ===============\n")
for portal in portals:
Expand All @@ -41,6 +51,10 @@ def getPassword(portal):
print("\n=============== Making docker compose file ===============\n")
services = {}
for portal in portals:
extraenv = []
for key, value in portalconfig[portal].iteritems():
extraenv.append("%s=\"%s\"" % (key, value))

services[portal + '_backend'] = {
"image": "node:8",
"working_dir": "/home/node/app",
Expand All @@ -49,7 +63,7 @@ def getPassword(portal):
"DBURI=mysql://%s:%s@portaldb/%s" % (portal, getPassword(portal), portal),
"PUBLIC_API_URL=https://felicity.iiit.ac.in/k/%s/api" % portal,
"PUBLIC_FRONTEND_URL=https://felicity.iiit.ac.in/k/%s" % portal,
],
] + extraenv,
"volumes": [ "../portals/%s/backend:/home/node/app" % portal ],
"command": "bash -c 'yarn install && yarn start'"
}
Expand Down

0 comments on commit 6dbac7b

Please sign in to comment.