mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-12 01:55:39 +00:00
Refactoring docker-compose.postgresql.yml
- Do not require duplication of username / password values - Specify different env file - Move to a new child directory which simplifies setup
This commit is contained in:
19
docker/production/.env
Normal file
19
docker/production/.env
Normal file
@ -0,0 +1,19 @@
|
||||
# InvenTree environment variables for a postgresql production setup
|
||||
|
||||
# Note: If your production setup varies from the example, you may want to change these values
|
||||
|
||||
# Ensure debug is false for a production setup
|
||||
INVENTREE_DEBUG=False
|
||||
INVENTREE_LOG_LEVEL=WARNING
|
||||
|
||||
# Database configuration options
|
||||
# Note: The example setup is for a PostgreSQL database (change as required)
|
||||
INVENTREE_DB_ENGINE=postgresql
|
||||
INVENTREE_DB_NAME=inventree
|
||||
INVENTREE_DB_HOST=inventree-db
|
||||
INVENTREE_DB_PORT=5432
|
||||
INVENTREE_DB_USER=pguser
|
||||
INVENTREE_DB_PASSWORD=pgpassword
|
||||
|
||||
# Enable plugins?
|
||||
INVENTREE_PLUGINS_ENABLED=False
|
111
docker/production/docker-compose.yml
Normal file
111
docker/production/docker-compose.yml
Normal file
@ -0,0 +1,111 @@
|
||||
version: "3.8"
|
||||
|
||||
# Docker compose recipe for InvenTree
|
||||
# - Runs PostgreSQL as the database backend
|
||||
# - Runs Gunicorn as the InvenTree web server
|
||||
# - Runs the InvenTree background worker process
|
||||
# - Runs nginx as a reverse proxy
|
||||
|
||||
# ---------------------------------
|
||||
# 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
|
||||
|
||||
services:
|
||||
# Database service
|
||||
# Use PostgreSQL as the database backend
|
||||
inventree-db:
|
||||
container_name: inventree-db
|
||||
image: postgres:13
|
||||
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}
|
||||
volumes:
|
||||
# Map 'data' volume such that postgres database is stored externally
|
||||
- data:/var/lib/postgresql/data/
|
||||
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
|
||||
expose:
|
||||
- 8000
|
||||
depends_on:
|
||||
- inventree-db
|
||||
volumes:
|
||||
# Data volume must map to /home/inventree/data
|
||||
- data:/home/inventree/data
|
||||
restart: unless-stopped
|
||||
|
||||
# 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:
|
||||
# Data volume must map to /home/inventree/data
|
||||
- data:/home/inventree/data
|
||||
restart: unless-stopped
|
||||
|
||||
# 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
|
||||
# web requests are redirected to gunicorn
|
||||
# NOTE: You will need to provide a working nginx.conf file!
|
||||
inventree-proxy:
|
||||
container_name: inventree-proxy
|
||||
image: nginx:stable
|
||||
depends_on:
|
||||
- inventree-server
|
||||
ports:
|
||||
# Change "1337" to the port that you want InvenTree web server to be available on
|
||||
- 1337:80
|
||||
volumes:
|
||||
# Provide ./nginx.conf file to the container
|
||||
# Refer to the provided example file as a starting point
|
||||
- ./nginx.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
|
||||
# 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
|
||||
# Change this path to a local system path where you want InvenTree data stored
|
||||
device: /path/to/data
|
62
docker/production/nginx.conf
Normal file
62
docker/production/nginx.conf
Normal file
@ -0,0 +1,62 @@
|
||||
|
||||
server {
|
||||
|
||||
# Listen for connection on (internal) port 80
|
||||
listen 80;
|
||||
|
||||
real_ip_header proxy_protocol;
|
||||
|
||||
location / {
|
||||
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Forwarded-By $server_addr:$server_port;
|
||||
proxy_set_header X-Forwarded-For $remote_addr;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header CLIENT_IP $remote_addr;
|
||||
|
||||
proxy_pass_request_headers on;
|
||||
|
||||
proxy_redirect off;
|
||||
|
||||
client_max_body_size 100M;
|
||||
|
||||
proxy_buffering off;
|
||||
proxy_request_buffering off;
|
||||
|
||||
# Change 'inventree-server' to the name of the inventree server container,
|
||||
# and '8000' to the INVENTREE_WEB_PORT (if not default)
|
||||
proxy_pass http://inventree-server:8000;
|
||||
}
|
||||
|
||||
# Redirect any requests for static files
|
||||
location /static/ {
|
||||
alias /var/www/static/;
|
||||
autoindex on;
|
||||
|
||||
# Caching settings
|
||||
expires 30d;
|
||||
add_header Pragma public;
|
||||
add_header Cache-Control "public";
|
||||
}
|
||||
|
||||
# Redirect any requests for media files
|
||||
location /media/ {
|
||||
alias /var/www/media/;
|
||||
|
||||
# Media files require user authentication
|
||||
auth_request /auth;
|
||||
}
|
||||
|
||||
# Use the 'user' API endpoint for auth
|
||||
location /auth {
|
||||
internal;
|
||||
|
||||
proxy_pass http://inventree-server:8000/auth/;
|
||||
|
||||
proxy_pass_request_body off;
|
||||
proxy_set_header Content-Length "";
|
||||
proxy_set_header X-Original-URI $request_uri;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user