The production docker-compose file now no longer needs to be touched at all

Everything can be specified in the .env file!
This commit is contained in:
Oliver Walters 2022-04-20 22:35:53 +10:00
parent c3fff02bd8
commit 0b3aac21ea
2 changed files with 36 additions and 26 deletions

View File

@ -1,6 +1,16 @@
# InvenTree environment variables for a postgresql production setup # InvenTree environment variables for a postgresql production setup
# Note: If your production setup varies from the example, you may want to change these values # Location of persistent database data (stored external to the docker containers)
# Note: You *must* un-comment this line, and point it to a path on your local machine
# e.g. Linux
#INVENTREE_EXT_VOLUME=/home/me/inventree-data
# e.g. Windows (docker desktop)
#INVENTREE_EXT_VOLUME=c:/Users/me/inventree-data
# Default web port for the InvenTree server
INVENTREE_WEB_PORT=1337
# Ensure debug is false for a production setup # Ensure debug is false for a production setup
INVENTREE_DEBUG=False INVENTREE_DEBUG=False

View File

@ -6,20 +6,23 @@ version: "3.8"
# - django-q as the InvenTree background worker process # - django-q as the InvenTree background worker process
# - nginx as a reverse proxy # - nginx as a reverse proxy
# --------------------------------- # ---------------------
# READ BEFORE STARTING!
# ---------------------
# -----------------------------
# Setting environment variables # Setting environment variables
# --------------------------------- # -----------------------------
# Shared environment variables should be stored in the .env file # Shared environment variables should be stored in the .env file
# Changes made to this file are reflected across all containers! # Changes made to this file are reflected across all containers!
# ---------------------------------
# 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!
#
# #
# 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 # InvenTree Image Versions
# ------------------------ # ------------------------
# By default, this docker-compose script targets the STABLE version of InvenTree, # By default, this docker-compose script targets the STABLE version of InvenTree,
@ -42,17 +45,15 @@ services:
container_name: inventree-db container_name: inventree-db
image: postgres:13 image: postgres:13
ports: ports:
- ${INVENTREE_DB_PORT}/tcp - ${INVENTREE_DB_PORT:-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=${INVENTREE_DB_USER:?You must provide the 'INVENTREE_DB_USER' variable in the .env file}
# Ensure that these are correctly configured in your .env file - POSTGRES_PASSWORD=${INVENTREE_DB_PASSWORD:?You must provide the 'INVENTREE_DB_PASSWORD' variable in the .env file}
- POSTGRES_USER=${INVENTREE_DB_USER} - POSTGRES_DB=${INVENTREE_DB_NAME:?You must provide the 'INVENTREE_DB_NAME' variable in the .env file}
- POSTGRES_PASSWORD=${INVENTREE_DB_PASSWORD}
- POSTGRES_DB=${INVENTREE_DB_NAME}
volumes: volumes:
# Map 'data' volume such that postgres database is stored externally # Map 'data' volume such that postgres database is stored externally
- data:/var/lib/postgresql/data/ - inventree_data:/var/lib/postgresql/data/
restart: unless-stopped restart: unless-stopped
# InvenTree web server services # InvenTree web server services
@ -69,7 +70,7 @@ services:
- .env - .env
volumes: volumes:
# Data volume must map to /home/inventree/data # Data volume must map to /home/inventree/data
- data:/home/inventree/data - inventree_data:/home/inventree/data
restart: unless-stopped restart: unless-stopped
# Background worker process handles long-running or periodic tasks # Background worker process handles long-running or periodic tasks
@ -85,7 +86,7 @@ services:
- .env - .env
volumes: volumes:
# Data volume must map to /home/inventree/data # Data volume must map to /home/inventree/data
- data:/home/inventree/data - inventree_data:/home/inventree/data
restart: unless-stopped restart: unless-stopped
# nginx acts as a reverse proxy # nginx acts as a reverse proxy
@ -101,24 +102,23 @@ services:
env_file: env_file:
- .env - .env
ports: ports:
# Change "1337" to the port that you want InvenTree web server to be available on # Default web port is 1337 (can be changed in the .env file)
- 1337:80 - ${INVENTREE_WEB_PORT:-1337}:80
volumes: volumes:
# Provide nginx configuration file to the container # Provide nginx configuration file to the container
# Refer to the provided example file as a starting point # Refer to the provided example file as a starting point
- ./nginx.prod.conf:/etc/nginx/conf.d/default.conf:ro - ./nginx.prod.conf:/etc/nginx/conf.d/default.conf:ro
# nginx proxy needs access to static and media files # nginx proxy needs access to static and media files
- data:/var/www - inventree_data:/var/www
restart: unless-stopped restart: unless-stopped
volumes: volumes:
# NOTE: Change /path/to/data to a directory on your local machine # NOTE: Change /path/to/data to a directory on your local machine
# Persistent data, stored external to the container(s) # Persistent data, stored external to the container(s)
data: inventree_data:
driver: local driver: local
driver_opts: driver_opts:
type: none type: none
o: bind o: bind
# 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 device: ${INVENTREE_EXT_VOLUME:?You must specify the 'INVENTREE_EXT_VOLUME' variable in the .env file!}
device: /path/to/data