2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-12 01:55:39 +00:00

Add option to specify config file via environment variable

This commit is contained in:
Oliver Walters
2021-04-07 23:46:03 +10:00
parent 9c38d67b52
commit d4d9263131
4 changed files with 23 additions and 17 deletions

View 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"]

View File

@ -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

View File

@ -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