mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Improvements to development docker-compose script
- Python packages are installed in a virtual environment within the src dir - This prevents a LONG installation process each time the docker image is rebuilt
This commit is contained in:
parent
914db9e913
commit
3381c5e257
@ -430,11 +430,15 @@ It can be specified in config.yaml (or envvar) as either (for example):
|
|||||||
- django.db.backends.postgresql
|
- 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
|
# 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_config['ENGINE'] = db_engine
|
||||||
|
|
||||||
db_name = db_config['NAME']
|
db_name = db_config['NAME']
|
||||||
|
@ -86,11 +86,9 @@ COPY gunicorn.conf.py ${INVENTREE_HOME}/gunicorn.conf.py
|
|||||||
|
|
||||||
# Copy startup scripts
|
# Copy startup scripts
|
||||||
COPY start_prod_server.sh ${INVENTREE_SRC_DIR}/start_prod_server.sh
|
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
|
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_prod_server.sh
|
||||||
RUN chmod 755 ${INVENTREE_SRC_DIR}/start_dev_server.sh
|
|
||||||
RUN chmod 755 ${INVENTREE_SRC_DIR}/start_worker.sh
|
RUN chmod 755 ${INVENTREE_SRC_DIR}/start_worker.sh
|
||||||
|
|
||||||
# exec commands should be executed from the "src" directory
|
# exec commands should be executed from the "src" directory
|
||||||
@ -100,7 +98,13 @@ WORKDIR ${INVENTREE_SRC_DIR}
|
|||||||
CMD ["bash", "./start_prod_server.sh"]
|
CMD ["bash", "./start_prod_server.sh"]
|
||||||
|
|
||||||
FROM base as dev
|
FROM base as dev
|
||||||
|
|
||||||
# The development image requires the source code to be mounted to /home/inventree/src/
|
# The development image requires the source code to be mounted to /home/inventree/src/
|
||||||
# So from here, we don't actually "do" anything
|
# So from here, we don't actually "do" anything
|
||||||
|
|
||||||
WORKDIR ${INVENTREE_SRC_DIR}
|
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"]
|
||||||
|
@ -15,46 +15,46 @@ services:
|
|||||||
# Uses gunicorn as the web server
|
# Uses gunicorn as the web server
|
||||||
inventree-server:
|
inventree-server:
|
||||||
container_name: inventree-server
|
container_name: inventree-server
|
||||||
image: inventree/inventree:latest
|
build:
|
||||||
entrypoint: ./start_dev_server.sh
|
context: .
|
||||||
|
target: dev
|
||||||
ports:
|
ports:
|
||||||
- 8000
|
- 8000
|
||||||
depends_on:
|
|
||||||
- inventree-db
|
|
||||||
volumes:
|
volumes:
|
||||||
# Ensure you specify the location of the 'src' directory at the end of this file
|
# Ensure you specify the location of the 'src' directory at the end of this file
|
||||||
- src:/home/inventree/src
|
- src:/home/inventree/src
|
||||||
- data:/home/inventree/data
|
|
||||||
- static:/home/inventree/static
|
|
||||||
environment:
|
environment:
|
||||||
# Configure a simple sqlite server for development
|
# Configure a simple sqlite server for development
|
||||||
# Note: You can always change to a different database backend if required!
|
# Note: You can always change to a different database backend if required!
|
||||||
- INVENTREE_DB_ENGINE=sqlite
|
- INVENTREE_DB_ENGINE=sqlite3
|
||||||
- INVENTREE_DB_NAME=inventree
|
- 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
|
restart: unless-stopped
|
||||||
|
|
||||||
# Background worker process handles long-running or periodic tasks
|
# Background worker process handles long-running or periodic tasks
|
||||||
inventree-worker:
|
inventree-worker:
|
||||||
container_name: inventree-worker
|
container_name: inventree-worker
|
||||||
image: inventree/inventree:latest
|
build:
|
||||||
entrypoint: ./start_worker.sh
|
context: .
|
||||||
depends_on:
|
target: dev
|
||||||
- inventree-db
|
entrypoint: invoke worker
|
||||||
- inventree-server
|
- inventree-server
|
||||||
volumes:
|
volumes:
|
||||||
# Ensure you specify the location of the 'src' directory at the end of this file
|
# Ensure you specify the location of the 'src' directory at the end of this file
|
||||||
- data:/home/inventree/data
|
- src:/home/inventree/src
|
||||||
- static:/home/inventree/static
|
|
||||||
environment:
|
environment:
|
||||||
# Configure a simple sqlite server for development
|
# Configure a simple sqlite server for development
|
||||||
# Note: You can always change to a different database backend if required!
|
# Note: You can always change to a different database backend if required!
|
||||||
- INVENTREE_DB_ENGINE=sqlite
|
- INVENTREE_DB_ENGINE=sqlite3
|
||||||
- INVENTREE_DB_NAME=inventree
|
- 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
|
restart: unless-stopped
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
# NOTE: Change /path/to/src to a directory on your local machine, where the InvenTree source code is located
|
# 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)
|
# Persistent data, stored external to the container(s)
|
||||||
src:
|
src:
|
||||||
driver: local
|
driver: local
|
||||||
@ -63,8 +63,4 @@ volumes:
|
|||||||
o: bind
|
o: bind
|
||||||
# This directory specified where InvenTree source code is stored "outside" the docker containers
|
# This directory specified where InvenTree source code is stored "outside" the docker containers
|
||||||
# Note: This directory must conatin the file *manage.py*
|
# Note: This directory must conatin the file *manage.py*
|
||||||
device: /path/to/src
|
device: /path/to/inventree/src
|
||||||
# Uploaded data / media files, shared between containers
|
|
||||||
data:
|
|
||||||
# Static files, shared between containers
|
|
||||||
static:
|
|
||||||
|
@ -19,6 +19,14 @@ else
|
|||||||
cp $INVENTREE_SRC_DIR/InvenTree/config_template.yaml $INVENTREE_CONFIG_FILE
|
cp $INVENTREE_SRC_DIR/InvenTree/config_template.yaml $INVENTREE_CONFIG_FILE
|
||||||
fi
|
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..."
|
echo "Starting InvenTree server..."
|
||||||
|
|
||||||
# Wait for the database to be ready
|
# Wait for the database to be ready
|
||||||
|
Loading…
Reference in New Issue
Block a user