Skip to content

Commit

Permalink
added script to generate docker ifles
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosp420 committed Oct 21, 2020
1 parent c7a83a7 commit 88facc0
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
46 changes: 46 additions & 0 deletions generate_docker_files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import argparse
import sys
import yaml


def open_file(app_name):
with open("voseq_apps.yml", "r") as handle:
data = yaml.load(handle.read(), Loader=yaml.FullLoader)

if app_name not in data:
sys.exit(f'{app_name} not found in available apps {list(data.keys())}')

app_data = data[app_name]

files_and_data = [
# file, data to replace, data to replace with
('run/docker/.env', 'voseq', app_name),
('run/docker/postgres/init-user-db.sh', 'voseq', app_name),
('run/docker/docker-compose.yml', '8081', app_data['http_port']),
('run/docker/docker-compose.yml', '4431', app_data['https_port']),
]
for item in files_and_data:
with open(item[0], 'r') as handle:
data = handle.read()

data = data.replace(item[1], str(item[2]))
with open(item[0], 'w') as handle:
handle.write(data)


def main():
parser = argparse.ArgumentParser(description="Generate docker files")
parser.add_argument(
'-a',
'--app_name',
dest="app_name",
action="store",
required=True,
)
args = parser.parse_args()
print(f'Will generate docker files for app "{args.app_name}"')
open_file(args.app_name)


if __name__ == "__main__":
main()
15 changes: 15 additions & 0 deletions voseq_apps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This is a list of app names that can be used to generate docker files and ports
# so that we can run several Voseq installations in a single server without
# port or name conflicts.
# Write here the apps that you want to install in your single server.
# Run the script to regenerate such files (under the run folder) in case they
# get overwritten by updates to the Voseq repository.
#
# Usage:
# python generate_docker_files.py APP_NAME

# default app
voseq:
name: voseq
http_port: 8081
https_port: 4431

0 comments on commit 88facc0

Please sign in to comment.