开源库存管理系统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外,还支持mysqlINVENTREE_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 &…...
环境配置与基础教程:保姆级教程:VS Code DevContainer 一键构建可复现的 YOLO 训练开发容器
摘要 你是否还在为YOLO训练环境的搭建而焦头烂额?CUDA版本不匹配、Python依赖冲突、团队协作时“在我机器上能跑”的经典难题——这些问题浪费了无数开发者的宝贵时间。本文将带你通过VS Code DevContainer技术,一键构建完全可复现的YOLO训练开发容器,彻底告别环境配置噩梦…...
用Python+OpenCV给《梦幻西游》写个自动挖图脚本(附完整代码与避坑指南)
用PythonOpenCV实现《梦幻西游》自动挖宝图的全流程实战 最近在技术社区看到不少关于游戏自动化的讨论,尤其是像《梦幻西游》这类经典MMORPG,很多开发者尝试用计算机视觉技术实现自动化操作。作为一个长期关注OpenCV应用的开发者,我花了三周…...
Kohya Trainer 图像生成实战:利用训练好的模型进行高质量创作
Kohya Trainer 图像生成实战:利用训练好的模型进行高质量创作 【免费下载链接】kohya-trainer Adapted from https://note.com/kohya_ss/n/nbf7ce8d80f29 for easier cloning 项目地址: https://gitcode.com/gh_mirrors/ko/kohya-trainer Kohya Trainer 是一…...
跨平台光标同步工具:技术原理、实现与多屏开发效率优化
1. 项目概述:一个为开发者量身定制的光标同步工具 如果你和我一样,经常需要在多台显示器、多个IDE窗口,甚至是远程桌面和本地环境之间来回切换,那么你一定对“找光标”这件事深恶痛绝。尤其是在进行代码对比、调试或者多屏幕协作时…...
基于PSCAD的光伏-火电打捆直流送出系统建模与扰动特性仿真研究
基于PSCAD的光伏-火电打捆直流送出系统建模与扰动特性仿真研究 摘要 随着我国“双碳”目标的深入推进,以光伏为代表的新能源发电装机规模持续快速增长。然而,光伏发电具有间歇性和波动性特征,大规模并网对电力系统的安全稳定运行提出了严峻挑战。将光伏与火电打捆经高压直…...
这下,很多大学老师要睡不着了!
这两年,很多人都在说大学老师“稳定、体面、假期多”,可真把话筒递给高校老师本人,听到的往往不是轻松,而是另一种很闷的疲惫:睡不好,心里总悬着,白天上课,晚上改材料、写本子、赶论…...
【c++面向对象编程】第2篇:类与对象(一):定义第一个类——成员变量与成员函数
目录 一、从一个日常需求开始 二、定义你的第一个类 三、访问修饰符:public、private、protected 举个例子,看看区别: 四、成员变量怎么声明? 五、成员函数:两种实现方式 方式一:类内实现(…...
Oracle诉Google案:API版权与合理使用对软件互操作性的深远影响
1. 一场定义软件未来的世纪诉讼:Oracle诉Google案深度解析2012年5月,科技界和法律界都将目光聚焦在了美国加州北区联邦地方法院。一场被业界称为“世纪诉讼”的官司——Oracle America Inc. 诉 Google Inc. 案——进入了关键的第一阶段庭审。表面上看&am…...
观察使用Token Plan套餐后月度AI调用成本的变化趋势
🚀 告别海外账号与网络限制!稳定直连全球优质大模型,限时半价接入中。 👉 点击领取海量免费额度 观察使用Token Plan套餐后月度AI调用成本的变化趋势 1. 项目背景与成本挑战 作为一个小型技术团队的负责人,我负责维护…...
基于 base-admin 人事管理系统开源项目学习与功能扩展实战笔记
最近跟着课程实战拆解了base-admin 人事管理系统开源项目,这是一款基于 SpringBoot 搭建的企业级后台管理平台,遵循 Apache 2.0 开源协议,非常适合 Java 后端和软件工程入门练手。项目整体采用经典三层架构,Controller、Service、…...
