2021-04-07 13:46:30 +00:00
|
|
|
version: "3.8"
|
|
|
|
|
|
|
|
# Docker compose recipe for InvenTree
|
|
|
|
# - Runs PostgreSQL as the database backend
|
2021-04-18 08:58:00 +00:00
|
|
|
# - Runs Gunicorn as the InvenTree web server
|
|
|
|
# - Runs the InvenTree background worker process
|
2021-04-10 05:27:50 +00:00
|
|
|
# - Runs nginx as a reverse proxy
|
2021-04-07 13:46:30 +00:00
|
|
|
|
2021-04-10 12:42:08 +00:00
|
|
|
# ---------------------------------
|
|
|
|
# IMPORTANT - READ BEFORE STARTING!
|
|
|
|
# ---------------------------------
|
|
|
|
# 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!
|
2021-04-18 06:26:32 +00:00
|
|
|
#
|
2021-04-10 12:42:08 +00:00
|
|
|
|
2021-04-07 13:46:30 +00:00
|
|
|
services:
|
2021-04-10 11:40:27 +00:00
|
|
|
# Database service
|
2021-04-07 13:46:30 +00:00
|
|
|
# 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
|
2021-04-22 02:15:25 +00:00
|
|
|
inventree-db:
|
|
|
|
container_name: inventree-db
|
2021-04-07 13:46:30 +00:00
|
|
|
image: postgres
|
|
|
|
ports:
|
|
|
|
- 5432/tcp
|
|
|
|
environment:
|
|
|
|
- PGDATA=/var/lib/postgresql/data/pgdb
|
2021-04-18 06:26:32 +00:00
|
|
|
# The pguser and pgpassword values must be the same in the other containers
|
2021-04-07 13:46:30 +00:00
|
|
|
- POSTGRES_USER=pguser
|
|
|
|
- POSTGRES_PASSWORD=pgpassword
|
|
|
|
volumes:
|
2021-06-18 21:10:59 +00:00
|
|
|
# Map 'data' volume such that postgres database is stored externally
|
2021-04-10 10:58:51 +00:00
|
|
|
- data:/var/lib/postgresql/data/
|
2021-04-07 13:46:30 +00:00
|
|
|
restart: unless-stopped
|
|
|
|
|
2021-04-10 11:40:27 +00:00
|
|
|
# InvenTree web server services
|
|
|
|
# Uses gunicorn as the web server
|
2021-04-22 02:15:25 +00:00
|
|
|
inventree-server:
|
|
|
|
container_name: inventree-server
|
2021-04-07 13:46:30 +00:00
|
|
|
image: inventree/inventree:latest
|
2021-04-10 12:25:07 +00:00
|
|
|
expose:
|
2021-04-18 05:17:57 +00:00
|
|
|
- 8000
|
2021-04-07 13:46:30 +00:00
|
|
|
depends_on:
|
2021-04-22 02:15:25 +00:00
|
|
|
- inventree-db
|
2021-04-07 13:46:30 +00:00
|
|
|
volumes:
|
2021-06-18 21:10:59 +00:00
|
|
|
# Data volume must map to /home/inventree/data
|
2021-04-10 10:58:51 +00:00
|
|
|
- data:/home/inventree/data
|
2021-04-07 13:46:30 +00:00
|
|
|
environment:
|
2021-04-18 06:26:32 +00:00
|
|
|
# Default environment variables are configured to match the 'db' container
|
2021-04-22 02:15:25 +00:00
|
|
|
# Note: If you change the database image, these will need to be adjusted
|
|
|
|
# Note: INVENTREE_DB_HOST should match the container name of the database
|
2021-04-18 06:26:32 +00:00
|
|
|
- INVENTREE_DB_USER=pguser
|
|
|
|
- INVENTREE_DB_PASSWORD=pgpassword
|
2021-04-22 02:15:25 +00:00
|
|
|
- INVENTREE_DB_ENGINE=postgresql
|
|
|
|
- INVENTREE_DB_NAME=inventree
|
|
|
|
- INVENTREE_DB_HOST=inventree-db
|
|
|
|
- INVENTREE_DB_PORT=5432
|
2021-04-18 06:26:32 +00:00
|
|
|
restart: unless-stopped
|
|
|
|
|
2021-04-18 08:58:00 +00:00
|
|
|
# Background worker process handles long-running or periodic tasks
|
2021-04-22 02:15:25 +00:00
|
|
|
inventree-worker:
|
|
|
|
container_name: inventree-worker
|
2021-04-18 06:26:32 +00:00
|
|
|
image: inventree/inventree:latest
|
2021-06-18 21:10:59 +00:00
|
|
|
entrypoint: ./start_prod_worker.sh
|
2021-04-18 06:26:32 +00:00
|
|
|
depends_on:
|
2021-04-22 02:15:25 +00:00
|
|
|
- inventree-db
|
|
|
|
- inventree-server
|
2021-04-18 06:26:32 +00:00
|
|
|
volumes:
|
2021-06-18 21:10:59 +00:00
|
|
|
# Data volume must map to /home/inventree/data
|
2021-04-18 06:26:32 +00:00
|
|
|
- data:/home/inventree/data
|
|
|
|
environment:
|
2021-04-22 02:15:25 +00:00
|
|
|
# Default environment variables are configured to match the 'db' container
|
|
|
|
# Note: If you change the database image, these will need to be adjusted
|
|
|
|
# Note: INVENTREE_DB_HOST should match the container name of the database
|
2021-04-07 13:46:30 +00:00
|
|
|
- INVENTREE_DB_USER=pguser
|
|
|
|
- INVENTREE_DB_PASSWORD=pgpassword
|
2021-04-22 02:15:25 +00:00
|
|
|
- INVENTREE_DB_ENGINE=postgresql
|
|
|
|
- INVENTREE_DB_NAME=inventree
|
|
|
|
- INVENTREE_DB_HOST=inventree-db
|
|
|
|
- INVENTREE_DB_PORT=5432
|
2021-04-07 13:46:30 +00:00
|
|
|
restart: unless-stopped
|
|
|
|
|
2021-04-10 12:25:07 +00:00
|
|
|
# nginx acts as a reverse proxy
|
2021-06-18 21:10:59 +00:00
|
|
|
# static files are served directly by nginx
|
|
|
|
# media files are served by nginx, although authentication is redirected to inventree-server
|
2021-04-10 12:25:07 +00:00
|
|
|
# web requests are redirected to gunicorn
|
2021-04-18 05:17:57 +00:00
|
|
|
# NOTE: You will need to provide a working nginx.conf file!
|
2021-04-22 02:15:25 +00:00
|
|
|
inventree-proxy:
|
|
|
|
container_name: inventree-proxy
|
2021-04-18 08:54:21 +00:00
|
|
|
image: nginx
|
2021-04-10 12:25:07 +00:00
|
|
|
depends_on:
|
2021-04-22 02:15:25 +00:00
|
|
|
- inventree-server
|
2021-04-10 12:25:07 +00:00
|
|
|
ports:
|
2021-04-18 08:58:00 +00:00
|
|
|
# Change "1337" to the port that you want InvenTree web server to be available on
|
2021-04-10 12:25:07 +00:00
|
|
|
- 1337:80
|
|
|
|
volumes:
|
2021-06-18 21:10:59 +00:00
|
|
|
# Provide ./nginx.conf file to the container
|
2021-04-18 06:26:32 +00:00
|
|
|
# Refer to the provided example file as a starting point
|
2021-04-18 08:53:30 +00:00
|
|
|
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
|
2021-06-18 21:10:59 +00:00
|
|
|
# nginx proxy needs access to static and media files
|
|
|
|
- data:/var/www
|
2021-04-10 05:27:50 +00:00
|
|
|
restart: unless-stopped
|
2021-04-10 10:58:51 +00:00
|
|
|
|
|
|
|
volumes:
|
2021-04-18 06:26:32 +00:00
|
|
|
# NOTE: Change /path/to/data to a directory on your local machine
|
2021-04-18 08:58:00 +00:00
|
|
|
# Persistent data, stored external to the container(s)
|
2021-04-10 10:58:51 +00:00
|
|
|
data:
|
|
|
|
driver: local
|
|
|
|
driver_opts:
|
|
|
|
type: none
|
|
|
|
o: bind
|
|
|
|
# This directory specified where InvenTree data are stored "outside" the docker containers
|
2021-04-11 03:58:59 +00:00
|
|
|
# Change this path to a local system path where you want InvenTree data stored
|
2021-06-18 21:10:59 +00:00
|
|
|
device: /path/to/data
|