diff --git a/InvenTree/InvenTree/settings.py b/InvenTree/InvenTree/settings.py index 894332b189..8fc0562059 100644 --- a/InvenTree/InvenTree/settings.py +++ b/InvenTree/InvenTree/settings.py @@ -923,8 +923,7 @@ MARKDOWNIFY_BLEACH = False # Maintenance mode MAINTENANCE_MODE_RETRY_AFTER = 60 - -# Plugins +# Plugin Directories (local plugins will be loaded from these directories) PLUGIN_DIRS = ['plugin.builtin', ] if not TESTING: @@ -935,6 +934,23 @@ if DEBUG or TESTING: # load samples in debug mode PLUGIN_DIRS.append('plugin.samples') +# Check if an external plugin directory has been specified as an environment variable +# Note: This should be specified as INVENTREE_PLUGIN_DIR +plugin_dir = os.getenv('INVENTREE_PLUGIN_DIR') + +if plugin_dir: + if not os.path.exists(plugin_dir): + logger.info(f"Plugin directory '{plugin_dir}' does not exist") + + try: + os.makedirs(plugin_dir, exist_ok=True) + logger.info(f"Created plugin directory '{plugin_dir}'") + except: + logger.warning(f"Could not create plugins directory '{plugin_dir}'") + + if os.path.exists(plugin_dir): + PLUGIN_DIRS.append(plugin_dir) + # Plugin test settings PLUGIN_TESTING = get_setting('PLUGIN_TESTING', TESTING) # are plugins beeing tested? PLUGIN_TESTING_SETUP = get_setting('PLUGIN_TESTING_SETUP', False) # load plugins from setup hooks in testing? diff --git a/docker/Dockerfile b/docker/Dockerfile index 673792a22f..8fd932ff6f 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -30,9 +30,11 @@ ENV INVENTREE_MNG_DIR="${INVENTREE_HOME}/InvenTree" ENV INVENTREE_DATA_DIR="${INVENTREE_HOME}/data" ENV INVENTREE_STATIC_ROOT="${INVENTREE_DATA_DIR}/static" ENV INVENTREE_MEDIA_ROOT="${INVENTREE_DATA_DIR}/media" +ENV INVENTREE_PLUGIN_DIR="${INVENTREE_DATA_DIR}/plugins" ENV INVENTREE_CONFIG_FILE="${INVENTREE_DATA_DIR}/config.yaml" ENV INVENTREE_SECRET_KEY_FILE="${INVENTREE_DATA_DIR}/secret_key.txt" +ENV INVENTREE_PLUGIN_FILE="${INVENTREE_DATA_DIR}}/plugins.txt" # Worker configuration (can be altered by user) ENV INVENTREE_GUNICORN_WORKERS="4"