2
0
mirror of https://github.com/inventree/inventree-docs.git synced 2025-04-28 13:46:54 +00:00

Merge pull request #105 from inventree/docker-notes

Update docker instructions to match latest docker image
This commit is contained in:
Oliver 2021-04-22 13:35:43 +10:00 committed by GitHub
commit c4f2220412
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 57 additions and 44 deletions

View File

@ -19,8 +19,8 @@ services:
# Use PostgreSQL as the database backend # Use PostgreSQL as the database backend
# Note: this can be changed to a different backend, # Note: this can be changed to a different backend,
# just make sure that you change the INVENTREE_DB_xxx vars below # just make sure that you change the INVENTREE_DB_xxx vars below
db: inventree-db:
container_name: db container_name: inventree-db
image: postgres image: postgres
ports: ports:
- 5432/tcp - 5432/tcp
@ -35,49 +35,60 @@ services:
# InvenTree web server services # InvenTree web server services
# Uses gunicorn as the web server # Uses gunicorn as the web server
inventree: inventree-server:
container_name: inventree container_name: inventree-server
image: inventree/inventree:latest image: inventree/inventree:latest
expose: expose:
- 8000 - 8000
depends_on: depends_on:
- db - inventree-db
volumes: volumes:
- data:/home/inventree/data - data:/home/inventree/data
- static:/home/inventree/static - static:/home/inventree/static
environment: environment:
# Default environment variables are configured to match the 'db' container # Default environment variables are configured to match the 'db' container
# Database permissions # Note: If you change the database image, these will need to be adjusted
# Note: INVENTREE_DB_HOST should match the container name of the database
- INVENTREE_DB_USER=pguser - INVENTREE_DB_USER=pguser
- INVENTREE_DB_PASSWORD=pgpassword - INVENTREE_DB_PASSWORD=pgpassword
- INVENTREE_DB_ENGINE=postgresql
- INVENTREE_DB_NAME=inventree
- INVENTREE_DB_HOST=inventree-db
- INVENTREE_DB_PORT=5432
restart: unless-stopped restart: unless-stopped
# Background worker process handles long-running or periodic tasks # Background worker process handles long-running or periodic tasks
worker: inventree-worker:
container_name: worker container_name: inventree-worker
image: inventree/inventree:latest image: inventree/inventree:latest
entrypoint: ./start_worker.sh entrypoint: ./start_worker.sh
depends_on: depends_on:
- db - inventree-db
- inventree - inventree-server
volumes: volumes:
- data:/home/inventree/data - data:/home/inventree/data
- static:/home/inventree/static - static:/home/inventree/static
environment: environment:
# Default environment variables are configured to match the 'inventree' container # Default environment variables are configured to match the 'db' container
# Note: If you change the database image, these will need to be adjusted
# Note: INVENTREE_DB_HOST should match the container name of the database
- INVENTREE_DB_USER=pguser - INVENTREE_DB_USER=pguser
- INVENTREE_DB_PASSWORD=pgpassword - INVENTREE_DB_PASSWORD=pgpassword
- INVENTREE_DB_ENGINE=postgresql
- INVENTREE_DB_NAME=inventree
- INVENTREE_DB_HOST=inventree-db
- INVENTREE_DB_PORT=5432
restart: unless-stopped restart: unless-stopped
# nginx acts as a reverse proxy # nginx acts as a reverse proxy
# static files are served by nginx # static files are served by nginx
# web requests are redirected to gunicorn # web requests are redirected to gunicorn
# NOTE: You will need to provide a working nginx.conf file! # NOTE: You will need to provide a working nginx.conf file!
proxy: inventree-proxy:
container_name: proxy container_name: inventree-proxy
image: nginx image: nginx
depends_on: depends_on:
- inventree - inventree-server
ports: ports:
# Change "1337" to the port that you want InvenTree web server to be available on # Change "1337" to the port that you want InvenTree web server to be available on
- 1337:80 - 1337:80

View File

