mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Entrypoint script - start.sh
This commit is contained in:
parent
8d3b9e2ca4
commit
2436b1f2c9
@ -28,7 +28,7 @@ database:
|
|||||||
# NAME: '/home/inventree/database.sqlite3'
|
# NAME: '/home/inventree/database.sqlite3'
|
||||||
|
|
||||||
# --- Example Configuration - MySQL ---
|
# --- Example Configuration - MySQL ---
|
||||||
#ENGINE: django.db.backends.mysql
|
#ENGINE: mysql
|
||||||
#NAME: inventree
|
#NAME: inventree
|
||||||
#USER: inventree
|
#USER: inventree
|
||||||
#PASSWORD: inventree_password
|
#PASSWORD: inventree_password
|
||||||
@ -36,7 +36,7 @@ database:
|
|||||||
#PORT: '3306'
|
#PORT: '3306'
|
||||||
|
|
||||||
# --- Example Configuration - Postgresql ---
|
# --- Example Configuration - Postgresql ---
|
||||||
#ENGINE: django.db.backends.postgresql
|
#ENGINE: postgresql
|
||||||
#NAME: inventree
|
#NAME: inventree
|
||||||
#USER: inventree
|
#USER: inventree
|
||||||
#PASSWORD: inventree_password
|
#PASSWORD: inventree_password
|
||||||
|
@ -3,12 +3,13 @@ FROM python:alpine as production
|
|||||||
# GitHub source
|
# GitHub source
|
||||||
ARG INVENTREE_REPO="https://github.com/inventree/InvenTree.git"
|
ARG INVENTREE_REPO="https://github.com/inventree/InvenTree.git"
|
||||||
ARG INVENTREE_VERSION="master"
|
ARG INVENTREE_VERSION="master"
|
||||||
|
ARG INVENTREE_CONFIG_FILE="InvenTree/config_template.yaml"
|
||||||
|
|
||||||
# InvenTree server port
|
# InvenTree server port
|
||||||
ARG INVENTREE_PORT="80"
|
ARG INVENTREE_PORT="80"
|
||||||
|
|
||||||
# Database configuration options
|
# Database configuration options
|
||||||
ARG INVENTREE_DB_ENGINE="sqlite"
|
ARG INVENTREE_DB_ENGINE="sqlite3"
|
||||||
ARG INVENTREE_DB_NAME="inventree_db.sqlite3"
|
ARG INVENTREE_DB_NAME="inventree_db.sqlite3"
|
||||||
ARG INVENTREE_DB_HOST="127.0.0.1"
|
ARG INVENTREE_DB_HOST="127.0.0.1"
|
||||||
ARG INVENTREE_DB_PORT=""
|
ARG INVENTREE_DB_PORT=""
|
||||||
@ -21,6 +22,8 @@ ENV PYTHONUNBUFFERED 1
|
|||||||
ENV INVENTREE_HOME="/home/inventree"
|
ENV INVENTREE_HOME="/home/inventree"
|
||||||
ENV INVENTREE_PORT="${INVENTREE_PORT}"
|
ENV INVENTREE_PORT="${INVENTREE_PORT}"
|
||||||
|
|
||||||
|
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"
|
||||||
@ -42,7 +45,7 @@ LABEL org.label-schema.schema-version="1.0" \
|
|||||||
org.label-schema.build-date=${DATE} \
|
org.label-schema.build-date=${DATE} \
|
||||||
org.label-schema.vendor="inventree" \
|
org.label-schema.vendor="inventree" \
|
||||||
org.label-schema.name="inventree/inventree" \
|
org.label-schema.name="inventree/inventree" \
|
||||||
org.label-schema.url="https://hub.docker.com/r/inventree/inventree-docker" \
|
org.label-schema.url="https://hub.docker.com/r/inventree/inventree" \
|
||||||
org.label-schema.version=${INVENTREE_VERSION} \
|
org.label-schema.version=${INVENTREE_VERSION} \
|
||||||
org.label-schema.vcs-url=${INVENTREE_REPO} \
|
org.label-schema.vcs-url=${INVENTREE_REPO} \
|
||||||
org.label-schema.vcs-branch=${BRANCH} \
|
org.label-schema.vcs-branch=${BRANCH} \
|
||||||
@ -93,4 +96,13 @@ COPY docker/supervisor.conf /etc/supervisord.conf
|
|||||||
# Copy gunicorn config file
|
# Copy gunicorn config file
|
||||||
COPY docker/gunicorn.conf.py ${INVENTREE_HOME}/gunicorn.conf.py
|
COPY docker/gunicorn.conf.py ${INVENTREE_HOME}/gunicorn.conf.py
|
||||||
|
|
||||||
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"]
|
# Copy default InvenTree config file
|
||||||
|
COPY ${INVENTREE_CONFIG_FILE} ${INVENTREE_SRC_DIR}/InvenTree/config.yaml
|
||||||
|
|
||||||
|
# Copy startup script
|
||||||
|
COPY docker/start.sh ${INVENTREE_HOME}/start.sh
|
||||||
|
|
||||||
|
RUN chmod 755 ${INVENTREE_HOME}/start.sh
|
||||||
|
|
||||||
|
# Let us begin
|
||||||
|
CMD "./start.sh"
|
||||||
|
35
docker/start.sh
Normal file
35
docker/start.sh
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Check that the database engine is specified
|
||||||
|
if [ -z "$INVENTREE_DB_ENGINE" ]; then
|
||||||
|
echo "INVENTREE_DB_ENGINE not configured"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check that the base dir is set
|
||||||
|
if [ -z "$INVENTREE_HOME" ]; then
|
||||||
|
echo "INVENTREE_HOME not configured"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Activate virtual environment
|
||||||
|
source $INVENTREE_VENV/bin/activate
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# Now we can launch the server and background worker
|
||||||
|
/usr/bin/supervisord -c /etc/supervisord.conf
|
Loading…
Reference in New Issue
Block a user