2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-05-10 01:08:49 +00:00
InvenTree/docs/docs/start/bare_prod.md
Matthias Mair 0bace3f3af
Code structure refactor (#5582)
* moved docker files to /contrib/container

* changed code owners to make more precise

* updated CI to use new subdirs

* added manual trigger for testing

* moved ci files

* moved assets into subdir

* moved deploy template file to contrib

* moved django files to src/backend

* updated paths in scripts etc

* updated reqs path

* fixed version file path

* fixed flake8 path

* fixed path to node ressources

* fixed task paths

* added dep path for node

* removed unused yarn lockfile

* removed unused ci script

* updated internal backend paths for tasks

* updated translation stats path

* fixed source path for coverage

* fixed main commit repo path

* fit in changes from testing

* gather packager improvements (#149)

* Matmair/issue5578 (#143)

* moved docker files to /contrib/container

* changed code owners to make more precise

* updated CI to use new subdirs

* added manual trigger for testing

* moved ci files

* moved assets into subdir

* moved deploy template file to contrib

* moved django files to src/backend

* updated paths in scripts etc

* updated reqs path

* fixed version file path

* fixed flake8 path

* fixed path to node ressources

* fixed task paths

* added dep path for node

* removed unused yarn lockfile

* removed unused ci script

* updated internal backend paths for tasks

* updated translation stats path

* fixed source path for coverage

* fixed main commit repo path

* fix docker path

* use project dir

* move project dir command

* fixed docker paths

* another fix?

* seperate tasks out

* remove tasks

* some debugging

* ci: add .deepsource.toml

* Update .deepsource.toml

* also ignore migrations

* more debugging

* fix path issues

* remove debug script

* fix style

* change locale path

* Fixed paths for requirements

* Added dummy requirements to fool packager

* fixed exec path

* remove deepsource

---------

Co-authored-by: deepsource-io[bot] <42547082+deepsource-io[bot]@users.noreply.github.com>

* Added docs for file structure

* Fixed style errors

* updated deepsource paths

* fix deepsource paths

* fixed reqs

* merge fixes

* move newly added dirs too

* fix reqs files

* another dep fix

* merge upstream/master

* revert removal of tags

* merge upstream

* enabled detection of old config files

* adapt coverage src

* also detect and support old location for plugins.txt

* style fix

* fix ~/init.sh location

* fix requirements path

* fix config to current master

* move new folders

* fix import order

* fix paths for qc_check

* fix docs build

* fix fix path

* set docker project dir

* just use a cd

* set image path?

* set file correct

* fix copy path

* fix tasks dir

* fix init path

* fix copy path

* set prject dir

* fix paths

* remove old prod files

* fix dev env path

* set docker file

* Fix devcontainer docker compose file

* fix login attempt values

* fix init.sh path

* Fix pathing for Docker

* Docker build fix

- Set INVENTREE_BACKEND_DIR separately

* Update init.sh

* Fix path

* Update requirements.txt

* merge

* fix rq merge

* fix docker compose usage

---------

Co-authored-by: deepsource-io[bot] <42547082+deepsource-io[bot]@users.noreply.github.com>
Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
2024-04-03 12:16:59 +11:00

4.1 KiB

title
title
Bare Metal Production Server

Bare Metal Production Server

!!! warning "Installation" Before continuing, ensure that the installation steps have been completed.

The following instructions provide a reasonably performant server, using gunicorn as a webserver, and supervisor as a process manager.

For alternative deployment methods, django apps provide multiple deployment methods - see the [Django documentation]({% include "django.html" %}/howto/deployment/).

There are also numerous online tutorials describing how to deploy a Django application either locally or on an online platform.

Gunicorn

The InvenTree web server is hosted using Gunicorn. Gunicorn is a Python WSGI server which provides a multi-worker server which is well suited to handling multiple simultaneous requests. Gunicorn is a solid choice for a production server which is easy to configure and performs well in a multi-user environment.

Supervisor

Supervisor is a process control system which monitors and controls multiple background processes. It is used in the InvenTree production setup to ensure that the server and background worker processes are always running.

Gunicorn

Gunicorn should have already been installed (within the python virtual environment) as part of the installation procedure.

A simple gunicorn configuration file is also provided. This configuration file can be edited if different server settings are required

Test Gunicorn Server

First, let's confirm that the gunicorn server is operational.

!!! info "Virtual Environment" Don't forget to activate the python virtual environment

cd /home/InvenTree
source ./env/bin/activate

cd src/InvenTree
/home/inventree/env/bin/gunicorn -c gunicorn.conf.py InvenTree.wsgi -b 127.0.0.1:8000

This should start the gunicorn server as a foreground process.

Check that you can access the InvenTree web server in your browser:

Stop Gunicorn Server

Once the gunicorn server is operational, kill the server with Ctrl+c

Supervisor

We will use supervisor as a process monitor, to ensure the web server and background worker processes are automatically started, and restarted if something goes wrong.

Install Supervisor

!!! info "Sudo Actions" Perform sudo actions from a separate shell, as 'inventree' user does not have sudo access

sudo apt-get install supervisor

Configure Supervisor

!!! warning "Configuration Override" If you already have supervisor installed on your system, you will not want to override your existing configuration file. In this case, edit the existing configuration file at /etc/supervisord.conf to integrate the InvenTree processes

Copy the supervisor configuration file:

sudo cp /home/inventree/src/contrib/deploy/supervisord.conf /etc/supervisord.conf

Start Supervisor Daemon

sudo supervisord

Check Server

Check that the InvenTree web server is running.

View Process Status

The process status can be viewed in your web browser.

Production Ready

The InvenTree server (and background task manager) should now be running!

Static and Media Files

In addition to the InvenTree server, you will need a method of delivering static and media files (this is not handled by the InvenTree server in a production environment).

!!! info "Read More" Refer to the Serving Files section for more details

Next Steps

You (or your system administrator) may wish to perform further steps such as placing the InvenTree server behind a reverse-proxy such as caddy, or nginx. As production environment options are many and varied, such tasks are outside the scope of this documentation.

There are many great online tutorials about running django applications in production!

As a starting point, you can refer to the docker guide for a demonstration of running InvenTree behind a Caddy proxy.