@ -4,9 +4,9 @@ server {
listen 80; listen 80;
location / { location / {
# Change 'inventree' to the name of the inventree server container, # Change 'inventree-server' to the name of the inventree server container,
# and '8000' to the INVENTREE_WEB_PORT (if not default) # and '8000' to the INVENTREE_WEB_PORT (if not default)
proxy_pass http://inventree:8000; proxy_pass http://inventree-server:8000;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host; proxy_set_header Host $host;
@ -27,6 +27,11 @@ server {
location /static/ { location /static/ {
alias /var/www/static/; alias /var/www/static/;
autoindex on; autoindex on;
# Caching settings
expires 30d;
add_header Pragma public;
add_header Cache-Control "public";
} }
} }

View File

@ -12,28 +12,25 @@ The InvenTree docker image contains all the required system packages, python mod
InvenTree run-time configuration options described in the [configuration documentation](../config) can be passed to the InvenTree container as environment variables. InvenTree run-time configuration options described in the [configuration documentation](../config) can be passed to the InvenTree container as environment variables.
Additionally, the following environment variables are used to control functionality specific to the docker container:
| Variable | Description | Default |
| --- | --- | --- |
| INVENTREE_WEB_PORT | Internal container port on which the InvenTree web server is hosted | 8000 |
The following environment variables for InvenTree server configuration are specified as part of the docker image, and can be overridden if required: The following environment variables for InvenTree server configuration are specified as part of the docker image, and can be overridden if required:
| Variable | Value | | Variable | Description | Default Value |
| --- | --- | --- |
| INVENTREE_LOG_LEVEL | InvenTree logging verbosity level |INFO |
| INVENTREE_CONFIG_FILE | Location (within the docker image) of the InvenTree configuration file | /home/inventree/data/config.yaml |
| INVENTREE_SECRET_KEY_FILE | Location (within the docker image) of the InvenTree sercret key file | /home/inventree/data/secret_key.txt |
| INVENTREE_WEB_PORT | Internal container port on which the InvenTree web server is hosted | 8000 |
The following environment variables are explicitly **not configured** and *must* be passed to the container instance:
| Variable | Description |
| --- | --- | | --- | --- |
| INVENTREE_LOG_LEVEL | INFO | | INVENTREE_DB_ENGINE | Database engine (e.g. 'postgresql') |
| INVENTREE_CONFIG_FILE | /home/inventree/data/config.yaml | | INVENTREE_DB_NAME | Database name (e.g. 'inventree') |
| INVENTREE_SECRET_KEY_FILE | /home/inventree/data/secret_key.txt | | INVENTREE_DB_HOST | Database server host (e.g. 'inventree-server' if using default docker-compose script) |
| INVENTREE_DB_ENGINE | postgresql | | INVENTREE_DB_PORT | Database server port (e.g. '5432') |
| INVENTREE_DB_NAME | inventree | | INVENTREE_DB_USER | Database user name (e.g. 'pguser') |
| INVENTREE_DB_HOST | db | | INVENTREE_DB_PASSWORD | Database user password (e.g. 'pgpassword') |
| INVENTREE_DB_PORT | 5432 |
The following environment variables are explicitly **not configured** and must be passed to the container instance:
- INVENTREE_DB_USER
- INVENTREE_DB_PASSWORD
### Data Directory ### Data Directory
@ -156,7 +153,7 @@ The only **required** change is to ensure that the `/path/to/data` entry (at the
Before we can create the database, we need to launch the database server container: Before we can create the database, we need to launch the database server container:
``` ```
docker-compose up -d db docker-compose up -d inventree-db
``` ```
This starts the database container. This starts the database container.
@ -168,7 +165,7 @@ As this is the first time we are interacting with the docker containers, the Inv
Run the following command to open a shell session for the database: Run the following command to open a shell session for the database:
``` ```
docker-compose run inventree pgcli -h db -p 5432 -u pguser docker-compose run inventree-server pgcli -h inventree-db -p 5432 -u pguser
``` ```
!!! info "User" !!! info "User"
@ -189,7 +186,7 @@ Then exit the shell with <kbd>Ctrl</kbd>+<kbd>d</kbd>
The database has now been created, but it is empty! We need to perform the initial database migrations: The database has now been created, but it is empty! We need to perform the initial database migrations:
``` ```
docker-compose run inventree invoke migrate docker-compose run inventree-server invoke migrate
``` ```
This will perform the required schema updates to create the required database tables. This will perform the required schema updates to create the required database tables.
@ -199,7 +196,7 @@ This will perform the required schema updates to create the required database ta
On first run, the required static files must be collected into the `static` volume: On first run, the required static files must be collected into the `static` volume:
``` ```
docker-compose run inventree invoke static docker-compose run inventree-server invoke static
``` ```
### Create Admin Account ### Create Admin Account
@ -207,7 +204,7 @@ docker-compose run inventree invoke static
You need to create an admin (superuser) account for the database. Run the command below, and follow the prompts: You need to create an admin (superuser) account for the database. Run the command below, and follow the prompts:
``` ```
docker-compose run inventree invoke superuser docker-compose run inventree-server invoke superuser
``` ```
### Configure InvenTree Options ### Configure InvenTree Options
@ -236,11 +233,11 @@ Now that the database has been created, migrations applied, and you have created
docker-compose up -d docker-compose up -d
``` ```
This command launches the remaining container processes: This command launches the remaining containers:
- `inventree` - InvenTree web server - `inventree-server` - InvenTree web server
- `worker` - Background worker - `inventree-worker` - Background worker
- `nginx` - Nginx reverse proxy - `inventree-nginx` - Nginx reverse proxy
!!! success "Up and Running!" !!! success "Up and Running!"
You should now be able to view the InvenTree login screen at [http://localhost:1337](http://localhost:1337) You should now be able to view the InvenTree login screen at [http://localhost:1337](http://localhost:1337)