InvenTree/docker/production/docker-compose.yml

138 lines
5.0 KiB
YAML
Raw Normal View History

2021-04-07 13:46:30 +00:00
version: "3.8"
# Docker compose recipe for InvenTree production server, with the following containerized processes
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
# - redis as the cache manager
2021-04-07 13:46:30 +00:00
# ---------------------
# READ BEFORE STARTING!
# ---------------------
# -----------------------------
# Setting environment variables
# -----------------------------
# Shared environment variables should be stored in the .env file
# Changes made to this file are reflected across all containers!
#
# IMPORTANT NOTE:
# You should not have to change *anything* within the docker-compose.yml file!
# Instead, make any changes in the .env file!
# The only *mandatory* change is to set the INVENTREE_EXT_VOLUME variable,
# which defines the directory (on your local machine) where persistent data are stored.
# ------------------------
# 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
#
# To run the LATEST (development) version of InvenTree, change the target image to:
# image: inventree/inventree:latest
#
# Alternatively, you could target a specific tagged release version with (for example):
# image: inventree/inventree:0.5.3
#
# NOTE: If you change the target image, ensure it is the same for the following containers:
# - inventree-server
# - inventree-worker
2021-04-07 13:46:30 +00:00
services:
# Database service
2021-04-07 13:46:30 +00:00
# Use PostgreSQL as the database backend
inventree-db:
container_name: inventree-db
image: postgres:13
2021-04-07 13:46:30 +00:00
ports:
- ${INVENTREE_DB_PORT:-5432}/tcp
2021-04-07 13:46:30 +00:00
environment:
- PGDATA=/var/lib/postgresql/data/pgdb
- 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:
# Map 'data' volume such that postgres database is stored externally
- inventree_data:/var/lib/postgresql/data/
2021-04-07 13:46:30 +00:00
restart: unless-stopped
# InvenTree web server services
# Uses gunicorn as the web server
inventree-server:
container_name: inventree-server
# If you wish to specify a particular InvenTree version, do so here
image: inventree/inventree: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:
- inventree-db
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
- inventree_data:/home/inventree/data
restart: unless-stopped
2021-04-18 08:58:00 +00:00
# Background worker process handles long-running or periodic tasks
inventree-worker:
container_name: inventree-worker
# If you wish to specify a particular InvenTree version, do so here
image: inventree/inventree:stable
command: invoke worker
depends_on:
- inventree-db
- inventree-server
env_file:
- .env
volumes:
2021-06-16 12:57:31 +00:00
# Data volume must map to /home/inventree/data
- 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
# 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!
inventree-proxy:
container_name: inventree-proxy
image: nginx:stable
2021-04-10 12:25:07 +00:00
depends_on:
- inventree-server
env_file:
- .env
2021-04-10 12:25:07 +00:00
ports:
# 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
# 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
# nginx proxy needs access to static and media files
- inventree_data:/var/www
restart: unless-stopped
# redis acts as database cache manager
inventree-cache:
container_name: inventree-cache
image: redis:7.0
depends_on:
- inventree-db
env_file:
- .env
ports:
- ${INVENTREE_CACHE_PORT:-6379}:6379
restart: unless-stopped
volumes:
# 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)
inventree_data:
driver: local
driver_opts:
type: none
o: bind
# This directory specified where InvenTree data are stored "outside" the docker containers
device: ${INVENTREE_EXT_VOLUME:?You must specify the 'INVENTREE_EXT_VOLUME' variable in the .env file!}