From 00c5a883838b5d72aff0e9ff3636a5a4099b99ee Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Wed, 12 May 2021 21:15:53 +1000 Subject: [PATCH] Split environment variables out into a .env file - No need to collect "static" file when we are running in DEBUG mode --- .gitignore | 1 + docker/dev-config.env | 7 +++++++ docker/docker-compose.dev.yml | 22 +++++++--------------- docker/start_dev_server.sh | 6 ++---- 4 files changed, 17 insertions(+), 19 deletions(-) create mode 100644 docker/dev-config.env diff --git a/.gitignore b/.gitignore index 54ad8f07b6..7c360a8231 100644 --- a/.gitignore +++ b/.gitignore @@ -31,6 +31,7 @@ var/ *.log local_settings.py *.sqlite3 +*.sqlite3-journal *.backup *.old diff --git a/docker/dev-config.env b/docker/dev-config.env new file mode 100644 index 0000000000..200c3db479 --- /dev/null +++ b/docker/dev-config.env @@ -0,0 +1,7 @@ +INVENTREE_DB_ENGINE=sqlite3 +INVENTREE_DB_NAME=/home/inventree/src/inventree_docker_dev.sqlite3 +INVENTREE_MEDIA_ROOT=/home/inventree/src/inventree_media +INVENTREE_STATIC_ROOT=/home/inventree/src/inventree_static +INVENTREE_CONFIG_FILE=/home/inventree/src/config.yaml +INVENTREE_SECRET_KEY_FILE=/home/inventree/src/secret_key.txt +INVENTREE_DEBUG=true \ No newline at end of file diff --git a/docker/docker-compose.dev.yml b/docker/docker-compose.dev.yml index bde7130c70..f03ce45571 100644 --- a/docker/docker-compose.dev.yml +++ b/docker/docker-compose.dev.yml @@ -23,14 +23,10 @@ services: volumes: # Ensure you specify the location of the 'src' directory at the end of this file - src:/home/inventree/src - environment: - # Configure a simple sqlite server for development - # Note: You can always change to a different database backend if required! - - INVENTREE_DB_ENGINE=sqlite3 - - INVENTREE_DB_NAME=/home/inventree/data/inventree_database.sqlite3 - - INVENTREE_MEDIA_ROOT=/home/inventree/src/inventree_media - - INVENTREE_STATIC_ROOT=/home/inventree/src/inventree_static - - INVENTREE_CONFIG_FILE=/home/inventree/src/config.yaml + env_file: + # Environment variables required for the dev server are configured in dev-config.env + - dev-config.env + restart: unless-stopped # Background worker process handles long-running or periodic tasks @@ -44,13 +40,9 @@ services: volumes: # Ensure you specify the location of the 'src' directory at the end of this file - src:/home/inventree/src - environment: - # Configure a simple sqlite server for development - # Note: You can always change to a different database backend if required! - - INVENTREE_DB_ENGINE=sqlite3 - - INVENTREE_DB_NAME=/home/inventree/data/inventree_database.sqlite3 - - INVENTREE_MEDIA_ROOT=/home/inventree/src/inventree_media - - INVENTREE_STATIC_ROOT=/home/inventree/src/inventree_static + env_file: + # Environment variables required for the dev server are configured in dev-config.env + - dev-config.env restart: unless-stopped volumes: diff --git a/docker/start_dev_server.sh b/docker/start_dev_server.sh index 47eb25f9ef..8cf7d10468 100644 --- a/docker/start_dev_server.sh +++ b/docker/start_dev_server.sh @@ -35,16 +35,14 @@ python manage.py wait_for_db sleep 10 -echo "Running InvenTree database migrations and collecting static files..." +echo "Running InvenTree database migrations..." # We assume at this stage that the database is up and running # Ensure that the database schema are up to date python manage.py check || exit 1 python manage.py migrate --noinput || exit 1 python manage.py migrate --run-syncdb || exit 1 -python manage.py prerender || exit 1 -python manage.py collectstatic --noinput || exit 1 python manage.py clearsessions || exit 1 # Launch a development server -python manage.py runserver -a 0.0.0.0:$INVENTREE_WEB_PORT \ No newline at end of file +python manage.py runserver 0.0.0.0:$INVENTREE_WEB_PORT \ No newline at end of file