mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add option to specify config file via environment variable
This commit is contained in:
parent
9c38d67b52
commit
d4d9263131
@ -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")
|
||||
|
@ -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"]
|
||||
|
@ -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
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user