diff --git a/docker/Dockerfile b/docker/Dockerfile index 1fd9329d69..eefc700cc7 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -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 diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 08eb84d45b..839128738d 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -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: diff --git a/docker/start_server.sh b/docker/start_server.sh index e9eaff1dfa..0436cd532f 100644 --- a/docker/start_server.sh +++ b/docker/start_server.sh @@ -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 diff --git a/docker/start_worker.sh b/docker/start_worker.sh index a8a4815583..64c8d75ee4 100644 --- a/docker/start_worker.sh +++ b/docker/start_worker.sh @@ -2,9 +2,6 @@ echo "Starting InvenTree worker..." -# Activate virtual environment -source ./env/bin/activate - sleep 5 # Wait for the database to be ready