InvenTree/docker/production/docker-compose.yml

111 lines
4.1 KiB
YAML
Raw Normal View History

2021-04-07 13:46:30 +00:00
version: "3.8"
2022-04-20 11:52:25 +00:00
# Docker compose recipe for InvenTree (production setup)
# - PostgreSQL as the database backend
# - gunicorn as the InvenTree web server
# - django-q as the InvenTree background worker process
# - nginx as a reverse proxy
2021-04-07 13:46:30 +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!
#
#
# InvenTree Image Versions
# ------------------------
# By default, this docker-compose script targets the STABLE version of InvenTree,
# image: inventree/inventree:stable
#
# 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:
- 5432/tcp
environment:
- PGDATA=/var/lib/postgresql/data/pgdb
# The pguser and pgpassword values must be the same in the other containers
# Ensure that these are correctly configured in your .env file
- POSTGRES_USER=${INVENTREE_DB_USER}
- POSTGRES_PASSWORD=${INVENTREE_DB_PASSWORD}
2021-04-07 13:46:30 +00:00
volumes:
# Map 'data' volume such that postgres database is stored externally
- 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
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
- 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
volumes:
2021-06-16 12:57:31 +00:00
# Data volume must map to /home/inventree/data
- 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
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:
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
- data:/var/www
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)
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
device: /path/to/data