All "development" related stuff now goes under ./dev

- Update dev-config.env
- Update docker-compose.dev.yml
- Development target of Dockerfile no longer creates any folders
- Update entry point scripts
This commit is contained in:
Oliver Walters 2021-06-15 23:05:03 +10:00
parent 8da00c6106
commit 01328075ea
6 changed files with 38 additions and 35 deletions

5
.gitignore vendored
View File

@ -61,4 +61,7 @@ secret_key.txt
# Coverage reports
.coverage
htmlcov/
htmlcov/
# Development files
.dev/

View File

@ -101,14 +101,11 @@ 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
# The development image requires the source code to be mounted to /home/inventree/
# So from here, we don't actually "do" anything, apart from some file management
WORKDIR ${INVENTREE_SRC_DIR}
ENV INVENTREE_DEV_DIR = "${INVENTREE_HOME}/dev"
COPY start_dev_server.sh ${INVENTREE_HOME}/start_dev_server.sh
COPY start_dev_worker.sh ${INVENTREE_HOME}/start_dev_worker.sh
RUN chmod 755 ${INVENTREE_HOME}/start_dev_server.sh
RUN chmod 755 ${INVENTREE_HOME}/start_dev_worker.sh
WORKDIR ${INVENTREE_HOME}
CMD ["bash", "/home/inventree/start_dev_server.sh"]
CMD ["bash", "/home/inventree/docker/start_dev_server.sh"]

View File

@ -1,7 +1,9 @@
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
INVENTREE_DB_NAME=/home/inventree/dev/inventree_db.sqlite3
INVENTREE_MEDIA_ROOT=/home/inventree/dev/media
INVENTREE_STATIC_ROOT=/home/inventree/dev/static
INVENTREE_CONFIG_FILE=/home/inventree/dev/config.yaml
INVENTREE_SECRET_KEY_FILE=/home/inventree/dev/secret_key.txt
INVENTREE_DEBUG=true
INVENTREE_WEB_ADDR=127.0.0.1
INVENTREE_WEB_PORT=8000

View File

@ -13,8 +13,8 @@ version: "3.8"
services:
# InvenTree web server services
# Uses gunicorn as the web server
inventree-server:
container_name: inventree-server
inventree-dev-server:
container_name: inventree-dev-server
build:
context: .
target: dev
@ -22,7 +22,7 @@ services:
- 8000:8000
volumes:
# Ensure you specify the location of the 'src' directory at the end of this file
- src:/home/inventree/src
- src:/home/inventree
env_file:
# Environment variables required for the dev server are configured in dev-config.env
- dev-config.env
@ -30,17 +30,17 @@ services:
restart: unless-stopped
# Background worker process handles long-running or periodic tasks
inventree-worker:
container_name: inventree-worker
inventree-dev-worker:
container_name: inventree-dev-worker
build:
context: .
target: dev
entrypoint: /home/inventree/start_dev_worker.sh
entrypoint: /home/inventree/docker/start_dev_worker.sh
depends_on:
- inventree-server
- inventree-dev-server
volumes:
# Ensure you specify the location of the 'src' directory at the end of this file
- src:/home/inventree/src
- src:/home/inventree
env_file:
# Environment variables required for the dev server are configured in dev-config.env
- dev-config.env
@ -55,5 +55,5 @@ volumes:
type: none
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/inventree/src
# By default, this directory is one level above the "docker" directory
device: ../

View File

@ -16,21 +16,22 @@ if test -f "$INVENTREE_CONFIG_FILE"; then
echo "$INVENTREE_CONFIG_FILE exists - skipping"
else
echo "Copying config file to $INVENTREE_CONFIG_FILE"
cp $INVENTREE_SRC_DIR/InvenTree/config_template.yaml $INVENTREE_CONFIG_FILE
cp $INVENTREE_HOME/InvenTree/config_template.yaml $INVENTREE_CONFIG_FILE
fi
# Setup a virtual environment
python3 -m venv inventree-docker-dev
# Setup a virtual environment (within the "dev" directory)
python3 -m venv ./dev/env
source inventree-docker-dev/bin/activate
# Activate the virtual environment
source ./dev/env/bin/activate
echo "Installing required packages..."
pip install --no-cache-dir -U -r ${INVENTREE_SRC_DIR}/requirements.txt
pip install --no-cache-dir -U -r ${INVENTREE_HOME}/requirements.txt
echo "Starting InvenTree server..."
# Wait for the database to be ready
cd $INVENTREE_MNG_DIR
cd ${INVENTREE_HOME}/InvenTree
python manage.py wait_for_db
sleep 10
@ -45,4 +46,4 @@ python manage.py migrate --run-syncdb || exit 1
python manage.py clearsessions || exit 1
# Launch a development server
python manage.py runserver 0.0.0.0:$INVENTREE_WEB_PORT
python manage.py runserver ${INVENTREE_WEB_ADDR}:${INVENTREE_WEB_PORT}

View File

@ -2,15 +2,15 @@
echo "Starting InvenTree worker..."
cd $INVENTREE_SRC_DIR
cd $INVENTREE_HOME
# Activate virtual environment
source inventree-docker-dev/bin/activate
source ./dev/env/bin/activate
sleep 5
# Wait for the database to be ready
cd $INVENTREE_MNG_DIR
cd InvenTree
python manage.py wait_for_db
sleep 10