-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #402 from VoSeq/multidocker
Multidocker
- Loading branch information
Showing
2 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# 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 | ||
|
||
ins_db: | ||
name: ins_db | ||
http_port: 8082 | ||
https_port: 4432 | ||
|
||
lepidoptera: | ||
name: lepidoptera | ||
http_port: 8083 | ||
https_port: 4433 |