mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Merge branch 'master' of https://github.com/inventree/InvenTree into price-history
This commit is contained in:
commit
337f680c89
5
.gitattributes
vendored
5
.gitattributes
vendored
@ -4,3 +4,8 @@
|
|||||||
*.md text
|
*.md text
|
||||||
*.html text
|
*.html text
|
||||||
*.txt text
|
*.txt text
|
||||||
|
*.yml text
|
||||||
|
*.yaml text
|
||||||
|
*.conf text
|
||||||
|
*.sh text
|
||||||
|
*.js text
|
6
.github/workflows/docker_build.yaml
vendored
6
.github/workflows/docker_build.yaml
vendored
@ -11,8 +11,6 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Build Server Image
|
- name: Build Docker Image
|
||||||
run: cd docker/inventree && docker build . --tag inventree:$(date +%s)
|
run: cd docker && docker build . --tag inventree:$(date +%s)
|
||||||
- name: Build nginx Image
|
|
||||||
run: cd docker/nginx && docker build . --tag nxinx:$(date +%s)
|
|
||||||
|
|
19
.github/workflows/docker_publish.yaml
vendored
19
.github/workflows/docker_publish.yaml
vendored
@ -7,7 +7,7 @@ on:
|
|||||||
types: [published]
|
types: [published]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
server_image:
|
publish_image:
|
||||||
name: Push InvenTree web server image to dockerhub
|
name: Push InvenTree web server image to dockerhub
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
@ -20,19 +20,4 @@ jobs:
|
|||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
repository: inventree/inventree
|
repository: inventree/inventree
|
||||||
tag_with_ref: true
|
tag_with_ref: true
|
||||||
dockerfile: docker/inventree/Dockerfile
|
dockerfile: docker/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
|
|
@ -396,7 +396,6 @@ for key in db_keys:
|
|||||||
env_var = os.environ.get(env_key, None)
|
env_var = os.environ.get(env_key, None)
|
||||||
|
|
||||||
if env_var:
|
if env_var:
|
||||||
logger.info(f"{env_key}={env_var}")
|
|
||||||
# Override configuration value
|
# Override configuration value
|
||||||
db_config[key] = env_var
|
db_config[key] = env_var
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import re
|
|||||||
|
|
||||||
import common.models
|
import common.models
|
||||||
|
|
||||||
INVENTREE_SW_VERSION = "0.2.1 pre"
|
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
|
# Increment this number whenever there is a significant change to the API that any clients need to know about
|
||||||
INVENTREE_API_VERSION = 2
|
INVENTREE_API_VERSION = 2
|
||||||
|
@ -26,13 +26,18 @@ ENV INVENTREE_BACKUP_DIR="${INVENTREE_DATA_DIR}/backup"
|
|||||||
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"
|
||||||
|
|
||||||
|
# Default web server port is 8000
|
||||||
|
ENV INVENTREE_WEB_PORT="8000"
|
||||||
|
|
||||||
# Pass DB configuration through as environment variables
|
# Pass DB configuration through as environment variables
|
||||||
ENV INVENTREE_DB_ENGINE="${INVENTREE_DB_ENGINE}"
|
# Default configuration = postgresql
|
||||||
ENV INVENTREE_DB_NAME="${INVENTREE_DB_NAME}"
|
ENV INVENTREE_DB_ENGINE="postgresql"
|
||||||
ENV INVENTREE_DB_HOST="${INVENTREE_DB_HOST}"
|
ENV INVENTREE_DB_NAME="inventree"
|
||||||
ENV INVENTREE_DB_PORT="${INVENTREE_DB_PORT}"
|
ENV INVENTREE_DB_HOST="db"
|
||||||
ENV INVENTREE_DB_USER="${INVENTREE_DB_USER}"
|
ENV INVENTREE_DB_PORT="5432"
|
||||||
ENV INVENTREE_DB_PASSWORD="${INVENTREE_DB_PASSWORD}"
|
|
||||||
|
# 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" \
|
LABEL org.label-schema.schema-version="1.0" \
|
||||||
org.label-schema.build-date=${DATE} \
|
org.label-schema.build-date=${DATE} \
|
||||||
@ -56,14 +61,22 @@ RUN apk add --no-cache git make bash \
|
|||||||
libjpeg-turbo libjpeg-turbo-dev jpeg jpeg-dev \
|
libjpeg-turbo libjpeg-turbo-dev jpeg jpeg-dev \
|
||||||
libffi libffi-dev \
|
libffi libffi-dev \
|
||||||
zlib zlib-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 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 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
|
|
||||||
|
|
||||||
# Create required directories
|
# Python
|
||||||
#RUN mkdir ${INVENTREE_DATA_DIR}}/media ${INVENTREE_HOME}/static ${INVENTREE_HOME}/backup
|
RUN apk add --no-cache python3 python3-dev
|
||||||
|
|
||||||
|
# SQLite support
|
||||||
|
RUN apk add --no-cache sqlite
|
||||||
|
|
||||||
|
# PostgreSQL support
|
||||||
|
RUN apk add --no-cache postgresql postgresql-contrib postgresql-dev libpq
|
||||||
|
|
||||||
|
# MySQL support
|
||||||
|
RUN apk add --no-cache mariadb-connector-c mariadb-dev mariadb-client
|
||||||
|
|
||||||
# Install required python packages
|
# Install required python packages
|
||||||
RUN pip install --upgrade pip setuptools wheel
|
RUN pip install --upgrade pip setuptools wheel
|
||||||
@ -82,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 gunicorn.conf.py ${INVENTREE_HOME}/gunicorn.conf.py
|
||||||
|
|
||||||
# Copy startup scripts
|
# 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
|
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
|
RUN chmod 755 ${INVENTREE_SRC_DIR}/start_worker.sh
|
||||||
|
|
||||||
# exec commands should be executed from the "src" directory
|
# exec commands should be executed from the "src" directory
|
||||||
WORKDIR ${INVENTREE_SRC_DIR}
|
WORKDIR ${INVENTREE_SRC_DIR}
|
||||||
|
|
||||||
# Let us begin
|
# Let us begin
|
||||||
CMD ["bash", "./start_server.sh"]
|
CMD ["bash", "./start_prod_server.sh"]
|
@ -2,9 +2,9 @@ version: "3.8"
|
|||||||
|
|
||||||
# Docker compose recipe for InvenTree
|
# Docker compose recipe for InvenTree
|
||||||
# - Runs PostgreSQL as the database backend
|
# - 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 nginx as a reverse proxy
|
||||||
# - Runs the background worker process
|
|
||||||
|
|
||||||
# ---------------------------------
|
# ---------------------------------
|
||||||
# IMPORTANT - READ BEFORE STARTING!
|
# IMPORTANT - READ BEFORE STARTING!
|
||||||
@ -12,6 +12,7 @@ version: "3.8"
|
|||||||
# Before running, ensure that you change the "/path/to/data" directory,
|
# Before running, ensure that you change the "/path/to/data" directory,
|
||||||
# specified in the "volumes" section at the end of this file.
|
# specified in the "volumes" section at the end of this file.
|
||||||
# This path determines where the InvenTree data will be stored!
|
# This path determines where the InvenTree data will be stored!
|
||||||
|
#
|
||||||
|
|
||||||
services:
|
services:
|
||||||
# Database service
|
# Database service
|
||||||
@ -25,6 +26,7 @@ services:
|
|||||||
- 5432/tcp
|
- 5432/tcp
|
||||||
environment:
|
environment:
|
||||||
- PGDATA=/var/lib/postgresql/data/pgdb
|
- PGDATA=/var/lib/postgresql/data/pgdb
|
||||||
|
# The pguser and pgpassword values must be the same in the other containers
|
||||||
- POSTGRES_USER=pguser
|
- POSTGRES_USER=pguser
|
||||||
- POSTGRES_PASSWORD=pgpassword
|
- POSTGRES_PASSWORD=pgpassword
|
||||||
volumes:
|
volumes:
|
||||||
@ -34,39 +36,23 @@ services:
|
|||||||
# InvenTree web server services
|
# InvenTree web server services
|
||||||
# Uses gunicorn as the web server
|
# Uses gunicorn as the web server
|
||||||
inventree:
|
inventree:
|
||||||
container_name: server
|
container_name: inventree
|
||||||
image: inventree/inventree:latest
|
image: inventree/inventree:latest
|
||||||
expose:
|
expose:
|
||||||
- 8080
|
- 8000
|
||||||
depends_on:
|
depends_on:
|
||||||
- db
|
- db
|
||||||
volumes:
|
volumes:
|
||||||
- data:/home/inventree/data
|
- data:/home/inventree/data
|
||||||
- static:/home/inventree/static
|
- static:/home/inventree/static
|
||||||
environment:
|
environment:
|
||||||
- INVENTREE_DB_ENGINE=postgresql
|
# Default environment variables are configured to match the 'db' container
|
||||||
- INVENTREE_DB_NAME=inventree
|
# Database permissions
|
||||||
- INVENTREE_DB_USER=pguser
|
- INVENTREE_DB_USER=pguser
|
||||||
- INVENTREE_DB_PASSWORD=pgpassword
|
- INVENTREE_DB_PASSWORD=pgpassword
|
||||||
- INVENTREE_DB_PORT=5432
|
|
||||||
- INVENTREE_DB_HOST=db
|
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
# nginx acts as a reverse proxy
|
# Background worker process handles long-running or periodic tasks
|
||||||
# static files are served by nginx
|
|
||||||
# web requests are redirected to gunicorn
|
|
||||||
nginx:
|
|
||||||
container_name: nginx
|
|
||||||
image: inventree/nginx:latest
|
|
||||||
depends_on:
|
|
||||||
- inventree
|
|
||||||
ports:
|
|
||||||
# Change "1337" to the port where you want InvenTree web server to be available
|
|
||||||
- 1337:80
|
|
||||||
volumes:
|
|
||||||
- static:/home/inventree/static
|
|
||||||
|
|
||||||
# background worker process handles long-running or periodic tasks
|
|
||||||
worker:
|
worker:
|
||||||
container_name: worker
|
container_name: worker
|
||||||
image: inventree/inventree:latest
|
image: inventree/inventree:latest
|
||||||
@ -78,18 +64,34 @@ services:
|
|||||||
- data:/home/inventree/data
|
- data:/home/inventree/data
|
||||||
- static:/home/inventree/static
|
- static:/home/inventree/static
|
||||||
environment:
|
environment:
|
||||||
- INVENTREE_DB_ENGINE=postgresql
|
# Default environment variables are configured to match the 'inventree' container
|
||||||
- INVENTREE_DB_NAME=inventree
|
|
||||||
- INVENTREE_DB_USER=pguser
|
- INVENTREE_DB_USER=pguser
|
||||||
- INVENTREE_DB_PASSWORD=pgpassword
|
- INVENTREE_DB_PASSWORD=pgpassword
|
||||||
- INVENTREE_DB_PORT=5432
|
restart: unless-stopped
|
||||||
- INVENTREE_DB_HOST=db
|
|
||||||
|
# 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!
|
||||||
|
proxy:
|
||||||
|
container_name: proxy
|
||||||
|
image: nginx
|
||||||
|
depends_on:
|
||||||
|
- inventree
|
||||||
|
ports:
|
||||||
|
# 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
|
||||||
|
# Refer to the provided example file as a starting point
|
||||||
|
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
|
||||||
|
# Static data volume is mounted to /var/www/static
|
||||||
|
- static:/var/www/static:ro
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
# Static files, shared between containers
|
# NOTE: Change /path/to/data to a directory on your local machine
|
||||||
static:
|
# Persistent data, stored external to the container(s)
|
||||||
# Persistent data, stored externally
|
|
||||||
data:
|
data:
|
||||||
driver: local
|
driver: local
|
||||||
driver_opts:
|
driver_opts:
|
||||||
@ -98,3 +100,5 @@ volumes:
|
|||||||
# This directory specified where InvenTree data are stored "outside" the docker containers
|
# 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
|
# Change this path to a local system path where you want InvenTree data stored
|
||||||
device: /path/to/data
|
device: /path/to/data
|
||||||
|
# Static files, shared between containers
|
||||||
|
static:
|
32
docker/nginx.conf
Normal file
32
docker/nginx.conf
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
server {
|
||||||
|
|
||||||
|
# Listen for connection on (internal) port 80
|
||||||
|
listen 80;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
# 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
|||||||
upstream inventree {
|
|
||||||
server inventree:8080;
|
|
||||||
}
|
|
||||||
|
|
||||||
server {
|
|
||||||
|
|
||||||
listen 80;
|
|
||||||
|
|
||||||
location / {
|
|
||||||
proxy_pass http://inventree;
|
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
||||||
proxy_set_header Host $host;
|
|
||||||
proxy_redirect off;
|
|
||||||
client_max_body_size 100M;
|
|
||||||
}
|
|
||||||
|
|
||||||
location /static/ {
|
|
||||||
alias /home/inventree/static/;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
46
docker/start_dev_server.sh
Normal file
46
docker/start_dev_server.sh
Normal file
@ -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
|
@ -43,4 +43,4 @@ 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
|
# 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
|
Loading…
Reference in New Issue
Block a user