From 124db01b63c604233f5ec946f4b9717b6e5fc4d8 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 18 Apr 2021 14:45:41 +1000 Subject: [PATCH 01/17] Add binaries for database dumping --- docker/inventree/Dockerfile | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/docker/inventree/Dockerfile b/docker/inventree/Dockerfile index fcba19e964..f5fb538eb7 100644 --- a/docker/inventree/Dockerfile +++ b/docker/inventree/Dockerfile @@ -56,11 +56,22 @@ RUN apk add --no-cache git make bash \ libjpeg-turbo libjpeg-turbo-dev jpeg jpeg-dev \ libffi libffi-dev \ zlib zlib-dev + +# Cairo deps for WeasyPrint (these will be deprecated once WeasyPrint drops cairo requirement) RUN apk add --no-cache cairo cairo-dev pango pango-dev RUN apk add --no-cache fontconfig ttf-droid ttf-liberation ttf-dejavu ttf-opensans ttf-ubuntu-font-family font-croscore font-noto -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 + +# Python +RUN apk add --no-cache python3 python3-dev python3-pip + +# SQLite support +RUN apk add --no-cache sqlite3 + +# PostgreSQL support +RUN apk add --no-cache postgresql-contrib postgresql-dev libpq pg_dump + +# MySQL support +RUN apk add --no-cache mariadb-connector-c mariadb-dev mysqldump # Create required directories #RUN mkdir ${INVENTREE_DATA_DIR}}/media ${INVENTREE_HOME}/static ${INVENTREE_HOME}/backup From 75054f870ed336d797745e982f3c96f3c5a88890 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 18 Apr 2021 14:50:22 +1000 Subject: [PATCH 02/17] Fix --- docker/inventree/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/inventree/Dockerfile b/docker/inventree/Dockerfile index f5fb538eb7..b9e52ed863 100644 --- a/docker/inventree/Dockerfile +++ b/docker/inventree/Dockerfile @@ -62,7 +62,7 @@ RUN apk add --no-cache cairo cairo-dev pango pango-dev RUN apk add --no-cache fontconfig ttf-droid ttf-liberation ttf-dejavu ttf-opensans ttf-ubuntu-font-family font-croscore font-noto # Python -RUN apk add --no-cache python3 python3-dev python3-pip +RUN apk add --no-cache python3 python3-dev # SQLite support RUN apk add --no-cache sqlite3 From cbb94d2ff75fd6713fb21d50e10f21465776aae9 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 18 Apr 2021 14:57:25 +1000 Subject: [PATCH 03/17] sqlite3 -> sqlite --- docker/inventree/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/inventree/Dockerfile b/docker/inventree/Dockerfile index b9e52ed863..6e3166028c 100644 --- a/docker/inventree/Dockerfile +++ b/docker/inventree/Dockerfile @@ -65,7 +65,7 @@ RUN apk add --no-cache fontconfig ttf-droid ttf-liberation ttf-dejavu ttf-opensa RUN apk add --no-cache python3 python3-dev # SQLite support -RUN apk add --no-cache sqlite3 +RUN apk add --no-cache sqlite # PostgreSQL support RUN apk add --no-cache postgresql-contrib postgresql-dev libpq pg_dump From c07aef7f752e1011c50b03f273504706221e930f Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 18 Apr 2021 14:58:02 +1000 Subject: [PATCH 04/17] Remove commented line --- docker/inventree/Dockerfile | 3 --- 1 file changed, 3 deletions(-) diff --git a/docker/inventree/Dockerfile b/docker/inventree/Dockerfile index 6e3166028c..42d18d04c6 100644 --- a/docker/inventree/Dockerfile +++ b/docker/inventree/Dockerfile @@ -73,9 +73,6 @@ RUN apk add --no-cache postgresql-contrib postgresql-dev libpq pg_dump # MySQL support RUN apk add --no-cache mariadb-connector-c mariadb-dev mysqldump -# Create required directories -#RUN mkdir ${INVENTREE_DATA_DIR}}/media ${INVENTREE_HOME}/static ${INVENTREE_HOME}/backup - # Install required python packages RUN pip install --upgrade pip setuptools wheel RUN pip install --no-cache-dir -U invoke From 69473b9bff5c36cbd4f3cdcc0722164276883bb8 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 18 Apr 2021 15:05:52 +1000 Subject: [PATCH 05/17] Fix install Also make the web port configurable --- docker/inventree/Dockerfile | 5 ++++- docker/inventree/start_server.sh | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docker/inventree/Dockerfile b/docker/inventree/Dockerfile index 42d18d04c6..43ac865169 100644 --- a/docker/inventree/Dockerfile +++ b/docker/inventree/Dockerfile @@ -26,6 +26,9 @@ ENV INVENTREE_BACKUP_DIR="${INVENTREE_DATA_DIR}/backup" ENV INVENTREE_CONFIG_FILE="${INVENTREE_DATA_DIR}/config.yaml" ENV INVENTREE_SECRET_KEY_FILE="${INVENTREE_DATA_DIR}/secret_key.txt" +# Default web server port is 8000 +ENV INVENTREE_WEB_PORT="8000" + # Pass DB configuration through as environment variables ENV INVENTREE_DB_ENGINE="${INVENTREE_DB_ENGINE}" ENV INVENTREE_DB_NAME="${INVENTREE_DB_NAME}" @@ -68,7 +71,7 @@ RUN apk add --no-cache python3 python3-dev RUN apk add --no-cache sqlite # PostgreSQL support -RUN apk add --no-cache postgresql-contrib postgresql-dev libpq pg_dump +RUN apk add --no-cache postgresql postgresql-contrib postgresql-dev libpq # MySQL support RUN apk add --no-cache mariadb-connector-c mariadb-dev mysqldump diff --git a/docker/inventree/start_server.sh b/docker/inventree/start_server.sh index 0436cd532f..db9f1594ae 100644 --- a/docker/inventree/start_server.sh +++ b/docker/inventree/start_server.sh @@ -43,4 +43,4 @@ python manage.py collectstatic --noinput || exit 1 python manage.py clearsessions || exit 1 # Now we can launch the server -gunicorn -c $INVENTREE_HOME/gunicorn.conf.py InvenTree.wsgi -b 0.0.0.0:8080 +gunicorn -c $INVENTREE_HOME/gunicorn.conf.py InvenTree.wsgi -b 0.0.0.0:$INVENTREE_WEB_PORT From 9eb559bec5c6021519c1c4f83b074e6a3a1e5d36 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 18 Apr 2021 15:09:01 +1000 Subject: [PATCH 06/17] More install fixes --- docker/inventree/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/inventree/Dockerfile b/docker/inventree/Dockerfile index 43ac865169..2911da907a 100644 --- a/docker/inventree/Dockerfile +++ b/docker/inventree/Dockerfile @@ -74,7 +74,7 @@ RUN apk add --no-cache sqlite RUN apk add --no-cache postgresql postgresql-contrib postgresql-dev libpq # MySQL support -RUN apk add --no-cache mariadb-connector-c mariadb-dev mysqldump +RUN apk add --no-cache mariadb-connector-c mariadb-dev mariadb-client # Install required python packages RUN pip install --upgrade pip setuptools wheel From 270c0ea85db9498b576087421d0e73d99a813903 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 18 Apr 2021 15:17:57 +1000 Subject: [PATCH 07/17] Cleanup docker files --- .github/workflows/docker_build.yaml | 8 +++----- .github/workflows/docker_publish.yaml | 19 ++----------------- docker/{inventree => }/Dockerfile | 0 docker/docker-compose.yml | 19 ++++++++++++------- docker/{inventree => }/gunicorn.conf.py | 0 docker/{nginx => }/nginx.conf | 7 +++++-- docker/nginx/Dockerfile | 14 -------------- docker/{inventree => }/start_server.sh | 0 docker/{inventree => }/start_worker.sh | 0 9 files changed, 22 insertions(+), 45 deletions(-) rename docker/{inventree => }/Dockerfile (100%) rename docker/{inventree => }/gunicorn.conf.py (100%) rename docker/{nginx => }/nginx.conf (60%) delete mode 100644 docker/nginx/Dockerfile rename docker/{inventree => }/start_server.sh (100%) rename docker/{inventree => }/start_worker.sh (100%) diff --git a/.github/workflows/docker_build.yaml b/.github/workflows/docker_build.yaml index c9f8a69654..e307c18452 100644 --- a/.github/workflows/docker_build.yaml +++ b/.github/workflows/docker_build.yaml @@ -11,8 +11,6 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Build Server Image - run: cd docker/inventree && docker build . --tag inventree:$(date +%s) - - name: Build nginx Image - run: cd docker/nginx && docker build . --tag nxinx:$(date +%s) - \ No newline at end of file + - name: Build Docker Image + run: cd docker && docker build . --tag inventree:$(date +%s) + \ No newline at end of file diff --git a/.github/workflows/docker_publish.yaml b/.github/workflows/docker_publish.yaml index 6870754ad3..75f2d67d20 100644 --- a/.github/workflows/docker_publish.yaml +++ b/.github/workflows/docker_publish.yaml @@ -7,7 +7,7 @@ on: types: [published] jobs: - server_image: + publish_image: name: Push InvenTree web server image to dockerhub runs-on: ubuntu-latest steps: @@ -20,19 +20,4 @@ jobs: password: ${{ secrets.DOCKER_PASSWORD }} repository: inventree/inventree tag_with_ref: true - dockerfile: docker/inventree/Dockerfile - - nginx_image: - name: Push InvenTree nginx image to dockerhub - runs-on: ubuntu-latest - steps: - - name: Check out repo - uses: actions/checkout@v2 - - name: Push to Docker Hub - uses: docker/build-push-action@v1 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - repository: inventree/nginx - tag_with_ref: true - dockerfile: docker/nginx/Dockerfile + dockerfile: docker/Dockerfile \ No newline at end of file diff --git a/docker/inventree/Dockerfile b/docker/Dockerfile similarity index 100% rename from docker/inventree/Dockerfile rename to docker/Dockerfile diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 90b5fa2668..8a18d864b3 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -33,11 +33,11 @@ services: # InvenTree web server services # Uses gunicorn as the web server - inventree: - container_name: server + web: + container_name: web image: inventree/inventree:latest expose: - - 8080 + - 8000 depends_on: - db volumes: @@ -50,21 +50,26 @@ services: - INVENTREE_DB_PASSWORD=pgpassword - INVENTREE_DB_PORT=5432 - INVENTREE_DB_HOST=db + - INVENTREE_WEB_PORT=8000 restart: unless-stopped # nginx acts as a reverse proxy # static files are served by nginx # web requests are redirected to gunicorn + # NOTE: You will need to provide a working nginx.conf file! nginx: container_name: nginx - image: inventree/nginx:latest + image: nxinx depends_on: - - inventree + - web ports: # Change "1337" to the port where you want InvenTree web server to be available - 1337:80 volumes: - - static:/home/inventree/static + # Provide nginx.conf file to the container + - ./nginx.conf:/etc/nginx/templates/default.conf.template:ro + # Static data volume is mounted to /var/www/static + - static:/var/www/static # background worker process handles long-running or periodic tasks worker: @@ -73,7 +78,7 @@ services: entrypoint: ./start_worker.sh depends_on: - db - - inventree + - web volumes: - data:/home/inventree/data - static:/home/inventree/static diff --git a/docker/inventree/gunicorn.conf.py b/docker/gunicorn.conf.py similarity index 100% rename from docker/inventree/gunicorn.conf.py rename to docker/gunicorn.conf.py diff --git a/docker/nginx/nginx.conf b/docker/nginx.conf similarity index 60% rename from docker/nginx/nginx.conf rename to docker/nginx.conf index 0f25f51674..af681b0f31 100644 --- a/docker/nginx/nginx.conf +++ b/docker/nginx.conf @@ -1,9 +1,11 @@ upstream inventree { - server inventree:8080; + # Should point to the InvenTree web server container + server web:8000; } server { + # Listen for connection on (internal) port 80 listen 80; location / { @@ -14,8 +16,9 @@ server { client_max_body_size 100M; } + # Redirect any requests for static files location /static/ { - alias /home/inventree/static/; + alias /var/www/static/; } } \ No newline at end of file diff --git a/docker/nginx/Dockerfile b/docker/nginx/Dockerfile deleted file mode 100644 index e754597f02..0000000000 --- a/docker/nginx/Dockerfile +++ /dev/null @@ -1,14 +0,0 @@ -FROM nginx:1.19.0-alpine - -# Create user account -RUN addgroup -S inventreegroup && adduser -S inventree -G inventreegroup - -ENV HOME=/home/inventree -WORKDIR $HOME - -# Create the "static" volume directory -RUN mkdir $HOME/static - -RUN rm /etc/nginx/conf.d/default.conf -COPY nginx.conf /etc/nginx/conf.d - diff --git a/docker/inventree/start_server.sh b/docker/start_server.sh similarity index 100% rename from docker/inventree/start_server.sh rename to docker/start_server.sh diff --git a/docker/inventree/start_worker.sh b/docker/start_worker.sh similarity index 100% rename from docker/inventree/start_worker.sh rename to docker/start_worker.sh From eb108edb60d56befa39d3887084b73edb64f7a19 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 18 Apr 2021 16:26:32 +1000 Subject: [PATCH 08/17] Adds entrypoint for starting a development server --- docker/Dockerfile | 22 ++++---- docker/docker-compose.yml | 52 +++++++++---------- docker/start_dev_server.sh | 46 ++++++++++++++++ .../{start_server.sh => start_prod_server.sh} | 0 4 files changed, 85 insertions(+), 35 deletions(-) create mode 100644 docker/start_dev_server.sh rename docker/{start_server.sh => start_prod_server.sh} (100%) diff --git a/docker/Dockerfile b/docker/Dockerfile index 2911da907a..9682665e04 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -30,12 +30,14 @@ ENV INVENTREE_SECRET_KEY_FILE="${INVENTREE_DATA_DIR}/secret_key.txt" ENV INVENTREE_WEB_PORT="8000" # Pass DB configuration through as environment variables -ENV INVENTREE_DB_ENGINE="${INVENTREE_DB_ENGINE}" -ENV INVENTREE_DB_NAME="${INVENTREE_DB_NAME}" -ENV INVENTREE_DB_HOST="${INVENTREE_DB_HOST}" -ENV INVENTREE_DB_PORT="${INVENTREE_DB_PORT}" -ENV INVENTREE_DB_USER="${INVENTREE_DB_USER}" -ENV INVENTREE_DB_PASSWORD="${INVENTREE_DB_PASSWORD}" +# Default configuration = postgresql +ENV INVENTREE_DB_ENGINE="postgresql" +ENV INVENTREE_DB_NAME="inventree" +ENV INVENTREE_DB_HOST="db" +ENV INVENTREE_DB_PORT="5432" + +# INVENTREE_DB_USER must be specified at run-time +# INVENTREE_DB_PASSWORD must be specified at run-time LABEL org.label-schema.schema-version="1.0" \ org.label-schema.build-date=${DATE} \ @@ -93,14 +95,16 @@ RUN pip install --no-cache-dir -U -r ${INVENTREE_SRC_DIR}/requirements.txt COPY gunicorn.conf.py ${INVENTREE_HOME}/gunicorn.conf.py # Copy startup scripts -COPY start_server.sh ${INVENTREE_SRC_DIR}/start_server.sh +COPY start_prod_server.sh ${INVENTREE_SRC_DIR}/start_prod_server.sh +COPY start_dev_server.sh ${INVENTREE_SRC_DIR}/start_dev_server.sh COPY start_worker.sh ${INVENTREE_SRC_DIR}/start_worker.sh -RUN chmod 755 ${INVENTREE_SRC_DIR}/start_server.sh +RUN chmod 755 ${INVENTREE_SRC_DIR}/start_prod_server.sh +RUN chmod 755 ${INVENTREE_SRC_DIR}/start_dev_server.sh RUN chmod 755 ${INVENTREE_SRC_DIR}/start_worker.sh # exec commands should be executed from the "src" directory WORKDIR ${INVENTREE_SRC_DIR} # Let us begin -CMD ["bash", "./start_server.sh"] +CMD ["bash", "./start_prod_server.sh"] diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 8a18d864b3..31b43bac01 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -12,6 +12,7 @@ version: "3.8" # Before running, ensure that you change the "/path/to/data" directory, # specified in the "volumes" section at the end of this file. # This path determines where the InvenTree data will be stored! +# services: # Database service @@ -25,6 +26,7 @@ services: - 5432/tcp environment: - PGDATA=/var/lib/postgresql/data/pgdb + # The pguser and pgpassword values must be the same in the other containers - POSTGRES_USER=pguser - POSTGRES_PASSWORD=pgpassword volumes: @@ -44,13 +46,28 @@ services: - data:/home/inventree/data - static:/home/inventree/static environment: - - INVENTREE_DB_ENGINE=postgresql - - INVENTREE_DB_NAME=inventree + # Default environment variables are configured to match the 'db' container + # Database permissions + - INVENTREE_DB_USER=pguser + - INVENTREE_DB_PASSWORD=pgpassword + restart: unless-stopped + + # background worker process handles long-running or periodic tasks + worker: + container_name: worker + image: inventree/inventree:latest + entrypoint: ./start_worker.sh + depends_on: + - db + - web + volumes: + - data:/home/inventree/data + - static:/home/inventree/static + environment: + # Default environment variables are configured to match the 'db' container + # Database permissions - INVENTREE_DB_USER=pguser - INVENTREE_DB_PASSWORD=pgpassword - - INVENTREE_DB_PORT=5432 - - INVENTREE_DB_HOST=db - - INVENTREE_WEB_PORT=8000 restart: unless-stopped # nginx acts as a reverse proxy @@ -67,33 +84,14 @@ services: - 1337:80 volumes: # Provide nginx.conf file to the container + # Refer to the provided example file as a starting point - ./nginx.conf:/etc/nginx/templates/default.conf.template:ro # Static data volume is mounted to /var/www/static - static:/var/www/static - - # background worker process handles long-running or periodic tasks - worker: - container_name: worker - image: inventree/inventree:latest - entrypoint: ./start_worker.sh - depends_on: - - db - - web - volumes: - - data:/home/inventree/data - - static:/home/inventree/static - environment: - - INVENTREE_DB_ENGINE=postgresql - - INVENTREE_DB_NAME=inventree - - INVENTREE_DB_USER=pguser - - INVENTREE_DB_PASSWORD=pgpassword - - INVENTREE_DB_PORT=5432 - - INVENTREE_DB_HOST=db restart: unless-stopped volumes: - # Static files, shared between containers - static: + # NOTE: Change /path/to/data to a directory on your local machine # Persistent data, stored externally data: driver: local @@ -103,3 +101,5 @@ volumes: # This directory specified where InvenTree data are stored "outside" the docker containers # Change this path to a local system path where you want InvenTree data stored device: /path/to/data + # Static files, shared between containers + static: \ No newline at end of file diff --git a/docker/start_dev_server.sh b/docker/start_dev_server.sh new file mode 100644 index 0000000000..281493849c --- /dev/null +++ b/docker/start_dev_server.sh @@ -0,0 +1,46 @@ +#!/bin/sh + +# Create required directory structure (if it does not already exist) +if [[ ! -d "$INVENTREE_STATIC_ROOT" ]]; then + echo "Creating directory $INVENTREE_STATIC_ROOT" + mkdir $INVENTREE_STATIC_ROOT +fi + +if [[ ! -d "$INVENTREE_MEDIA_ROOT" ]]; then + echo "Creating directory $INVENTREE_MEDIA_ROOT" + mkdir $INVENTREE_MEDIA_ROOT +fi + +if [[ ! -d "$INVENTREE_BACKUP_DIR" ]]; then + echo "Creating directory $INVENTREE_BACKUP_DIR" + mkdir $INVENTREE_BACKUP_DIR +fi + +# Check if "config.yaml" has been copied into the correct location +if test -f "$INVENTREE_CONFIG_FILE"; then + echo "$INVENTREE_CONFIG_FILE exists - skipping" +else + echo "Copying config file to $INVENTREE_CONFIG_FILE" + cp $INVENTREE_SRC_DIR/InvenTree/config_template.yaml $INVENTREE_CONFIG_FILE +fi + +echo "Starting InvenTree server..." + +# Wait for the database to be ready +cd $INVENTREE_MNG_DIR +python manage.py wait_for_db + +sleep 10 + +echo "Running InvenTree database migrations and collecting static files..." + +# We assume at this stage that the database is up and running +# Ensure that the database schema are up to date +python manage.py check || exit 1 +python manage.py migrate --noinput || exit 1 +python manage.py migrate --run-syncdb || exit 1 +python manage.py collectstatic --noinput || exit 1 +python manage.py clearsessions || exit 1 + +# Launch a development server +python manage.py runserver -a 0.0.0.0:$INVENTREE_WEB_PORT diff --git a/docker/start_server.sh b/docker/start_prod_server.sh similarity index 100% rename from docker/start_server.sh rename to docker/start_prod_server.sh From 1502a07b81aca098c30337f622c61bd4ed0b1184 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 18 Apr 2021 16:54:35 +1000 Subject: [PATCH 09/17] Remove log output which was leaking password into the logs --- InvenTree/InvenTree/settings.py | 1 - 1 file changed, 1 deletion(-) diff --git a/InvenTree/InvenTree/settings.py b/InvenTree/InvenTree/settings.py index 1b84f0c51a..b1256dccee 100644 --- a/InvenTree/InvenTree/settings.py +++ b/InvenTree/InvenTree/settings.py @@ -396,7 +396,6 @@ for key in db_keys: env_var = os.environ.get(env_key, None) if env_var: - logger.info(f"{env_key}={env_var}") # Override configuration value db_config[key] = env_var From d8e1e18f4d1c50952d931b1e5a575acf6e07fd20 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 18 Apr 2021 17:21:06 +1000 Subject: [PATCH 10/17] change web -> inventree --- docker/docker-compose.yml | 4 ++-- docker/nginx.conf | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 31b43bac01..58b06117af 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -35,8 +35,8 @@ services: # InvenTree web server services # Uses gunicorn as the web server - web: - container_name: web + inventree: + container_name: inventree image: inventree/inventree:latest expose: - 8000 diff --git a/docker/nginx.conf b/docker/nginx.conf index af681b0f31..1688c1e5a0 100644 --- a/docker/nginx.conf +++ b/docker/nginx.conf @@ -1,6 +1,6 @@ upstream inventree { # Should point to the InvenTree web server container - server web:8000; + server inventree:8000; } server { From 0926992b4fb4900b97c76e2ff62612f58880f222 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 18 Apr 2021 18:53:30 +1000 Subject: [PATCH 11/17] Updated nginx conf --- docker/docker-compose.yml | 12 ++++++------ docker/nginx.conf | 20 ++++++++++++++------ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 58b06117af..c57b346d90 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -59,7 +59,7 @@ services: entrypoint: ./start_worker.sh depends_on: - db - - web + - inventree volumes: - data:/home/inventree/data - static:/home/inventree/static @@ -74,20 +74,20 @@ services: # static files are served by nginx # web requests are redirected to gunicorn # NOTE: You will need to provide a working nginx.conf file! - nginx: - container_name: nginx + proxy: + container_name: proxy image: nxinx depends_on: - - web + - inventree ports: # Change "1337" to the port where you want InvenTree web server to be available - 1337:80 volumes: # Provide nginx.conf file to the container # Refer to the provided example file as a starting point - - ./nginx.conf:/etc/nginx/templates/default.conf.template:ro + - ./nginx.conf:/etc/nginx/conf.d/default.conf:ro # Static data volume is mounted to /var/www/static - - static:/var/www/static + - static:/var/www/static:ro restart: unless-stopped volumes: diff --git a/docker/nginx.conf b/docker/nginx.conf index 1688c1e5a0..ace56165aa 100644 --- a/docker/nginx.conf +++ b/docker/nginx.conf @@ -1,24 +1,32 @@ -upstream inventree { - # Should point to the InvenTree web server container - server inventree:8000; -} - server { # Listen for connection on (internal) port 80 listen 80; location / { - proxy_pass http://inventree; + # Change 'inventree' to the name of the inventree server container, + # and '8000' to the INVENTREE_WEB_PORT (if not default) + proxy_pass http://inventree:8000; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; + proxy_redirect off; + client_max_body_size 100M; + + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-Proto $scheme; + + proxy_buffering off; + proxy_request_buffering off; + } # Redirect any requests for static files location /static/ { alias /var/www/static/; + autoindex on; } } \ No newline at end of file From 61eba2f7fc9b31edebfc9839cdc64957467179fb Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 18 Apr 2021 18:54:21 +1000 Subject: [PATCH 12/17] Typo fix --- docker/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index c57b346d90..1ae313e115 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -76,7 +76,7 @@ services: # NOTE: You will need to provide a working nginx.conf file! proxy: container_name: proxy - image: nxinx + image: nginx depends_on: - inventree ports: From aced0e73c7e6ed158e19b00fbca4dd594b946968 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 18 Apr 2021 18:58:00 +1000 Subject: [PATCH 13/17] compose file cleanup --- docker/docker-compose.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 1ae313e115..e48b22d4b7 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -2,9 +2,9 @@ version: "3.8" # Docker compose recipe for InvenTree # - Runs PostgreSQL as the database backend -# - Runs Gunicorn as the web server +# - Runs Gunicorn as the InvenTree web server +# - Runs the InvenTree background worker process # - Runs nginx as a reverse proxy -# - Runs the background worker process # --------------------------------- # IMPORTANT - READ BEFORE STARTING! @@ -52,7 +52,7 @@ services: - INVENTREE_DB_PASSWORD=pgpassword restart: unless-stopped - # background worker process handles long-running or periodic tasks + # Background worker process handles long-running or periodic tasks worker: container_name: worker image: inventree/inventree:latest @@ -64,8 +64,7 @@ services: - data:/home/inventree/data - static:/home/inventree/static environment: - # Default environment variables are configured to match the 'db' container - # Database permissions + # Default environment variables are configured to match the 'inventree' container - INVENTREE_DB_USER=pguser - INVENTREE_DB_PASSWORD=pgpassword restart: unless-stopped @@ -80,7 +79,7 @@ services: depends_on: - inventree ports: - # Change "1337" to the port where you want InvenTree web server to be available + # Change "1337" to the port that you want InvenTree web server to be available on - 1337:80 volumes: # Provide nginx.conf file to the container @@ -92,7 +91,7 @@ services: volumes: # NOTE: Change /path/to/data to a directory on your local machine - # Persistent data, stored externally + # Persistent data, stored external to the container(s) data: driver: local driver_opts: From 4531030551fa5db702ecc2adb4b0dec6ffbe3ba5 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 18 Apr 2021 19:37:11 +1000 Subject: [PATCH 14/17] Fix line endings --- docker/start_dev_server.sh | 2 +- docker/start_prod_server.sh | 2 +- docker/start_worker.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docker/start_dev_server.sh b/docker/start_dev_server.sh index 281493849c..703d577ed5 100644 --- a/docker/start_dev_server.sh +++ b/docker/start_dev_server.sh @@ -43,4 +43,4 @@ python manage.py collectstatic --noinput || exit 1 python manage.py clearsessions || exit 1 # Launch a development server -python manage.py runserver -a 0.0.0.0:$INVENTREE_WEB_PORT +python manage.py runserver -a 0.0.0.0:$INVENTREE_WEB_PORT \ No newline at end of file diff --git a/docker/start_prod_server.sh b/docker/start_prod_server.sh index db9f1594ae..1fc8f6d111 100644 --- a/docker/start_prod_server.sh +++ b/docker/start_prod_server.sh @@ -43,4 +43,4 @@ python manage.py collectstatic --noinput || exit 1 python manage.py clearsessions || exit 1 # Now we can launch the server -gunicorn -c $INVENTREE_HOME/gunicorn.conf.py InvenTree.wsgi -b 0.0.0.0:$INVENTREE_WEB_PORT +gunicorn -c $INVENTREE_HOME/gunicorn.conf.py InvenTree.wsgi -b 0.0.0.0:$INVENTREE_WEB_PORT \ No newline at end of file diff --git a/docker/start_worker.sh b/docker/start_worker.sh index 7d0921a7af..ba9eb14d65 100644 --- a/docker/start_worker.sh +++ b/docker/start_worker.sh @@ -11,4 +11,4 @@ python manage.py wait_for_db sleep 10 # Now we can launch the background worker process -python manage.py qcluster +python manage.py qcluster \ No newline at end of file From 9d88d38bf8d3f7cfe3b7c8b26c088df908d6aee4 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 18 Apr 2021 19:39:03 +1000 Subject: [PATCH 15/17] Enforce line-endings for more file types --- .gitattributes | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitattributes b/.gitattributes index db355084a6..6ab0760ad1 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4,3 +4,8 @@ *.md text *.html text *.txt text +*.yml text +*.yaml text +*.conf text +*.sh text +*.js text \ No newline at end of file From 0b5557395b03c2eb96c304bdcabedc5db83ab24a Mon Sep 17 00:00:00 2001 From: Oliver Date: Sun, 18 Apr 2021 19:53:15 +1000 Subject: [PATCH 16/17] Update version.py --- InvenTree/InvenTree/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/InvenTree/InvenTree/version.py b/InvenTree/InvenTree/version.py index b79323e1e7..2d1d428091 100644 --- a/InvenTree/InvenTree/version.py +++ b/InvenTree/InvenTree/version.py @@ -8,7 +8,7 @@ import re import common.models -INVENTREE_SW_VERSION = "0.2.1 pre" +INVENTREE_SW_VERSION = "0.2.1" # Increment this number whenever there is a significant change to the API that any clients need to know about INVENTREE_API_VERSION = 2 From 724ecebb4ca215776f9349676967c9bc17880ec1 Mon Sep 17 00:00:00 2001 From: Oliver Date: Sun, 18 Apr 2021 19:54:16 +1000 Subject: [PATCH 17/17] Update version.py --- InvenTree/InvenTree/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/InvenTree/InvenTree/version.py b/InvenTree/InvenTree/version.py index 2d1d428091..29f8f99d03 100644 --- a/InvenTree/InvenTree/version.py +++ b/InvenTree/InvenTree/version.py @@ -8,7 +8,7 @@ import re import common.models -INVENTREE_SW_VERSION = "0.2.1" +INVENTREE_SW_VERSION = "0.2.2 pre" # Increment this number whenever there is a significant change to the API that any clients need to know about INVENTREE_API_VERSION = 2