From 62552918d0f5ceb877467cea6789345b78c33d5d Mon Sep 17 00:00:00 2001 From: Oliver Date: Thu, 12 Jun 2025 08:40:50 +1000 Subject: [PATCH] Add devcontainer flag (#9758) --- .devcontainer/docker-compose.yml | 1 + tasks.py | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index 855a247a8d..db09493562 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -38,6 +38,7 @@ services: INVENTREE_SITE_URL: http://localhost:8000 INVENTREE_CORS_ORIGIN_ALLOW_ALL: True INVENTREE_PY_ENV: /home/inventree/dev/venv + INVENTREE_DEVCONTAINER: True depends_on: - db diff --git a/tasks.py b/tasks.py index 8a5c93092e..03e583f823 100644 --- a/tasks.py +++ b/tasks.py @@ -22,6 +22,11 @@ def is_true(x): return str(x).strip().lower() in ['1', 'y', 'yes', 't', 'true', 'on'] +def is_devcontainer_environment(): + """Check if the InvenTree environment is running in a development container.""" + return is_true(os.environ.get('INVENTREE_DEVCONTAINER', 'False')) + + def is_docker_environment(): """Check if the InvenTree environment is running in a Docker container.""" return is_true(os.environ.get('INVENTREE_DOCKER', 'False')) @@ -217,7 +222,7 @@ def envcheck_invoke_cmd(): intendded = ['/bin/invoke', '/bin/inv'] correct_cmd: Optional[str] = None - if is_rtd_environment() or is_docker_environment(): + if is_rtd_environment() or is_docker_environment() or is_devcontainer_environment(): pass elif is_pkg_installer(load_content=True) and not is_pkg_installer_by_path(): correct_cmd = 'inventree run invoke'