diff --git a/InvenTree/InvenTree/settings.py b/InvenTree/InvenTree/settings.py index 3f705ae70c..be9a4b729f 100644 --- a/InvenTree/InvenTree/settings.py +++ b/InvenTree/InvenTree/settings.py @@ -55,7 +55,21 @@ TESTING = 'test' in sys.argv # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) -cfg_filename = os.path.join(BASE_DIR, 'config.yaml') +# Specify where the "config file" is located. +# By default, this is 'config.yaml' + +cfg_filename = os.getenv('INVENTREE_CONFIG_FILE') + +if cfg_filename: + cfg_filename = cfg_filename.strip() + cfg_filename = os.path.abspath(cfg_filename) + + if not os.path.exists(cfg_filename): + print(f"InvenTree configuration file '{cfg_filename}' does not exist!") + sys.exit(1) +else: + # Config file is *not* specified - use the default + cfg_filename = os.path.join(BASE_DIR, 'config.yaml') if not os.path.exists(cfg_filename): print("InvenTree configuration file 'config.yaml' not found - creating default file") diff --git a/docker/Dockerfile b/docker/Dockerfile index 3eb62af93b..073698adcd 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -3,7 +3,6 @@ FROM python:alpine as production # GitHub source ARG INVENTREE_REPO="https://github.com/inventree/InvenTree.git" ARG INVENTREE_VERSION="master" -ARG INVENTREE_CONFIG_FILE="InvenTree/config_template.yaml" ENV PYTHONUNBUFFERED 1 @@ -79,18 +78,15 @@ RUN apk add --no-cache supervisor RUN mkdir ${INVENTREE_HOME}/media ${INVENTREE_HOME}/static ${INVENTREE_HOME}/backup # Copy supervisor file -COPY docker/supervisord.conf ${INVENTREE_HOME}/supervisord.conf +COPY supervisord.conf ${INVENTREE_HOME}/supervisord.conf # Copy gunicorn config file -COPY docker/gunicorn.conf.py ${INVENTREE_HOME}/gunicorn.conf.py - -# Copy default InvenTree config file -COPY ${INVENTREE_CONFIG_FILE} ${INVENTREE_SRC_DIR}/InvenTree/config.yaml +COPY gunicorn.conf.py ${INVENTREE_HOME}/gunicorn.conf.py # Copy startup script -COPY docker/start.sh ${INVENTREE_HOME}/start.sh +COPY start.sh ${INVENTREE_HOME}/start.sh RUN chmod 755 ${INVENTREE_HOME}/start.sh # Let us begin -CMD "./start.sh" +CMD ["bash", "./start.sh"] diff --git a/docker/start.sh b/docker/start.sh index 21334d812a..f17150d0ca 100644 --- a/docker/start.sh +++ b/docker/start.sh @@ -1,17 +1,13 @@ #!/bin/sh +echo "Starting InvenTree server..." + # Check that the database engine is specified if [ -z "$INVENTREE_DB_ENGINE" ]; then echo "INVENTREE_DB_ENGINE not configured" exit 1 fi -# Check that the base dir is set -if [ -z "$INVENTREE_HOME" ]; then - echo "INVENTREE_HOME not configured" - exit 1 -fi - # Activate virtual environment source $INVENTREE_VENV/bin/activate @@ -34,4 +30,4 @@ python manage.py collectstatic --noinput || exit 1 python manage.py clearsessions || exit 1 # Now we can launch the server and background worker -/usr/bin/supervisord -c $INVENTREE_HOME/supervisord.conf +/usr/bin/supervisord -c $INVENTREE_HOME/supervisord.conf \ No newline at end of file diff --git a/docker/supervisord.conf b/docker/supervisord.conf index e0eaad4cfb..8dc8e77fc1 100644 --- a/docker/supervisord.conf +++ b/docker/supervisord.conf @@ -19,7 +19,7 @@ nodaemon=true [program:inventree-server] user=inventree directory=%(ENV_INVENTREE_SRC_DIR)s/InvenTree -command=%(ENV_INVENTREE_VENV)s/bin/gunicorn -c %(ENV_INVENTREE_HOME)s/gunicorn.conf.py InvenTree.wsgi -b 0.0.0.0:80 +command=%(ENV_INVENTREE_VENV)s/bin/gunicorn -c %(ENV_INVENTREE_HOME)s/gunicorn.conf.py InvenTree.wsgi -b 0.0.0.0:8080 startsecs=10 autostart=true autorestart=true