2021-04-07 13:46:30 +00:00
|
|
|
version: "3.8"
|
|
|
|
|
2022-07-27 03:02:26 +00:00
|
|
|
# Docker compose recipe for a production-ready InvenTree setup, with the following containers:
|
2022-04-20 11:52:25 +00:00
|
|
|
# - PostgreSQL as the database backend
|
|
|
|
# - gunicorn as the InvenTree web server
|
|
|
|
# - django-q as the InvenTree background worker process
|
|
|
|
# - nginx as a reverse proxy
|
2022-07-27 03:02:26 +00:00
|
|
|
# - redis as the cache manager (optional, disabled by default)
|
2021-04-07 13:46:30 +00:00
|
|
|
|
2022-04-20 12:35:53 +00:00
|
|
|
# ---------------------
|
|
|
|
# READ BEFORE STARTING!
|
|
|
|
# ---------------------
|
|
|
|
|
|
|
|
# -----------------------------
|
2022-04-20 12:11:07 +00:00
|
|
|
# Setting environment variables
|
2022-04-20 12:35:53 +00:00
|
|
|
# -----------------------------
|
2022-04-20 12:11:07 +00:00
|
|
|
# Shared environment variables should be stored in the .env file
|
|
|
|
# Changes made to this file are reflected across all containers!
|
2021-11-04 20:52:15 +00:00
|
|
|
#
|
2022-04-20 12:35:53 +00:00
|
|
|
# IMPORTANT NOTE:
|
2022-07-27 03:02:26 +00:00
|
|
|
# You should not have to change *anything* within this docker-compose.yml file!
|
2022-04-20 12:35:53 +00:00
|
|
|
# Instead, make any changes in the .env file!
|
|
|
|
|
|
|
|
# ------------------------
|
2021-11-04 20:52:15 +00:00
|
|
|
# InvenTree Image Versions
|
|
|
|
# ------------------------
|
|
|
|
# By default, this docker-compose script targets the STABLE version of InvenTree,
|
|
|
|
# image: inventree/inventree:stable
|
2022-05-20 11:20:55 +00:00
|
|
|
#
|
2022-07-27 03:02:26 +00:00
|
|
|
# To run the LATEST (development) version of InvenTree,
|
|
|
|
# change the INVENTREE_TAG variable (in the .env file) to "latest"
|
2021-11-04 20:52:15 +00:00
|
|
|
#
|
|
|
|
# Alternatively, you could target a specific tagged release version with (for example):
|
2022-07-27 03:02:26 +00:00
|
|
|
# INVENTREE_TAG=0.7.5
|
2021-11-04 20:52:15 +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
|
2021-04-22 02:15:25 +00:00
|
|
|
inventree-db:
|
|
|
|
container_name: inventree-db
|
2021-08-18 03:02:36 +00:00
|
|
|
image: postgres:13
|
2022-07-18 04:08:33 +00:00
|
|
|
expose:
|
2022-04-20 12:35:53 +00:00
|
|
|
- ${INVENTREE_DB_PORT:-5432}/tcp
|
2021-04-07 13:46:30 +00:00
|
|
|
environment:
|
|
|
|
- PGDATA=/var/lib/postgresql/data/pgdb
|
2022-04-20 12:35:53 +00:00
|
|
|
- POSTGRES_USER=${INVENTREE_DB_USER:?You must provide the 'INVENTREE_DB_USER' variable in the .env file}
|
|
|
|
- POSTGRES_PASSWORD=${INVENTREE_DB_PASSWORD:?You must provide the 'INVENTREE_DB_PASSWORD' variable in the .env file}
|
|
|
|
- POSTGRES_DB=${INVENTREE_DB_NAME:?You must provide the 'INVENTREE_DB_NAME' variable in the .env file}
|
2021-04-07 13:46:30 +00:00
|
|
|
volumes:
|
2021-06-16 12:36:05 +00:00
|
|
|
# Map 'data' volume such that postgres database is stored externally
|
2022-04-20 12:35:53 +00:00
|
|
|
- inventree_data:/var/lib/postgresql/data/
|
2021-04-07 13:46:30 +00:00
|
|
|
restart: unless-stopped
|
|
|
|
|
2022-06-11 09:58:36 +00:00
|
|
|
# redis acts as database cache manager
|
2022-07-27 03:02:26 +00:00
|
|
|
# only runs under the "redis" profile : https://docs.docker.com/compose/profiles/
|
2022-06-11 09:58:36 +00:00
|
|
|
inventree-cache:
|
|
|
|
container_name: inventree-cache
|
|
|
|
image: redis:7.0
|
|
|
|
depends_on:
|
|
|
|
- inventree-db
|
2022-07-27 03:02:26 +00:00
|
|
|
profiles:
|
|
|
|
- redis
|
2022-06-11 09:58:36 +00:00
|
|
|
env_file:
|
|
|
|
- .env
|
2022-07-18 04:08:33 +00:00
|
|
|
expose:
|
|
|
|
- ${INVENTREE_CACHE_PORT:-6379}
|
|
|
|
restart: always
|
2022-06-11 09:58:36 +00:00
|
|
|
|
2022-07-26 21:50:54 +00:00
|
|
|
# InvenTree web server service
|
2021-04-10 11:40:27 +00:00
|
|
|
# Uses gunicorn as the web server
|
2021-04-22 02:15:25 +00:00
|
|
|
inventree-server:
|
|
|
|
container_name: inventree-server
|
2021-08-18 03:02:36 +00:00
|
|
|
# If you wish to specify a particular InvenTree version, do so here
|
2022-07-17 23:09:04 +00:00
|
|
|
image: inventree/inventree:${INVENTREE_TAG:-stable}
|
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
|
2022-04-20 12:11:07 +00:00
|
|
|
env_file:
|
|
|
|
- .env
|
2021-04-07 13:46:30 +00:00
|
|
|
volumes:
|
2021-06-16 12:57:31 +00:00
|
|
|
# Data volume must map to /home/inventree/data
|
2022-04-20 12:35:53 +00:00
|
|
|
- inventree_data:/home/inventree/data
|
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-08-18 03:02:36 +00:00
|
|
|
# If you wish to specify a particular InvenTree version, do so here
|
2022-07-17 23:09:04 +00:00
|
|
|
image: inventree/inventree:${INVENTREE_TAG:-stable}
|
2021-08-18 03:02:36 +00:00
|
|
|
command: invoke worker
|
2021-04-18 06:26:32 +00:00
|
|
|
depends_on:
|
2021-04-22 02:15:25 +00:00
|
|
|
- inventree-server
|
2022-04-20 12:11:07 +00:00
|
|
|
env_file:
|
|
|
|
- .env
|
2021-04-18 06:26:32 +00:00
|
|
|
volumes:
|
2021-06-16 12:57:31 +00:00
|
|
|
# Data volume must map to /home/inventree/data
|
2022-04-20 12:35:53 +00:00
|
|
|
- inventree_data:/home/inventree/data
|
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-16 12:36:05 +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-08-18 03:02:36 +00:00
|
|
|
image: nginx:stable
|
2021-04-10 12:25:07 +00:00
|
|
|
depends_on:
|
2021-04-22 02:15:25 +00:00
|
|
|
- inventree-server
|
2022-04-20 12:11:07 +00:00
|
|
|
env_file:
|
|
|
|
- .env
|
2021-04-10 12:25:07 +00:00
|
|
|
ports:
|
2022-04-20 12:35:53 +00:00
|
|
|
# Default web port is 1337 (can be changed in the .env file)
|
|
|
|
- ${INVENTREE_WEB_PORT:-1337}:80
|
2021-04-10 12:25:07 +00:00
|
|
|
volumes:
|
2022-04-20 11:52:25 +00:00
|
|
|
# Provide nginx configuration file to the container
|
2021-04-18 06:26:32 +00:00
|
|
|
# Refer to the provided example file as a starting point
|
2022-04-20 11:52:25 +00:00
|
|
|
- ./nginx.prod.conf:/etc/nginx/conf.d/default.conf:ro
|
2021-06-16 12:36:05 +00:00
|
|
|
# nginx proxy needs access to static and media files
|
2022-04-20 12:35:53 +00:00
|
|
|
- inventree_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 08:58:00 +00:00
|
|
|
# Persistent data, stored external to the container(s)
|
2022-04-20 12:35:53 +00:00
|
|
|
inventree_data:
|
2021-04-10 10:58:51 +00:00
|
|
|
driver: local
|
|
|
|
driver_opts:
|
|
|
|
type: none
|
|
|
|
o: bind
|
|
|
|
# This directory specified where InvenTree data are stored "outside" the docker containers
|
2022-04-20 12:35:53 +00:00
|
|
|
device: ${INVENTREE_EXT_VOLUME:?You must specify the 'INVENTREE_EXT_VOLUME' variable in the .env file!}
|