InvenTree/docker/init.sh
Oliver 6b659ba22f
Improvements for docker / gunicorn (#4031)
* Additional options for gunicorn configuration file (in docker):

Ref: https://pythonspeed.com/articles/gunicorn-in-docker/

* Catch potential error on startup

* Tweak log message for docker

* Wrap news feed update in try block
2022-12-08 23:06:02 +11:00

51 lines
1.5 KiB
Bash

#!/bin/bash
# exit when any command fails
set -e
# Create required directory structure (if it does not already exist)
if [[ ! -d "$INVENTREE_STATIC_ROOT" ]]; then
echo "Creating directory $INVENTREE_STATIC_ROOT"
mkdir -p $INVENTREE_STATIC_ROOT
fi
if [[ ! -d "$INVENTREE_MEDIA_ROOT" ]]; then
echo "Creating directory $INVENTREE_MEDIA_ROOT"
mkdir -p $INVENTREE_MEDIA_ROOT
fi
if [[ ! -d "$INVENTREE_BACKUP_DIR" ]]; then
echo "Creating directory $INVENTREE_BACKUP_DIR"
mkdir -p $INVENTREE_BACKUP_DIR
fi
# Check if "config.yaml" has been copied into the correct location
if test -f "$INVENTREE_CONFIG_FILE"; then
echo "Loading config file : $INVENTREE_CONFIG_FILE"
else
echo "Copying config file to $INVENTREE_CONFIG_FILE"
cp $INVENTREE_HOME/InvenTree/config_template.yaml $INVENTREE_CONFIG_FILE
fi
# Setup a python virtual environment
# This should be done on the *mounted* filesystem,
# so that the installed modules persist!
if [[ -n "$INVENTREE_PY_ENV" ]]; then
echo "Using Python virtual environment: ${INVENTREE_PY_ENV}"
# Setup a virtual environment (within the "dev" directory)
python3 -m venv ${INVENTREE_PY_ENV} --system-site-packages
# Activate the virtual environment
source ${INVENTREE_PY_ENV}/bin/activate
# Note: Python packages will have to be installed on first run
# e.g docker-compose run inventree-dev-server invoke update
fi
cd ${INVENTREE_HOME}
# Collect translation file stats
invoke translate-stats
# Launch the CMD *after* the ENTRYPOINT completes
exec "$@"