开源库存管理系统InvenTree的安装
本文是应网友
shijie880500
要求折腾的;
什么是 InvenTree ?
InvenTree
是一个开源的库存管理系统,提供强大的低级别库存控制和零件跟踪。InvenTree
系统的核心是Python/Django
数据库后端,它提供了一个管理界面(基于web
)和一个REST API
,用于与外部接口和应用程序交互。强大的插件系统为自定义应用程序和扩展提供支持。
前期准备
在群晖上以 Docker 方式安装。因为涉及到多个容器,所以采用了 docker-compose
安装
老苏是按生产环境搭建,因为开发模式只能用 localhost
访问,所需的文件都来自于官方的 production
目录:https://github.com/inventree/InvenTree/tree/master/docker/production
版本选择的是
InvenTree
的最新稳定版本stable
,对应的版本为0.12.8
docker-compose.yml
将下面的内容保存为 docker-compose.yml
文件
version: "3.8"# Docker compose recipe for a production-ready InvenTree setup, with the following containers:
# - PostgreSQL as the database backend
# - gunicorn as the InvenTree web server
# - django-q as the InvenTree background worker process
# - nginx as a reverse proxy
# - redis as the cache manager (optional, disabled by default)# ---------------------
# READ BEFORE STARTING!
# ---------------------# -----------------------------
# Setting environment variables
# -----------------------------
# Shared environment variables should be stored in the env.txt file
# Changes made to this file are reflected across all containers!
#
# IMPORTANT NOTE:
# You should not have to change *anything* within this docker-compose.yml file!
# Instead, make any changes in the env.txt file!# ------------------------
# 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 INVENTREE_TAG variable (in the env.txt file) to "latest"
#
# Alternatively, you could target a specific tagged release version with (for example):
# INVENTREE_TAG=0.7.5
#services:# Database service# Use PostgreSQL as the database backendinventree-db:image: postgres:13container_name: inventree-dbexpose:- ${INVENTREE_DB_PORT:-5432}/tcpenvironment:- PGDATA=/var/lib/postgresql/data/pgdb- POSTGRES_USER=${INVENTREE_DB_USER:?You must provide the 'INVENTREE_DB_USER' variable in the env.txt file}- POSTGRES_PASSWORD=${INVENTREE_DB_PASSWORD:?You must provide the 'INVENTREE_DB_PASSWORD' variable in the env.txt file}- POSTGRES_DB=${INVENTREE_DB_NAME:?You must provide the 'INVENTREE_DB_NAME' variable in the env.txt file}volumes:# Map 'data' volume such that postgres database is stored externally- inventree_data:/var/lib/postgresql/data/restart: unless-stopped# redis acts as database cache manager# only runs under the "redis" profile : https://docs.docker.com/compose/profiles/inventree-cache:image: redis:7.0container_name: inventree-cachedepends_on:- inventree-dbprofiles:- redisenv_file:- .envexpose:- ${INVENTREE_CACHE_PORT:-6379}restart: always# InvenTree web server service# Uses gunicorn as the web serverinventree-server:# If you wish to specify a particular InvenTree version, do so hereimage: inventree/inventree:${INVENTREE_TAG:-stable}container_name: inventree-server# Only change this port if you understand the stack.# If you change this you have to change:# - the proxy settings (on two lines)# - only change the exposed port - eg `1338:8000` if you want to expose the server on port 1338expose:- 8000depends_on:- inventree-dbenv_file:- .envvolumes:# Data volume must map to /home/inventree/data- inventree_data:/home/inventree/datarestart: unless-stopped# Background worker process handles long-running or periodic tasksinventree-worker:# If you wish to specify a particular InvenTree version, do so hereimage: inventree/inventree:${INVENTREE_TAG:-stable}container_name: inventree-workercommand: invoke workerdepends_on:- inventree-serverenv_file:- .envvolumes:# Data volume must map to /home/inventree/data- inventree_data:/home/inventree/datarestart: 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:image: nginxcontainer_name: inventree-proxydepends_on:- inventree-serverenv_file:- .envports:# Default web port is 1337 (can be changed in the env.txt file)- ${INVENTREE_WEB_PORT:-1337}:80volumes:# Provide nginx configuration file to the container# Refer to the provided example file as a starting point- ./nginx.prod.conf:/etc/nginx/conf.d/default.conf:ro# nginx proxy needs access to static and media files- inventree_data:/var/wwwrestart: unless-stoppedvolumes:# Persistent data, stored external to the container(s)inventree_data:driver: localdriver_opts:type: noneo: bind# This directory specified where InvenTree data are stored "outside" the docker containersdevice: ${INVENTREE_EXT_VOLUME:?You must specify the 'INVENTREE_EXT_VOLUME' variable in the env.txt file!}
相比官方的 docker-compose.yml
,老苏做了 2
处修改,但都不是必须的,你可以直接用官方原版的
nginx
的版本,官方用的是nginx:stable
,老苏为了少下载一个镜像,改为了nginx
,也就是nginx:latest
,因为机器上已经有了,这个不是必须要改的;- 给每个容器增加了
container_name
,只是为了看着舒服,同样也不是必须的;
nginx.prod.conf
将下面的内容保存为 r-compose.yml
文件,不需要做任何改动
server {# Listen for connection on (internal) port 80# If you are exposing this server to the internet, you should use HTTPS!# In which case, you should also set up a redirect from HTTP to HTTPS, and listen on port 443# See the Nginx documentation for more detailslisten 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;# Do not touch this unless you have a specific reason - this and the docker-compose need to matchproxy_pass http://inventree-server:8000;}# Redirect any requests for static fileslocation /static/ {alias /var/www/static/;autoindex on;# Caching settingsexpires 30d;add_header Pragma public;add_header Cache-Control "public";}# Redirect any requests for media fileslocation /media/ {alias /var/www/media/;# Media files require user authenticationauth_request /auth;# Content header to force downloadadd_header Content-disposition "attachment";}# Use the 'user' API endpoint for authlocation /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;}}
.env
将下面的内容保存为 .env
文件
# InvenTree environment variables for a postgresql production setup# 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=/volume1/docker/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
INVENTREE_DEBUG=False
INVENTREE_LOG_LEVEL=WARNING# InvenTree admin account details
# Un-comment (and complete) these lines to auto-create an admin acount
INVENTREE_ADMIN_USER=laosu
INVENTREE_ADMIN_PASSWORD=123456
INVENTREE_ADMIN_EMAIL=wbsu2003@gmail.com# Database configuration options
# Note: The example setup is for a PostgreSQL database
INVENTREE_DB_ENGINE=postgresql
INVENTREE_DB_NAME=inventree
INVENTREE_DB_HOST=inventree-db
INVENTREE_DB_PORT=5432# Database credentials - These must be configured before running
# Uncomment the lines below, and change from the default values!
INVENTREE_DB_USER=pguser
INVENTREE_DB_PASSWORD=pgpassword# Redis cache setup (disabled by default)
# Un-comment the following lines to enable Redis cache
# Note that you will also have to run docker-compose with the --profile redis command
# Refer to settings.py for other cache options
#INVENTREE_CACHE_HOST=inventree-cache
#INVENTREE_CACHE_PORT=6379# Options for gunicorn server
INVENTREE_GUNICORN_TIMEOUT=90# Enable custom plugins?
INVENTREE_PLUGINS_ENABLED=False# Run migrations automatically?
INVENTREE_AUTO_UPDATE=False# Image tag that should be used
INVENTREE_TAG=stableCOMPOSE_PROJECT_NAME=inventree-production
参数说明:
- 基本设置
INVENTREE_EXT_VOLUME
:映射为卷的本地目录,需要根据自己的目录进行修改;INVENTREE_WEB_PORT
:访问时的Web
端口,本地不冲突就可以;INVENTREE_DEBUG
:调试模式,默认False
为关闭;INVENTREE_LOG_LEVEL
:日志级别;
【建议】:前两项需要根据自己的情况就行修改;
- 管理员设置
INVENTREE_ADMIN_USER
:管理员账号;INVENTREE_ADMIN_PASSWORD
:管理员密码;INVENTREE_ADMIN_EMAIL
:管理员邮件地址;
【建议】:三项都需要根据自己的情况进行修改;这里如果不设置,就需要用命令行去单独创建管理员;
- 数据库设置
INVENTREE_DB_ENGINE
:数据库类型,除了postgresql
外,还支持mysql
INVENTREE_DB_NAME
:数据库库名;INVENTREE_DB_HOST
:数据库主机;INVENTREE_DB_PORT
:数据库端口;INVENTREE_DB_USER
:数据库用户;INVENTREE_DB_PASSWORD
:数据库密码;
【建议】:只要修改密码就可以的,其他的不建议修改;
Redis
设置INVENTREE_CACHE_HOST
:Redis
主机,默认本行被注释,在数据库初始化之前,一定不要取消注释;INVENTREE_CACHE_PORT
:Redis
端口,默认本行被注释,在数据库初始化之前,一定不要取消注释;
【强烈建议】:不管你后续是否要使用
Redis
,在数据库初始化之前,一定不要取消注释,否则会报错的,切记!切记!
- 其他
INVENTREE_GUNICORN_TIMEOUT
:服务器超时设置;INVENTREE_PLUGINS_ENABLED
:是否启用自定义插件;INVENTREE_TAG
:镜像的tag
的版本,不建议修改;COMPOSE_PROJECT_NAME
:默认就可以;
【建议】:保持默认就可以了;
更多的参数说明,请看官方文档:https://docs.inventree.org/en/stable/start/config/
以上建议是给和老苏一样的小白用户的,高手请忽略
命令行安装
上传文件
文件准备好之后,依次执行下面的命令
# 新建文件夹 inventree 和 子目录
mkdir -p /volume1/docker/inventree/data# 进入 inventree 目录
cd /volume1/docker/inventree# 将 docker-compose.yml 、.env 、 nginx.prod.conf 放入当前目录
现在的目录
初始化
# 初始化数据库
docker-compose run inventree-server invoke update
这行初始化命令执行了以下步骤:
- 确保安装了所需的
python
包 - 创建一个新的(空)数据库
- 执行所需的架构更新以创建所需的数据库表
- 更新翻译文件
- 将所有必需的静态文件收集到可由
nginx
提供服务的目录中
一定不要先注释 .env
中的 redis
设置,否则最后 Running InvenTree database migrations...
时会有错误
redis.exceptions.ConnectionError: Error -2 connecting to inventree-cache:6379. Name or service not known.
正常应该是下面这样的
创建管理员
- 已在
.env
中指定管理员帐户详细信息,可以跳过这一步; - 为了安全起见,请确保在首次运行后从
.env
文件中删除管理员帐户凭据;
# 创建管理员账号
docker-compose run inventree-server invoke superuser
启动 Docker 容器
现在可以开始启动了
# 一键启动(不带 redis)
docker-compose up -d
如果需要 Redis
服务 ,首先修改 .env
中的 redis
设置,取消 INVENTREE_CACHE_HOST
和 INVENTREE_CACHE_PORT
前面的注释
如果你取消了
redis
注释,但是执行的又是不带redis
的一键启动,也是会存在错误的,或导致容器不断重启;
然后再执行下面的启动命令
# 一键启动(带 redis)
docker-compose --profile redis up -d
不出意外的话,我们在 Docker
管理器中应该看到下面这样
inventree-production_inventree-server_run_2a703d49eef5
是初始化数据库的时候生成的,看着不爽的话,可以删掉
运行
在浏览器中输入 http://群晖IP:1337
就能看到登录界面
用我们前面设置的管理员账号、密码登录
主界面默认有部分中文显示,显然翻译程度还不高
不知道初始化时最一行显示的
InvenTree translation coverage: 27%
是不是指的中文翻译;
如果看到下面的提示,只要重启 inventree-server
容器即可
Server Restart Required
A configuration option has been changed which requires a server restart. Contact your system administrator for further information
其他
一些其他可能会用到的命令
# 一键删除
docker-compose down# 将数据库导出为 JSON
docker-compose run inventree-server invoke export-records -f /volume1/docker/inventree/data/data.json# 删除卷
docker volume rm -f inventree_data
参考文档
InvenTree
地址:https://github.com/inventree
InvenTree
地址:https://inventree.org
InvenTree - InvenTree Documentation
地址:https://docs.inventree.org
Docker Production Server - InvenTree Documentation
地址:https://docs.inventree.org/en/stable/start/docker_prod/
相关文章:

开源库存管理系统InvenTree的安装
本文是应网友 shijie880500 要求折腾的; 什么是 InvenTree ? InvenTree 是一个开源的库存管理系统,提供强大的低级别库存控制和零件跟踪。InvenTree 系统的核心是 Python/Django 数据库后端,它提供了一个管理界面(基于…...

[双指针] (二) LeetCode 202.快乐数 和 11.盛最多水的容器
[双指针] (二) LeetCode 202.快乐数 和 11.盛最多水的容器 快乐数 202. 快乐数 题目解析 (1) 判断一个数是不是快乐数 (2) 快乐数的定义:将整数替换为每个位上的和;如果最终结果为1,就是快乐数 (3) 这个数可能变为1,也可能无…...
前端、HTTP协议(重点)
什么是前端 前端是所有跟用户直接打交道的都可以称之为是前端 比如:PC页面、手机页面、平板页面、汽车显示屏、大屏幕展示出来的都是前端内容 能够用肉眼看到的都是前端 为什么要学前端 学了前端以后我们就可以做全栈工程师(会后端、会前端、会DB、会运维等) 咱…...

软件开发项目文档系列之六概要设计:构建可靠系统的蓝图
概要设计是软件开发项目中至关重要的阶段,它为整个系统提供了设计蓝图和技术方向。它的重要性在于明确项目目标、规划系统结构、确定技术选择、识别风险、以及为团队提供共同的视角,确保项目在后续开发阶段按计划进行。概要设计的主要内容包括项目的背景…...

[C++]命名空间等——喵喵要吃C嘎嘎
希望你开心,希望你健康,希望你幸福,希望你点赞! 最后的最后,关注喵,关注喵,关注喵,大大会看到更多有趣的博客哦!!! 喵喵喵,你对我真的…...
安装ora2pg遇到如下问题
通过源码安装ora2pg成功后,查询帮助信息报错 [rootlocalhost bin]# ora2pg --help Cant locate open.pm in INC (you may need to install the open module) (INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/shar…...

x86-32-Linux下栈溢出攻击原理
在x86-32-Linux下构造一个栈溢出攻击 栈缓冲区溢出攻击:向栈上的数组写入超过数组长度的数据导致覆盖到正常数据{栈帧上的返回地址}。 IA-32下C函数调用约定: 调用者将参数从右向左入栈,构造参数call 指令短跳转,会将call指令下一…...

GPS学习(一):在ROS2中将GPS经纬度数据转换为机器人ENU坐标系,在RVIZ中显示坐标轨迹
文章目录 一、GPS模块介绍二、坐标转换转换原理参数解释: 增加回调函数效果演示 本文记录在Ubuntu22.04-Humbel中使用NMEA协议GPS模块的过程,使用国产ROS开发板鲁班猫(LubanCat )进行调试。 一、GPS模块介绍 在淘宝找了款性价比较高的轮趣科技GPS北斗双…...

chatgpt生成文本的底层工作原理是什么?
文章目录 🌟 ChatGPT生成文本的底层工作原理🍊 一、数据预处理🍊 二、模型结构🍊 三、模型训练🍊 四、文本生成🍊 总结 📕我是廖志伟,一名Java开发工程师、Java领域优质创作者、CSDN…...

javaEE -11(10000字HTML入门级教程)
一: HTML HTML 代码是由 “标签” 构成的. 例如: <body>hello</body>标签名 (body) 放到 < > 中大部分标签成对出现. 为开始标签, 为结束标签.少数标签只有开始标签, 称为 “单标签”.开始标签和结束标签之间, 写的是标签的内容. (h…...
LeetCode75——Day21
文章目录 一、题目二、题解 一、题目 1207. Unique Number of Occurrences Given an array of integers arr, return true if the number of occurrences of each value in the array is unique or false otherwise. Example 1: Input: arr [1,2,2,1,1,3] Output: true Ex…...

学习笔记---更进一步的双向链表专题~~
目录 1. 双向链表的结构🦊 2. 实现双向链表🐝 2.1 要实现的目标🎯 2.2 创建初始化🦋 2.2.1 List.h 2.2.2 List.c 2.2.3 test.c 2.2.4 代码测试运行 2.3 尾插打印头插🪼 思路分析 2.3.1 List.h 2.3.2 List.…...
vscode格式化代码, 谷歌风格, 允许短if同行短块同行, tab = 4舒适风格
ctrl ,输入format, 点开C风格设置 在这块内容输入{ BasedOnStyle: Chromium, IndentWidth: 4, ColumnLimit: 200, AllowShortIfStatementsOnASingleLine: true, AllowShortLoopsOnASingleLine: true} C_Cpp: Clang_format_fallback Style 用作回退的预定义样式的名称&#x…...

百度富文本上传图片后样式崩塌
🔥博客主页: 破浪前进 🔖系列专栏: Vue、React、PHP ❤️感谢大家点赞👍收藏⭐评论✍️ 问题描述:上传图片后,图片会变得很大,当点击的时候更是会顶开整个的容器的高跟宽 原因&#…...
autoware.ai中检测模块lidar_detector caffe
lidar_apollo_cnn_seg_detect模块:该模块主要是调用百度apollo的目标分割。 1.需要安装caffe进行实现: caffe安装步骤: git clone https://github.com/BVLC/caffecd caffe && mdkir build && cd buildcmake ..出现报错: CM…...
CentOS安装Ruby环境
安装依赖项 sudo yum install -y perl zlib-devel openssl-devel安装git sudo yum install -y git git config --global http.sslVerify falsecurl取消ssl认证 echo "insecure" >> ~/.curlrc安装rbenv https://github.com/rbenv/rbenv git clone https://…...
力扣第509题 斐波那契数 新手动态规划(推荐参考) c++
题目 509. 斐波那契数 简单 相关标签 递归 记忆化搜索 数学 动态规划 斐波那契数 (通常用 F(n) 表示)形成的序列称为 斐波那契数列 。该数列由 0 和 1 开始,后面的每一项数字都是前面两项数字的和。也就是: F(0) 0&a…...

canvas绘制签名并保存
实现签名的三个关键方法: 1.mousedown:当鼠标按下时开始绘制签名。 2.mousemove:鼠标移动时持续绘制。 3.mouseup:鼠标抬起时结束绘制。 html: <div class"setSign"><canvasref"canvas&q…...

Android渲染流程
目录 缓冲区的不同生命周期代表当前缓冲区的状态: 多个源 ViewRootImpl: Android4.0: Android5.0: Android应用程序调用SurfaceFliger将测量,布局,绘制好的Surface借助GPU渲染显示到屏幕上。 一个Acti…...
牛客-【237题】算法基础精选题单-第二章 递归、分治
第二章 递归、分治 递归NC15173 The Biggest Water ProblemNC22164 更相减损术 递归 NC15173 The Biggest Water Problem 简单递归,直接暴力 #include <math.h> #include <stdio.h> #include <algorithm> #include <cstring> #include &…...

网络编程(Modbus进阶)
思维导图 Modbus RTU(先学一点理论) 概念 Modbus RTU 是工业自动化领域 最广泛应用的串行通信协议,由 Modicon 公司(现施耐德电气)于 1979 年推出。它以 高效率、强健性、易实现的特点成为工业控制系统的通信标准。 包…...

手游刚开服就被攻击怎么办?如何防御DDoS?
开服初期是手游最脆弱的阶段,极易成为DDoS攻击的目标。一旦遭遇攻击,可能导致服务器瘫痪、玩家流失,甚至造成巨大经济损失。本文为开发者提供一套简洁有效的应急与防御方案,帮助快速应对并构建长期防护体系。 一、遭遇攻击的紧急应…...
云原生核心技术 (7/12): K8s 核心概念白话解读(上):Pod 和 Deployment 究竟是什么?
大家好,欢迎来到《云原生核心技术》系列的第七篇! 在上一篇,我们成功地使用 Minikube 或 kind 在自己的电脑上搭建起了一个迷你但功能完备的 Kubernetes 集群。现在,我们就像一个拥有了一块崭新数字土地的农场主,是时…...

突破不可导策略的训练难题:零阶优化与强化学习的深度嵌合
强化学习(Reinforcement Learning, RL)是工业领域智能控制的重要方法。它的基本原理是将最优控制问题建模为马尔可夫决策过程,然后使用强化学习的Actor-Critic机制(中文译作“知行互动”机制),逐步迭代求解…...

为什么需要建设工程项目管理?工程项目管理有哪些亮点功能?
在建筑行业,项目管理的重要性不言而喻。随着工程规模的扩大、技术复杂度的提升,传统的管理模式已经难以满足现代工程的需求。过去,许多企业依赖手工记录、口头沟通和分散的信息管理,导致效率低下、成本失控、风险频发。例如&#…...

【机器视觉】单目测距——运动结构恢复
ps:图是随便找的,为了凑个封面 前言 在前面对光流法进行进一步改进,希望将2D光流推广至3D场景流时,发现2D转3D过程中存在尺度歧义问题,需要补全摄像头拍摄图像中缺失的深度信息,否则解空间不收敛…...

2.Vue编写一个app
1.src中重要的组成 1.1main.ts // 引入createApp用于创建应用 import { createApp } from "vue"; // 引用App根组件 import App from ./App.vue;createApp(App).mount(#app)1.2 App.vue 其中要写三种标签 <template> <!--html--> </template>…...
python如何将word的doc另存为docx
将 DOCX 文件另存为 DOCX 格式(Python 实现) 在 Python 中,你可以使用 python-docx 库来操作 Word 文档。不过需要注意的是,.doc 是旧的 Word 格式,而 .docx 是新的基于 XML 的格式。python-docx 只能处理 .docx 格式…...
sqlserver 根据指定字符 解析拼接字符串
DECLARE LotNo NVARCHAR(50)A,B,C DECLARE xml XML ( SELECT <x> REPLACE(LotNo, ,, </x><x>) </x> ) DECLARE ErrorCode NVARCHAR(50) -- 提取 XML 中的值 SELECT value x.value(., VARCHAR(MAX))…...

Redis数据倾斜问题解决
Redis 数据倾斜问题解析与解决方案 什么是 Redis 数据倾斜 Redis 数据倾斜指的是在 Redis 集群中,部分节点存储的数据量或访问量远高于其他节点,导致这些节点负载过高,影响整体性能。 数据倾斜的主要表现 部分节点内存使用率远高于其他节…...