Do not use python virtual environment inside container

This commit is contained in:
Oliver Walters 2021-04-10 21:40:27 +10:00
parent 823f84e46a
commit 2f1db486a0
4 changed files with 11 additions and 18 deletions

View File

@ -22,7 +22,6 @@ ENV INVENTREE_DATA_DIR="${INVENTREE_HOME}/data"
ENV INVENTREE_STATIC_ROOT="${INVENTREE_DATA_DIR}/static"
ENV INVENTREE_MEDIA_ROOT="${INVENTREE_DATA_DIR}/media"
ENV INVENTREE_BACKUP_DIR="${INVENTREE_DATA_DIR}/backup"
ENV INVENTREE_VENV="${INVENTREE_HOME}/env"
ENV INVENTREE_CONFIG_FILE="${INVENTREE_DATA_DIR}/config.yaml"
ENV INVENTREE_SECRET_KEY_FILE="${INVENTREE_DATA_DIR}/secret_key.txt"
@ -64,21 +63,18 @@ RUN apk add --no-cache mariadb-connector-c mariadb-dev
# Create required directories
#RUN mkdir ${INVENTREE_DATA_DIR}}/media ${INVENTREE_HOME}/static ${INVENTREE_HOME}/backup
# Setup Python virtual environment
RUN python3 -m venv ${INVENTREE_VENV}
# Install required PIP packages (into the virtual environment!)
RUN source ${INVENTREE_VENV}/bin/activate && pip install --upgrade pip setuptools wheel
RUN source ${INVENTREE_VENV}/bin/activate && pip install --no-cache-dir -U invoke
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
# Install required python packages
RUN pip install --upgrade pip setuptools wheel
RUN pip install --no-cache-dir -U invoke
RUN pip install --no-cache-dir -U psycopg2 mysqlclient pgcli mariadb
RUN 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
RUN pip install --no-cache-dir -U -r ${INVENTREE_SRC_DIR}/requirements.txt
# Copy gunicorn config file
COPY gunicorn.conf.py ${INVENTREE_HOME}/gunicorn.conf.py

View File

@ -7,6 +7,7 @@ version: "3.8"
# - Runs nginx as a reverse proxy
services:
# Database service
# Use PostgreSQL as the database backend
# Note: this can be changed to a different backend,
# just make sure that you change the INVENTREE_DB_xxx vars below
@ -23,7 +24,9 @@ services:
- data:/var/lib/postgresql/data/
restart: unless-stopped
server:
# InvenTree web server services
# Uses gunicorn as the web server
inventree:
build:
context: .
args:
@ -57,7 +60,7 @@ services:
container_name: inventree_worker
depends_on:
- db
- server
- inventree
volumes:
- data:/home/inventree/data
environment:

View File

@ -24,9 +24,6 @@ else
cp $INVENTREE_SRC_DIR/InvenTree/config_template.yaml $INVENTREE_CONFIG_FILE
fi
# Activate virtual environment
source $INVENTREE_VENV/bin/activate
echo "Starting InvenTree server..."
# Wait for the database to be ready

View File

@ -2,9 +2,6 @@
echo "Starting InvenTree worker..."
# Activate virtual environment
source ./env/bin/activate
sleep 5
# Wait for the database to be ready