Update dockerfile

This commit is contained in:
Oliver Walters 2021-04-10 15:08:10 +10:00
parent 47a93bc4cb
commit 8eb571bddf
5 changed files with 45 additions and 25 deletions

View File

@ -338,7 +338,7 @@ Q_CLUSTER = {
'queue_limit': 50,
'bulk': 10,
'orm': 'default',
'sync': True,
'sync': False,
}
# Markdownx configuration

View File

@ -42,8 +42,6 @@ LABEL org.label-schema.schema-version="1.0" \
org.label-schema.vcs-branch=${BRANCH} \
org.label-schema.vcs-ref=${COMMIT}
RUN echo "Installing InvenTree '${INVENTREE_VERSION}' from ${INVENTREE_REPO}"
# Create user account
RUN addgroup -S inventreegroup && adduser -S inventree -G inventreegroup
WORKDIR ${INVENTREE_HOME}
@ -60,8 +58,8 @@ RUN apk add --no-cache python3
RUN apk add --no-cache postgresql-contrib postgresql-dev libpq
RUN apk add --no-cache mariadb-connector-c mariadb-dev
# Clone source code
RUN git clone --branch ${INVENTREE_BRANCH} --depth 1 ${INVENTREE_REPO} ${INVENTREE_SRC_DIR}
# Create required directories
RUN mkdir ${INVENTREE_HOME}/media ${INVENTREE_HOME}/static ${INVENTREE_HOME}/backup
# Setup Python virtual environment
RUN python3 -m venv ${INVENTREE_VENV}
@ -72,25 +70,22 @@ RUN source ${INVENTREE_VENV}/bin/activate && pip install --no-cache-dir -U invok
RUN source ${INVENTREE_VENV}/bin/activate && pip install --no-cache-dir -U psycopg2 mysqlclient pgcli mariadb
RUN source ${INVENTREE_VENV}/bin/activate && pip install --no-cache-dir -U gunicorn
# Clone source code
RUN echo "Downloading InvenTree from ${INVENTREE_REPO}"
RUN git clone --branch ${INVENTREE_BRANCH} --depth 1 ${INVENTREE_REPO} ${INVENTREE_SRC_DIR}
# Install InvenTree packages
RUN source ${INVENTREE_VENV}/bin/activate && pip install --no-cache-dir -U -r ${INVENTREE_SRC_DIR}/requirements.txt
# Install supervisor
RUN apk add --no-cache supervisor
# Create required directories
RUN mkdir ${INVENTREE_HOME}/media ${INVENTREE_HOME}/static ${INVENTREE_HOME}/backup
# Copy supervisor file
COPY supervisord.conf ${INVENTREE_HOME}/supervisord.conf
# Copy gunicorn config file
COPY gunicorn.conf.py ${INVENTREE_HOME}/gunicorn.conf.py
# Copy startup script
COPY start.sh ${INVENTREE_HOME}/start.sh
# Copy startup scripts
COPY start_server.sh ${INVENTREE_HOME}/start_server.sh
COPY start_worker.sh ${INVENTREE_HOME}/start_worker.sh
RUN chmod 755 ${INVENTREE_HOME}/start.sh
RUN chmod 755 ${INVENTREE_HOME}/start_server.sh
RUN chmod 755 ${INVENTREE_HOME}/start_worker.sh
# Let us begin
CMD ["bash", "./start.sh"]
CMD ["bash", "./start_server.sh"]

View File

@ -29,5 +29,5 @@ 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 $INVENTREE_HOME/supervisord.conf
# Now we can launch the server
gunicorn -c $INVENTREE_HOME/gunicorn.conf.py InvenTree.wsgi -b 0.0.0.0:8080

24
docker/start_worker.sh Normal file
View File

@ -0,0 +1,24 @@
#!/bin/sh
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
source ./env/bin/activate
sleep 5
# Wait for the database to be ready
cd src/InvenTree
python manage.py wait_for_db
sleep 10
# Now we can launch the background worker process
python manage.py qcluster

View File

@ -16,18 +16,20 @@
user=inventree
nodaemon=true
[supervisorctl]
serverurl=unix:///var/run/supervisor.sock
[program:inventree-server]
user=inventree
directory=%(ENV_INVENTREE_SRC_DIR)s/InvenTree
command=%(ENV_INVENTREE_VENV)s/bin/gunicorn -c %(ENV_INVENTREE_HOME)s/gunicorn.conf.py InvenTree.wsgi -b 0.0.0.0:8080
command=%(ENV_INVENTREE_VENV)s/bin/gunicorn -c %(ENV_INVENTREE_HOME)s/gunicorn.conf.py InvenTree.wsgi -b 127.0.0.1:8080
startsecs=10
autostart=true
autorestart=true
startretries=3
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
stderr_logfile=/dev/fd/2
stderr_logfile_maxbytes=0
redirect_stderr=true
[program:inventree-cluster]
user=inventree
@ -38,5 +40,4 @@ autostart=true
autorestart=true
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
stderr_logfile=/dev/fd/2
stderr_logfile_maxbytes=0
redirect_stderr=true