mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Adds entrypoint for starting a development server
This commit is contained in:
parent
270c0ea85d
commit
eb108edb60
@ -30,12 +30,14 @@ ENV INVENTREE_SECRET_KEY_FILE="${INVENTREE_DATA_DIR}/secret_key.txt"
|
|||||||
ENV INVENTREE_WEB_PORT="8000"
|
ENV INVENTREE_WEB_PORT="8000"
|
||||||
|
|
||||||
# Pass DB configuration through as environment variables
|
# Pass DB configuration through as environment variables
|
||||||
ENV INVENTREE_DB_ENGINE="${INVENTREE_DB_ENGINE}"
|
# Default configuration = postgresql
|
||||||
ENV INVENTREE_DB_NAME="${INVENTREE_DB_NAME}"
|
ENV INVENTREE_DB_ENGINE="postgresql"
|
||||||
ENV INVENTREE_DB_HOST="${INVENTREE_DB_HOST}"
|
ENV INVENTREE_DB_NAME="inventree"
|
||||||
ENV INVENTREE_DB_PORT="${INVENTREE_DB_PORT}"
|
ENV INVENTREE_DB_HOST="db"
|
||||||
ENV INVENTREE_DB_USER="${INVENTREE_DB_USER}"
|
ENV INVENTREE_DB_PORT="5432"
|
||||||
ENV INVENTREE_DB_PASSWORD="${INVENTREE_DB_PASSWORD}"
|
|
||||||
|
# INVENTREE_DB_USER must be specified at run-time
|
||||||
|
# INVENTREE_DB_PASSWORD must be specified at run-time
|
||||||
|
|
||||||
LABEL org.label-schema.schema-version="1.0" \
|
LABEL org.label-schema.schema-version="1.0" \
|
||||||
org.label-schema.build-date=${DATE} \
|
org.label-schema.build-date=${DATE} \
|
||||||
@ -93,14 +95,16 @@ RUN pip install --no-cache-dir -U -r ${INVENTREE_SRC_DIR}/requirements.txt
|
|||||||
COPY gunicorn.conf.py ${INVENTREE_HOME}/gunicorn.conf.py
|
COPY gunicorn.conf.py ${INVENTREE_HOME}/gunicorn.conf.py
|
||||||
|
|
||||||
# Copy startup scripts
|
# Copy startup scripts
|
||||||
COPY start_server.sh ${INVENTREE_SRC_DIR}/start_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_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
|
||||||
WORKDIR ${INVENTREE_SRC_DIR}
|
WORKDIR ${INVENTREE_SRC_DIR}
|
||||||
|
|
||||||
# Let us begin
|
# Let us begin
|
||||||
CMD ["bash", "./start_server.sh"]
|
CMD ["bash", "./start_prod_server.sh"]
|
||||||
|
@ -12,6 +12,7 @@ version: "3.8"
|
|||||||
# Before running, ensure that you change the "/path/to/data" directory,
|
# Before running, ensure that you change the "/path/to/data" directory,
|
||||||
# specified in the "volumes" section at the end of this file.
|
# specified in the "volumes" section at the end of this file.
|
||||||
# This path determines where the InvenTree data will be stored!
|
# This path determines where the InvenTree data will be stored!
|
||||||
|
#
|
||||||
|
|
||||||
services:
|
services:
|
||||||
# Database service
|
# Database service
|
||||||
@ -25,6 +26,7 @@ services:
|
|||||||
- 5432/tcp
|
- 5432/tcp
|
||||||
environment:
|
environment:
|
||||||
- PGDATA=/var/lib/postgresql/data/pgdb
|
- PGDATA=/var/lib/postgresql/data/pgdb
|
||||||
|
# The pguser and pgpassword values must be the same in the other containers
|
||||||
- POSTGRES_USER=pguser
|
- POSTGRES_USER=pguser
|
||||||
- POSTGRES_PASSWORD=pgpassword
|
- POSTGRES_PASSWORD=pgpassword
|
||||||
volumes:
|
volumes:
|
||||||
@ -44,13 +46,28 @@ services:
|
|||||||
- data:/home/inventree/data
|
- data:/home/inventree/data
|
||||||
- static:/home/inventree/static
|
- static:/home/inventree/static
|
||||||
environment:
|
environment:
|
||||||
- INVENTREE_DB_ENGINE=postgresql
|
# Default environment variables are configured to match the 'db' container
|
||||||
- INVENTREE_DB_NAME=inventree
|
# Database permissions
|
||||||
|
- INVENTREE_DB_USER=pguser
|
||||||
|
- INVENTREE_DB_PASSWORD=pgpassword
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
# background worker process handles long-running or periodic tasks
|
||||||
|
worker:
|
||||||
|
container_name: worker
|
||||||
|
image: inventree/inventree:latest
|
||||||
|
entrypoint: ./start_worker.sh
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
|
- web
|
||||||
|
volumes:
|
||||||
|
- data:/home/inventree/data
|
||||||
|
- static:/home/inventree/static
|
||||||
|
environment:
|
||||||
|
# Default environment variables are configured to match the 'db' container
|
||||||
|
# Database permissions
|
||||||
- INVENTREE_DB_USER=pguser
|
- INVENTREE_DB_USER=pguser
|
||||||
- INVENTREE_DB_PASSWORD=pgpassword
|
- INVENTREE_DB_PASSWORD=pgpassword
|
||||||
- INVENTREE_DB_PORT=5432
|
|
||||||
- INVENTREE_DB_HOST=db
|
|
||||||
- INVENTREE_WEB_PORT=8000
|
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
# nginx acts as a reverse proxy
|
# nginx acts as a reverse proxy
|
||||||
@ -67,33 +84,14 @@ services:
|
|||||||
- 1337:80
|
- 1337:80
|
||||||
volumes:
|
volumes:
|
||||||
# Provide nginx.conf file to the container
|
# Provide nginx.conf file to the container
|
||||||
|
# Refer to the provided example file as a starting point
|
||||||
- ./nginx.conf:/etc/nginx/templates/default.conf.template:ro
|
- ./nginx.conf:/etc/nginx/templates/default.conf.template:ro
|
||||||
# Static data volume is mounted to /var/www/static
|
# Static data volume is mounted to /var/www/static
|
||||||
- static:/var/www/static
|
- static:/var/www/static
|
||||||
|
|
||||||
# background worker process handles long-running or periodic tasks
|
|
||||||
worker:
|
|
||||||
container_name: worker
|
|
||||||
image: inventree/inventree:latest
|
|
||||||
entrypoint: ./start_worker.sh
|
|
||||||
depends_on:
|
|
||||||
- db
|
|
||||||
- web
|
|
||||||
volumes:
|
|
||||||
- data:/home/inventree/data
|
|
||||||
- static:/home/inventree/static
|
|
||||||
environment:
|
|
||||||
- INVENTREE_DB_ENGINE=postgresql
|
|
||||||
- INVENTREE_DB_NAME=inventree
|
|
||||||
- INVENTREE_DB_USER=pguser
|
|
||||||
- INVENTREE_DB_PASSWORD=pgpassword
|
|
||||||
- INVENTREE_DB_PORT=5432
|
|
||||||
- INVENTREE_DB_HOST=db
|
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
# Static files, shared between containers
|
# NOTE: Change /path/to/data to a directory on your local machine
|
||||||
static:
|
|
||||||
# Persistent data, stored externally
|
# Persistent data, stored externally
|
||||||
data:
|
data:
|
||||||
driver: local
|
driver: local
|
||||||
@ -103,3 +101,5 @@ volumes:
|
|||||||
# This directory specified where InvenTree data are stored "outside" the docker containers
|
# This directory specified where InvenTree data are stored "outside" the docker containers
|
||||||
# Change this path to a local system path where you want InvenTree data stored
|
# Change this path to a local system path where you want InvenTree data stored
|
||||||
device: /path/to/data
|
device: /path/to/data
|
||||||
|
# Static files, shared between containers
|
||||||
|
static:
|
46
docker/start_dev_server.sh
Normal file
46
docker/start_dev_server.sh
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Create required directory structure (if it does not already exist)
|
||||||
|
if [[ ! -d "$INVENTREE_STATIC_ROOT" ]]; then
|
||||||
|
echo "Creating directory $INVENTREE_STATIC_ROOT"
|
||||||
|
mkdir $INVENTREE_STATIC_ROOT
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -d "$INVENTREE_MEDIA_ROOT" ]]; then
|
||||||
|
echo "Creating directory $INVENTREE_MEDIA_ROOT"
|
||||||
|
mkdir $INVENTREE_MEDIA_ROOT
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -d "$INVENTREE_BACKUP_DIR" ]]; then
|
||||||
|
echo "Creating directory $INVENTREE_BACKUP_DIR"
|
||||||
|
mkdir $INVENTREE_BACKUP_DIR
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if "config.yaml" has been copied into the correct location
|
||||||
|
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
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Starting InvenTree server..."
|
||||||
|
|
||||||
|
# Wait for the database to be ready
|
||||||
|
cd $INVENTREE_MNG_DIR
|
||||||
|
python manage.py wait_for_db
|
||||||
|
|
||||||
|
sleep 10
|
||||||
|
|
||||||
|
echo "Running InvenTree database migrations and collecting static files..."
|
||||||
|
|
||||||
|
# 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 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
|
Loading…
Reference in New Issue
Block a user