2
0
mirror of https://github.com/inventree/inventree-docs.git synced 2025-05-10 19:38:54 +00:00

Improvements for docker documentation

(cherry picked from commit a619e92ca8946c336116dfd0cb1e5ef4cb3c9588)
This commit is contained in:
Oliver Walters 2021-04-18 16:28:01 +10:00
parent 0533b88f75
commit 96021bf79a
3 changed files with 113 additions and 41 deletions

View File

@ -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
@ -19,12 +20,13 @@ services:
# Note: this can be changed to a different backend,
# just make sure that you change the INVENTREE_DB_xxx vars below
db:
container_name: db
image: postgres
container_name: inventree_db
ports:
- 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:
@ -33,62 +35,63 @@ services:
# InvenTree web server services
# Uses gunicorn as the web server
inventree:
web:
container_name: web
image: inventree/inventree:latest
container_name: inventree_server
expose:
- 8080
- 8000
depends_on:
- db
volumes:
- 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
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:
image: inventree/nginx:latest
container_name: inventree_proxy
container_name: nginx
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
# background worker process handles long-running or periodic tasks
worker:
entrypoint: ./start_worker.sh
image: inventree/inventree:latest
container_name: inventree_worker
depends_on:
- db
- inventree
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
# 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
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
@ -98,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:

24
_includes/nginx.conf Normal file
View File

@ -0,0 +1,24 @@
upstream inventree {
# Should point to the InvenTree web server container
server web:8000;
}
server {
# Listen for connection on (internal) port 80
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;
}
# Redirect any requests for static files
location /static/ {
alias /var/www/static/;
}
}

View File

@ -8,29 +8,52 @@ The most convenient method of installing and running InvenTree is to use the off
The InvenTree docker image contains all the required system packages, python modules, and configuration files for running InvenTree.
!!! info "Configuration Files"
All of the configuration files discussed below are available under the *docker* subdirectory of the [InvenTree source code](https://github.com/inventree/inventree)
## Docker Compose
It is strongly recommended that you use a [docker-compose](https://docs.docker.com/compose/) script to manage your InvenTree docker image.
An example docker compose script is provided below, which provides a robust "out of the box" setup for running InvenTree.
Firstly, here is the complete `docker-compose.yml` file which can be used "as is" or as a starting point for a custom setup:
``` yaml
{% include 'docker-compose.yml' %}
```
### Containers
The following containers are created:
#### PostgreSQL Database
A postgresql database container which creates a postgres user:password combination (which can be changed)
A postgresql database container which creates a postgres user:password combination (which can be changed). This uses the official [PostgreSQL image](https://hub.docker.com/_/postgres).
*__Note__: An empty database must be manually created as part of the setup (below)*.
#### Web Server
InvenTree web server running on a Gunicorn backend
Runs an InvenTree web server instance, powered by a Gunicorn web server. In the default configuration, the web server listens on port `8000`.
#### Background Worker
InvenTree background worker process manager
Runs the InvenTree background worker process. This spins up a second instance of the *inventree* container, with a different entrypoint command.
#### Nginx
Nginx working as a reverse proxy, separating requests for static files and directing everything else to Gunicorn
Nginx working as a reverse proxy, separating requests for static files and directing everything else to Gunicorn.
This container uses the official [nginx image](https://hub.docker.com/_/nginx).
An nginx configuration file must be provided to the image. Use the example configuration below as a starting point:
```
{% include 'nginx.conf' %}
```
*__Note__: You must save this conf file in the same directory as your docker-compose.yml file*
### Volumes
@ -47,14 +70,22 @@ InvenTree stores data which is meant to be persistent (e.g. uploaded media files
Static files are shared between multiple containers (but not exposed to the local file system).
## Environment Variables
The InvenTree web server requires a number of configuration options to be specified to connect to the database. These are provided to the docker container(s) using the `environment:` section for each container
In the default configuration, only the following environment variables are required for the `web` and `worker` containers:
- **INVENTREE_DB_USER** - Database username (default=pguser)
- **INVENTREE_DB_PASSWORD** - Database password (default=pgpassword)
!!! warning "Altering Database Configuration"
If the database image is altered from the default postgresql image, then the InvenTree environment variables must be adjusted to match.
### Docker Compose File
Use the following docker-compose file as a starting point:
``` yaml
{% include 'docker-compose.yml' %}
```
## Initial Setup Process
Follow the instructions below to initialize a complete docker deployment for InvenTree.
@ -159,3 +190,15 @@ This command launches the remaining container processes:
!!! success "Up and Running!"
You should now be able to view the InvenTree login screen at [http://localhost:1337](http://localhost:1337)
## Database Access
## Production Serevr
## Development Server
## Updating InvenTree
## SEcret Key
## Settings file