diff --git a/InvenTree/InvenTree/settings.py b/InvenTree/InvenTree/settings.py index cc61748372..5591678e4e 100644 --- a/InvenTree/InvenTree/settings.py +++ b/InvenTree/InvenTree/settings.py @@ -430,11 +430,15 @@ It can be specified in config.yaml (or envvar) as either (for example): - django.db.backends.postgresql """ -db_engine = db_config['ENGINE'] +db_engine = db_config['ENGINE'].lower() -if db_engine.lower() in ['sqlite3', 'postgresql', 'mysql']: +# Correct common misspelling +if db_engine == 'sqlite': + db_engine = 'sqlite3' + +if db_engine in ['sqlite3', 'postgresql', 'mysql']: # Prepend the required python module string - db_engine = f'django.db.backends.{db_engine.lower()}' + db_engine = f'django.db.backends.{db_engine}' db_config['ENGINE'] = db_engine db_name = db_config['NAME'] diff --git a/docker/Dockerfile b/docker/Dockerfile index 504236c131..61defc1607 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -86,11 +86,9 @@ COPY gunicorn.conf.py ${INVENTREE_HOME}/gunicorn.conf.py # Copy startup scripts COPY start_prod_server.sh ${INVENTREE_SRC_DIR}/start_prod_server.sh -COPY start_dev_server.sh ${INVENTREE_SRC_DIR}/start_dev_server.sh COPY start_worker.sh ${INVENTREE_SRC_DIR}/start_worker.sh RUN chmod 755 ${INVENTREE_SRC_DIR}/start_prod_server.sh -RUN chmod 755 ${INVENTREE_SRC_DIR}/start_dev_server.sh RUN chmod 755 ${INVENTREE_SRC_DIR}/start_worker.sh # exec commands should be executed from the "src" directory @@ -100,7 +98,13 @@ WORKDIR ${INVENTREE_SRC_DIR} CMD ["bash", "./start_prod_server.sh"] FROM base as dev + # The development image requires the source code to be mounted to /home/inventree/src/ # So from here, we don't actually "do" anything WORKDIR ${INVENTREE_SRC_DIR} + +COPY start_dev_server.sh ${INVENTREE_HOME}/start_dev_server.sh +RUN chmod 755 ${INVENTREE_HOME}/start_dev_server.sh + +CMD ["bash", "/home/inventree/start_dev_server.sh"] diff --git a/docker/docker-compose.dev.yml b/docker/docker-compose.dev.yml index b2e64f026a..bde7130c70 100644 --- a/docker/docker-compose.dev.yml +++ b/docker/docker-compose.dev.yml @@ -15,46 +15,46 @@ services: # Uses gunicorn as the web server inventree-server: container_name: inventree-server - image: inventree/inventree:latest - entrypoint: ./start_dev_server.sh + build: + context: . + target: dev ports: - 8000 - depends_on: - - inventree-db volumes: # Ensure you specify the location of the 'src' directory at the end of this file - src:/home/inventree/src - - data:/home/inventree/data - - static:/home/inventree/static environment: # Configure a simple sqlite server for development # Note: You can always change to a different database backend if required! - - INVENTREE_DB_ENGINE=sqlite - - INVENTREE_DB_NAME=inventree + - 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 restart: unless-stopped # Background worker process handles long-running or periodic tasks inventree-worker: container_name: inventree-worker - image: inventree/inventree:latest - entrypoint: ./start_worker.sh - depends_on: - - inventree-db + build: + context: . + target: dev + entrypoint: invoke worker - inventree-server volumes: # Ensure you specify the location of the 'src' directory at the end of this file - - data:/home/inventree/data - - static:/home/inventree/static + - 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=sqlite - - INVENTREE_DB_NAME=inventree + - 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 restart: unless-stopped volumes: # NOTE: Change /path/to/src to a directory on your local machine, where the InvenTree source code is located - # This directory must conatin the file *manage.py* # Persistent data, stored external to the container(s) src: driver: local @@ -63,8 +63,4 @@ volumes: o: bind # This directory specified where InvenTree source code is stored "outside" the docker containers # Note: This directory must conatin the file *manage.py* - device: /path/to/src - # Uploaded data / media files, shared between containers - data: - # Static files, shared between containers - static: \ No newline at end of file + device: /path/to/inventree/src diff --git a/docker/start_dev_server.sh b/docker/start_dev_server.sh index c22805b90b..47eb25f9ef 100644 --- a/docker/start_dev_server.sh +++ b/docker/start_dev_server.sh @@ -19,6 +19,14 @@ else cp $INVENTREE_SRC_DIR/InvenTree/config_template.yaml $INVENTREE_CONFIG_FILE fi +# Setup a virtual environment +python3 -m venv inventree-docker-dev + +source inventree-docker-dev/bin/activate + +echo "Installing required packages..." +pip install --no-cache-dir -U -r ${INVENTREE_SRC_DIR}/requirements.txt + echo "Starting InvenTree server..." # Wait for the database to be ready