From 87f0a8d4968056d8051ee9cc8ddd5223bb004e2c Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Wed, 13 May 2020 18:27:04 -0600 Subject: [PATCH] Added volume mounted config to Dockerfile (#39) --- Dockerfile | 5 +++++ app/routes.py | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4a8acf5..f3438aa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,6 +5,11 @@ RUN apt-get update && apt-get install -y build-essential libcurl4-openssl-dev li COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt +ARG config_dir=/config +RUN mkdir $config_dir +VOLUME $config_dir +ENV CONFIG_VOLUME=$config_dir + COPY . . EXPOSE 5000 diff --git a/app/routes.py b/app/routes.py index 6b48473..4fa3c93 100644 --- a/app/routes.py +++ b/app/routes.py @@ -15,7 +15,7 @@ import waitress app.config['APP_ROOT'] = os.getenv('APP_ROOT', os.path.dirname(os.path.abspath(__file__))) app.config['STATIC_FOLDER'] = os.getenv('STATIC_FOLDER', os.path.join(app.config['APP_ROOT'], 'static')) -CONFIG_PATH = app.config['STATIC_FOLDER'] + '/config.json' +CONFIG_PATH = os.getenv('CONFIG_VOLUME', app.config['STATIC_FOLDER']) + '/config.json' @app.before_request @@ -96,7 +96,7 @@ def config(): if 'url' not in config_data or not config_data['url']: config_data['url'] = request.url_root - with open(app.config['STATIC_FOLDER'] + '/config.json', 'w') as config_file: + with open(CONFIG_PATH, 'w') as config_file: config_file.write(json.dumps(config_data, indent=4)) config_file.close()