2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-29 03:56:43 +00:00

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_STATIC_ROOT="${INVENTREE_DATA_DIR}/static"
ENV INVENTREE_MEDIA_ROOT="${INVENTREE_DATA_DIR}/media" ENV INVENTREE_MEDIA_ROOT="${INVENTREE_DATA_DIR}/media"
ENV INVENTREE_BACKUP_DIR="${INVENTREE_DATA_DIR}/backup" 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_CONFIG_FILE="${INVENTREE_DATA_DIR}/config.yaml"
ENV INVENTREE_SECRET_KEY_FILE="${INVENTREE_DATA_DIR}/secret_key.txt" 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 # Create required directories
#RUN mkdir ${INVENTREE_DATA_DIR}}/media ${INVENTREE_HOME}/static ${INVENTREE_HOME}/backup #RUN mkdir ${INVENTREE_DATA_DIR}}/media ${INVENTREE_HOME}/static ${INVENTREE_HOME}/backup
# Setup Python virtual environment # Install required python packages
RUN python3 -m venv ${INVENTREE_VENV} RUN pip install --upgrade pip setuptools wheel
RUN pip install --no-cache-dir -U invoke
# Install required PIP packages (into the virtual environment!) RUN pip install --no-cache-dir -U psycopg2 mysqlclient pgcli mariadb
RUN source ${INVENTREE_VENV}/bin/activate && pip install --upgrade pip setuptools wheel RUN pip install --no-cache-dir -U gunicorn
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
# Clone source code # Clone source code
RUN echo "Downloading InvenTree from ${INVENTREE_REPO}" RUN echo "Downloading InvenTree from ${INVENTREE_REPO}"
RUN git clone --branch ${INVENTREE_BRANCH} --depth 1 ${INVENTREE_REPO} ${INVENTREE_SRC_DIR} 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 pip install --no-cache-dir -U -r ${INVENTREE_SRC_DIR}/requirements.txt
# 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

View File

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

View File

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

View File

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