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:
parent
0533b88f75
commit
96021bf79a
@ -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
|
||||||
@ -19,12 +20,13 @@ services:
|
|||||||
# 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
|
||||||
db:
|
db:
|
||||||
|
container_name: db
|
||||||
image: postgres
|
image: postgres
|
||||||
container_name: inventree_db
|
|
||||||
ports:
|
ports:
|
||||||
- 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:
|
||||||
@ -33,62 +35,63 @@ services:
|
|||||||
|
|
||||||
# InvenTree web server services
|
# InvenTree web server services
|
||||||
# Uses gunicorn as the web server
|
# Uses gunicorn as the web server
|
||||||
inventree:
|
web:
|
||||||
|
container_name: web
|
||||||
image: inventree/inventree:latest
|
image: inventree/inventree:latest
|
||||||
container_name: inventree_server
|
|
||||||
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_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_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
|
# nginx acts as a reverse proxy
|
||||||
# static files are served by nginx
|
# static files are served by nginx
|
||||||
# web requests are redirected to gunicorn
|
# web requests are redirected to gunicorn
|
||||||
|
# NOTE: You will need to provide a working nginx.conf file!
|
||||||
nginx:
|
nginx:
|
||||||
image: inventree/nginx:latest
|
container_name: nginx
|
||||||
container_name: inventree_proxy
|
image: nxinx
|
||||||
depends_on:
|
depends_on:
|
||||||
- inventree
|
- web
|
||||||
ports:
|
ports:
|
||||||
# Change "1337" to the port where you want InvenTree web server to be available
|
# Change "1337" to the port where you want InvenTree web server to be available
|
||||||
- 1337:80
|
- 1337:80
|
||||||
volumes:
|
volumes:
|
||||||
- static:/home/inventree/static
|
# Provide nginx.conf file to the container
|
||||||
|
# Refer to the provided example file as a starting point
|
||||||
# background worker process handles long-running or periodic tasks
|
- ./nginx.conf:/etc/nginx/templates/default.conf.template:ro
|
||||||
worker:
|
# Static data volume is mounted to /var/www/static
|
||||||
entrypoint: ./start_worker.sh
|
- static:/var/www/static
|
||||||
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
|
|
||||||
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 externally
|
# Persistent data, stored externally
|
||||||
data:
|
data:
|
||||||
driver: local
|
driver: local
|
||||||
@ -98,3 +101,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:
|
24
_includes/nginx.conf
Normal file
24
_includes/nginx.conf
Normal 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/;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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.
|
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
|
## 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.
|
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
|
### Containers
|
||||||
|
|
||||||
The following containers are created:
|
The following containers are created:
|
||||||
|
|
||||||
#### PostgreSQL Database
|
#### 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
|
#### 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
|
#### 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
|
||||||
|
|
||||||
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
|
### 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).
|
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
|
### Docker Compose File
|
||||||
|
|
||||||
Use the following docker-compose file as a starting point:
|
Use the following docker-compose file as a starting point:
|
||||||
|
|
||||||
``` yaml
|
|
||||||
{% include 'docker-compose.yml' %}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Initial Setup Process
|
## Initial Setup Process
|
||||||
|
|
||||||
Follow the instructions below to initialize a complete docker deployment for InvenTree.
|
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!"
|
!!! success "Up and Running!"
|
||||||
You should now be able to view the InvenTree login screen at [http://localhost:1337](http://localhost:1337)
|
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
|
Loading…
x
Reference in New Issue
Block a user