mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Simplify external directory structure
- All InvenTree data now in a single subdir - Copy default config file (if it does not exist) - Config file is accessible from outside world - Update start_server and start_worker scripts
This commit is contained in:
parent
1372343bd5
commit
9086c8a3bf
@ -18,12 +18,14 @@ ENV INVENTREE_LOG_LEVEL="INFO"
|
|||||||
# InvenTree paths
|
# InvenTree paths
|
||||||
ENV INVENTREE_SRC_DIR="${INVENTREE_HOME}/src"
|
ENV INVENTREE_SRC_DIR="${INVENTREE_HOME}/src"
|
||||||
ENV INVENTREE_MNG_DIR="${INVENTREE_SRC_DIR}/InvenTree"
|
ENV INVENTREE_MNG_DIR="${INVENTREE_SRC_DIR}/InvenTree"
|
||||||
ENV INVENTREE_STATIC_ROOT="${INVENTREE_HOME}/static"
|
ENV INVENTREE_DATA_DIR="${INVENTREE_HOME}/data"
|
||||||
ENV INVENTREE_MEDIA_ROOT="${INVENTREE_HOME}/media"
|
ENV INVENTREE_STATIC_ROOT="${INVENTREE_DATA_DIR}/static"
|
||||||
ENV INVENTREE_LOG_DIR="${INVENTREE_HOME}/log"
|
ENV INVENTREE_MEDIA_ROOT="${INVENTREE_MEDIA_DIR}/media"
|
||||||
ENV INVENTREE_BACKUP_DIR="${INVENTREE_HOME}/backup"
|
ENV INVENTREE_BACKUP_DIR="${INVENTREE_DATA_DIR}/backup"
|
||||||
ENV INVENTREE_VENV="${INVENTREE_HOME}/env"
|
ENV INVENTREE_VENV="${INVENTREE_HOME}/env"
|
||||||
|
|
||||||
|
ENV INVENTREE_CONFIG_FILE="${INVENTREE_DATA_DIR}/config.yaml"
|
||||||
|
|
||||||
# Pass DB configuration through as environment variables
|
# Pass DB configuration through as environment variables
|
||||||
ENV INVENTREE_DB_ENGINE="${INVENTREE_DB_ENGINE}"
|
ENV INVENTREE_DB_ENGINE="${INVENTREE_DB_ENGINE}"
|
||||||
ENV INVENTREE_DB_NAME="${INVENTREE_DB_NAME}"
|
ENV INVENTREE_DB_NAME="${INVENTREE_DB_NAME}"
|
||||||
@ -59,7 +61,7 @@ RUN apk add --no-cache postgresql-contrib postgresql-dev libpq
|
|||||||
RUN apk add --no-cache mariadb-connector-c mariadb-dev
|
RUN apk add --no-cache mariadb-connector-c mariadb-dev
|
||||||
|
|
||||||
# Create required directories
|
# Create required directories
|
||||||
RUN mkdir ${INVENTREE_HOME}/media ${INVENTREE_HOME}/static ${INVENTREE_HOME}/backup
|
#RUN mkdir ${INVENTREE_DATA_DIR}}/media ${INVENTREE_HOME}/static ${INVENTREE_HOME}/backup
|
||||||
|
|
||||||
# Setup Python virtual environment
|
# Setup Python virtual environment
|
||||||
RUN python3 -m venv ${INVENTREE_VENV}
|
RUN python3 -m venv ${INVENTREE_VENV}
|
||||||
|
@ -20,7 +20,9 @@ services:
|
|||||||
- POSTGRES_USER=pguser
|
- POSTGRES_USER=pguser
|
||||||
- POSTGRES_PASSWORD=pgpassword
|
- POSTGRES_PASSWORD=pgpassword
|
||||||
volumes:
|
volumes:
|
||||||
- database_data:/var/lib/postgresql/data/
|
# Map external directory to store database data
|
||||||
|
# Replace /path/to/dir with the required external path
|
||||||
|
- /mnt/c/abcdatabase:/var/lib/postgresql/data/
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
server:
|
server:
|
||||||
@ -36,9 +38,9 @@ services:
|
|||||||
depends_on:
|
depends_on:
|
||||||
- db
|
- db
|
||||||
volumes:
|
volumes:
|
||||||
- static_volume:/home/inventree/static
|
# Map external directory to store InvenTree data
|
||||||
- media_volume:/home/inventree/media
|
# Replace /path/to/dir with the required external path
|
||||||
- backup_volume:/home/inventree/backup
|
- /mnt/c/abcde:/home/inventree/data
|
||||||
environment:
|
environment:
|
||||||
- INVENTREE_DB_ENGINE=postgresql
|
- INVENTREE_DB_ENGINE=postgresql
|
||||||
- INVENTREE_DB_NAME=inventree
|
- INVENTREE_DB_NAME=inventree
|
||||||
@ -60,10 +62,6 @@ services:
|
|||||||
depends_on:
|
depends_on:
|
||||||
- db
|
- db
|
||||||
- server
|
- server
|
||||||
volumes:
|
|
||||||
- static_volume:/home/inventree/static
|
|
||||||
- media_volume:/home/inventree/media
|
|
||||||
- backup_volume:/home/inventree/backup
|
|
||||||
environment:
|
environment:
|
||||||
- INVENTREE_DB_ENGINE=postgresql
|
- INVENTREE_DB_ENGINE=postgresql
|
||||||
- INVENTREE_DB_NAME=inventree
|
- INVENTREE_DB_NAME=inventree
|
||||||
@ -72,9 +70,3 @@ services:
|
|||||||
- INVENTREE_DB_PORT=5432
|
- INVENTREE_DB_PORT=5432
|
||||||
- INVENTREE_DB_HOST=db
|
- INVENTREE_DB_HOST=db
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
volumes:
|
|
||||||
database_data:
|
|
||||||
static_volume:
|
|
||||||
media_volume:
|
|
||||||
backup_volume:
|
|
||||||
|
@ -1,17 +1,33 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
echo "Starting InvenTree server..."
|
# 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
|
||||||
|
|
||||||
# Check that the database engine is specified
|
if [[ ! -d "$INVENTREE_MEDIA_ROOT" ]]; then
|
||||||
if [ -z "$INVENTREE_DB_ENGINE" ]; then
|
echo "Creating directory $INVENTREE_MEDIA_ROOT"
|
||||||
echo "INVENTREE_DB_ENGINE not configured"
|
mkdir $INVENTREE_MEDIA_ROOT
|
||||||
exit 1
|
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
|
fi
|
||||||
|
|
||||||
# Activate virtual environment
|
# Activate virtual environment
|
||||||
source $INVENTREE_VENV/bin/activate
|
source $INVENTREE_VENV/bin/activate
|
||||||
|
|
||||||
sleep 5
|
echo "Starting InvenTree server..."
|
||||||
|
|
||||||
# Wait for the database to be ready
|
# Wait for the database to be ready
|
||||||
cd $INVENTREE_MNG_DIR
|
cd $INVENTREE_MNG_DIR
|
||||||
|
@ -2,12 +2,6 @@
|
|||||||
|
|
||||||
echo "Starting InvenTree worker..."
|
echo "Starting InvenTree worker..."
|
||||||
|
|
||||||
# Check that the database engine is specified
|
|
||||||
if [ -z "$INVENTREE_DB_ENGINE" ]; then
|
|
||||||
echo "INVENTREE_DB_ENGINE not configured"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Activate virtual environment
|
# Activate virtual environment
|
||||||
source ./env/bin/activate
|
source ./env/bin/activate
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user