Change dev environment setup to use postgresql

- sqlite causes too many errors
- fix requirements file
- fixes for docker setup
- A lot of concurrency issues
- Bite the bullet, time to go!
This commit is contained in:
Oliver 2021-12-21 00:34:23 +11:00
parent 189f836e47
commit 11d3cd3c0c
7 changed files with 37 additions and 17 deletions

View File

@ -101,7 +101,7 @@ RUN chown -R inventree:inventreegroup ${INVENTREE_HOME}/*
USER inventree USER inventree
# Install InvenTree packages # Install InvenTree packages
RUN pip3 install --no-cache-dir --disable-pip-version-check -r ${INVENTREE_HOME}/requirements.txt RUN pip3 install --user --no-cache-dir --disable-pip-version-check -r ${INVENTREE_HOME}/requirements.txt
# Need to be running from within this directory # Need to be running from within this directory
WORKDIR ${INVENTREE_MNG_DIR} WORKDIR ${INVENTREE_MNG_DIR}

View File

@ -2,14 +2,13 @@
# Set DEBUG to False for a production environment! # Set DEBUG to False for a production environment!
INVENTREE_DEBUG=True INVENTREE_DEBUG=True
# Change verbosity level for debug output
INVENTREE_DEBUG_LEVEL=INFO INVENTREE_DEBUG_LEVEL=INFO
# Database linking options # Database configuration options
INVENTREE_DB_ENGINE=sqlite3 # Note: The example setup is for a PostgreSQL database (change as required)
INVENTREE_DB_NAME=/home/inventree/dev/inventree_db.sqlite3 INVENTREE_DB_ENGINE=postgresql
# INVENTREE_DB_HOST=hostaddress INVENTREE_DB_NAME=inventree
# INVENTREE_DB_PORT=5432 INVENTREE_DB_HOST=inventree-dev-db
# INVENTREE_DB_USERNAME=dbuser INVENTREE_DB_PORT=5432
# INVENTREE_DB_PASSWEORD=dbpassword INVENTREE_DB_USER=pguser
INVENTREE_DB_PASSWORD=pgpassword

View File

@ -1,8 +1,10 @@
version: "3.8" version: "3.8"
# Docker compose recipe for InvenTree development server # Docker compose recipe for InvenTree development server
# - Runs sqlite3 as the database backend # - Runs PostgreSQL as the database backend
# - Uses built-in django webserver # - Uses built-in django webserver
# - Runs the InvenTree background worker process
# - Serves media and static content directly from Django webserver
# IMPORANT NOTE: # IMPORANT NOTE:
# The InvenTree docker image does not clone source code from git. # The InvenTree docker image does not clone source code from git.
@ -11,10 +13,32 @@ version: "3.8"
# The django server will auto-detect any code changes and reload the server. # The django server will auto-detect any code changes and reload the server.
services: services:
# Database service
# Use PostgreSQL as the database backend
# Note: This can be changed to a different backend if required
inventree-dev-db:
container_name: inventree-dev-db
image: postgres:13
ports:
- 5432/tcp
environment:
- PGDATA=/var/lib/postgresql/data/dev/pgdb
# The pguser and pgpassword values must be the same in the other containers
# Ensure that these are correctly configured in your dev-config.env file
- POSTGRES_USER=pguser
- POSTGRES_PASSWORD=pgpassword
volumes:
# Map 'data' volume such that postgres database is stored externally
- src:/var/lib/postgresql/data
restart: unless-stopped
# InvenTree web server services # InvenTree web server services
# Uses gunicorn as the web server # Uses gunicorn as the web server
inventree-dev-server: inventree-dev-server:
container_name: inventree-dev-server container_name: inventree-dev-server
depends_on:
- inventree-dev-db
build: build:
context: . context: .
target: dev target: dev

View File

@ -27,7 +27,7 @@ fi
if [[ -n "$INVENTREE_PY_ENV" ]]; then if [[ -n "$INVENTREE_PY_ENV" ]]; then
echo "Using Python virtual environment: ${INVENTREE_PY_ENV}" echo "Using Python virtual environment: ${INVENTREE_PY_ENV}"
# Setup a virtual environment (within the "dev" directory) # Setup a virtual environment (within the "dev" directory)
python3 -m venv ${INVENTREE_PY_ENV} python3 -m venv ${INVENTREE_PY_ENV} --system-site-packages
# Activate the virtual environment # Activate the virtual environment
source ${INVENTREE_PY_ENV}/bin/activate source ${INVENTREE_PY_ENV}/bin/activate

View File

@ -6,7 +6,7 @@
INVENTREE_DEBUG=False INVENTREE_DEBUG=False
INVENTREE_LOG_LEVEL=WARNING INVENTREE_LOG_LEVEL=WARNING
# Database configuration # Database configuration options
# Note: The example setup is for a PostgreSQL database (change as required) # Note: The example setup is for a PostgreSQL database (change as required)
INVENTREE_DB_ENGINE=postgresql INVENTREE_DB_ENGINE=postgresql
INVENTREE_DB_NAME=inventree INVENTREE_DB_NAME=inventree

View File

@ -4,13 +4,9 @@
setuptools>=57.4.0 setuptools>=57.4.0
wheel>=0.37.0 wheel>=0.37.0
invoke>=1.4.0 # Invoke build tool invoke>=1.4.0 # Invoke build tool
gunicorn>=20.1.0 # Gunicorn web server
# Database links # Database links
psycopg2>=2.9.1 psycopg2>=2.9.1
mysqlclient>=2.0.3 mysqlclient>=2.0.3
pgcli>=3.1.0 pgcli>=3.1.0
mariadb>=1.0.7 mariadb>=1.0.7
# Cache
django-redis>=5.0.0

View File

@ -21,6 +21,7 @@ django-markdownify==0.8.0 # Markdown rendering
django-markdownx==3.0.1 # Markdown form fields django-markdownx==3.0.1 # Markdown form fields
django-money==1.1 # Django app for currency management django-money==1.1 # Django app for currency management
django-mptt==0.11.0 # Modified Preorder Tree Traversal django-mptt==0.11.0 # Modified Preorder Tree Traversal
django-redis>=5.0.0
django-q==1.3.4 # Background task scheduling django-q==1.3.4 # Background task scheduling
django-sql-utils==0.5.0 # Advanced query annotation / aggregation django-sql-utils==0.5.0 # Advanced query annotation / aggregation
django-stdimage==5.1.1 # Advanced ImageField management django-stdimage==5.1.1 # Advanced ImageField management