mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-04 06:18:48 +00:00
Update dockerfile
This commit is contained in:
parent
47a93bc4cb
commit
8eb571bddf
@ -338,7 +338,7 @@ Q_CLUSTER = {
|
|||||||
'queue_limit': 50,
|
'queue_limit': 50,
|
||||||
'bulk': 10,
|
'bulk': 10,
|
||||||
'orm': 'default',
|
'orm': 'default',
|
||||||
'sync': True,
|
'sync': False,
|
||||||
}
|
}
|
||||||
|
|
||||||
# Markdownx configuration
|
# Markdownx configuration
|
||||||
|
@ -42,8 +42,6 @@ LABEL org.label-schema.schema-version="1.0" \
|
|||||||
org.label-schema.vcs-branch=${BRANCH} \
|
org.label-schema.vcs-branch=${BRANCH} \
|
||||||
org.label-schema.vcs-ref=${COMMIT}
|
org.label-schema.vcs-ref=${COMMIT}
|
||||||
|
|
||||||
RUN echo "Installing InvenTree '${INVENTREE_VERSION}' from ${INVENTREE_REPO}"
|
|
||||||
|
|
||||||
# Create user account
|
# Create user account
|
||||||
RUN addgroup -S inventreegroup && adduser -S inventree -G inventreegroup
|
RUN addgroup -S inventreegroup && adduser -S inventree -G inventreegroup
|
||||||
WORKDIR ${INVENTREE_HOME}
|
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 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
|
||||||
|
|
||||||
# Clone source code
|
# Create required directories
|
||||||
RUN git clone --branch ${INVENTREE_BRANCH} --depth 1 ${INVENTREE_REPO} ${INVENTREE_SRC_DIR}
|
RUN mkdir ${INVENTREE_HOME}/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}
|
||||||
@ -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 psycopg2 mysqlclient pgcli mariadb
|
||||||
RUN source ${INVENTREE_VENV}/bin/activate && pip install --no-cache-dir -U gunicorn
|
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
|
# Install InvenTree packages
|
||||||
RUN source ${INVENTREE_VENV}/bin/activate && pip install --no-cache-dir -U -r ${INVENTREE_SRC_DIR}/requirements.txt
|
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 config file
|
||||||
COPY gunicorn.conf.py ${INVENTREE_HOME}/gunicorn.conf.py
|
COPY gunicorn.conf.py ${INVENTREE_HOME}/gunicorn.conf.py
|
||||||
|
|
||||||
# Copy startup script
|
# Copy startup scripts
|
||||||
COPY start.sh ${INVENTREE_HOME}/start.sh
|
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
|
# Let us begin
|
||||||
CMD ["bash", "./start.sh"]
|
CMD ["bash", "./start_server.sh"]
|
||||||
|
@ -29,5 +29,5 @@ python manage.py migrate --run-syncdb || exit 1
|
|||||||
python manage.py collectstatic --noinput || exit 1
|
python manage.py collectstatic --noinput || exit 1
|
||||||
python manage.py clearsessions || exit 1
|
python manage.py clearsessions || exit 1
|
||||||
|
|
||||||
# Now we can launch the server and background worker
|
# Now we can launch the server
|
||||||
/usr/bin/supervisord -c $INVENTREE_HOME/supervisord.conf
|
gunicorn -c $INVENTREE_HOME/gunicorn.conf.py InvenTree.wsgi -b 0.0.0.0:8080
|
24
docker/start_worker.sh
Normal file
24
docker/start_worker.sh
Normal 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
|
@ -16,18 +16,20 @@
|
|||||||
user=inventree
|
user=inventree
|
||||||
nodaemon=true
|
nodaemon=true
|
||||||
|
|
||||||
|
[supervisorctl]
|
||||||
|
serverurl=unix:///var/run/supervisor.sock
|
||||||
|
|
||||||
[program:inventree-server]
|
[program:inventree-server]
|
||||||
user=inventree
|
user=inventree
|
||||||
directory=%(ENV_INVENTREE_SRC_DIR)s/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
|
startsecs=10
|
||||||
autostart=true
|
autostart=true
|
||||||
autorestart=true
|
autorestart=true
|
||||||
startretries=3
|
startretries=3
|
||||||
stdout_logfile=/dev/fd/1
|
stdout_logfile=/dev/fd/1
|
||||||
stdout_logfile_maxbytes=0
|
stdout_logfile_maxbytes=0
|
||||||
stderr_logfile=/dev/fd/2
|
redirect_stderr=true
|
||||||
stderr_logfile_maxbytes=0
|
|
||||||
|
|
||||||
[program:inventree-cluster]
|
[program:inventree-cluster]
|
||||||
user=inventree
|
user=inventree
|
||||||
@ -38,5 +40,4 @@ autostart=true
|
|||||||
autorestart=true
|
autorestart=true
|
||||||
stdout_logfile=/dev/fd/1
|
stdout_logfile=/dev/fd/1
|
||||||
stdout_logfile_maxbytes=0
|
stdout_logfile_maxbytes=0
|
||||||
stderr_logfile=/dev/fd/2
|
redirect_stderr=true
|
||||||
stderr_logfile_maxbytes=0
|
|
Loading…
x
Reference in New Issue
Block a user