往常節(jié)假日,都是呆在家里看別人堵,這回老蘇也出門湊了個熱鬧,28
號早上 7
點半出的門
2
點半往回走的
一天啥也沒干,就開了 7
個小時的車去舅舅家蹭了頓飯。還別說,那個田園雞味道是真不錯。
車很久沒開了,但這回起碼兩個月不用遛了。
本文是應(yīng)網(wǎng)友
瀟雨
的要求折騰的。
什么是 ERPNext
?
ERPNext
是一種免費的、開源的企業(yè)資源規(guī)劃(ERP
)軟件,它提供了一套完整的企業(yè)解決方案,包括會計、采購、銷售、庫存、制造、CRM
等功能。ERPNext
旨在為中小型企業(yè)提供一種簡單、易用、靈活的ERP
系統(tǒng),以幫助企業(yè)管理業(yè)務(wù)流程、優(yōu)化運營效率、提高生產(chǎn)力和盈利能力。ERPNext
建立在Frappe
框架之上,這是一個使用Python
和JavaScript
構(gòu)建的全棧web
應(yīng)用程序框架。
前期準(zhǔn)備
在網(wǎng)友提出要求之前,老蘇也曾經(jīng)嘗試過安裝 ERPNext
,但都以失敗告終。
首先嘗試了英文版,但由于涉及多個容器,可能有些地方改漏了、改錯了,導(dǎo)致出現(xiàn)了錯誤,因為工作原因,也沒有太多的時間去深入研究。
之后又嘗試了中文版,這是一個All in one
的版本,安裝相對簡單。但遺憾的是,老蘇一直遇到數(shù)據(jù)庫出錯的問題。由于老蘇的機器內(nèi)存較小,初步懷疑這可能是導(dǎo)致問題的原因。此外,由于容器內(nèi)反復(fù)啟動,導(dǎo)致機器的 CPU
占用率也急劇上升,最終只能放棄了。
docker-compose.yml
這次老蘇犧牲了幾個晚上,認真把 docker-compose.yml
好好整理了一下??。如果你不知道什么含義,不建議你直接改這個文件,老蘇已經(jīng)把需要修改的內(nèi)容,單獨拎了出來放在了env.txt
中
docker-compose.yml
是基于官網(wǎng) https://github.com/frappe/frappe_docker/blob/main/pwd.yml 修改
version: "3"
services:
backend:
image: frappe/erpnext:${APP_VERSION}
container_name: ${APP_NAME}-backend
deploy:
restart_policy:
condition: on-failure
volumes:
- sites:/home/frappe/frappe-bench/sites
- logs:/home/frappe/frappe-bench/logs
configurator:
image: frappe/erpnext:${APP_VERSION}
container_name: ${APP_NAME}-configurator
deploy:
restart_policy:
condition: none
entrypoint:
- bash
- -c
depends_on:
- db
command:
- >
ls -1 apps > sites/apps.txt;
bench set-config -g db_host $$DB_HOST;
bench set-config -gp db_port $$DB_PORT;
bench set-config -g redis_cache "redis://$$REDIS_CACHE";
bench set-config -g redis_queue "redis://$$REDIS_QUEUE";
bench set-config -g redis_socketio "redis://$$REDIS_SOCKETIO";
bench set-config -gp socketio_port $$SOCKETIO_PORT;
environment:
DB_HOST: db
DB_PORT: "3306"
REDIS_CACHE: redis-cache:6379
REDIS_QUEUE: redis-queue:6379
REDIS_SOCKETIO: redis-socketio:6379
SOCKETIO_PORT: "9000"
volumes:
- sites:/home/frappe/frappe-bench/sites
- logs:/home/frappe/frappe-bench/logs
create-site:
image: frappe/erpnext:${APP_VERSION}
container_name: ${APP_NAME}-create-site
depends_on:
- configurator
deploy:
restart_policy:
condition: none
volumes:
- sites:/home/frappe/frappe-bench/sites
- logs:/home/frappe/frappe-bench/logs
entrypoint:
- bash
- -c
command:
- >
wait-for-it -t 240 db:3306;
wait-for-it -t 120 redis-cache:6379;
wait-for-it -t 120 redis-queue:6379;
wait-for-it -t 120 redis-socketio:6379;
export start=`date +%s`;
until [[ -n `grep -hs ^ sites/common_site_config.json | jq -r ".db_host // empty"` ]] && \
[[ -n `grep -hs ^ sites/common_site_config.json | jq -r ".redis_cache // empty"` ]] && \
[[ -n `grep -hs ^ sites/common_site_config.json | jq -r ".redis_queue // empty"` ]];
do
echo "Waiting for sites/common_site_config.json to be created";
sleep 5;
if (( `date +%s`-start > 120 )); then
echo "could not find sites/common_site_config.json with required keys";
exit 1
fi
done;
echo "sites/common_site_config.json found";
bench new-site frontend --no-mariadb-socket --admin-password=${APP_PASSWORD} --db-root-password=${DB_ROOT_PASSWORD} --install-app erpnext --set-default;
db:
image: mariadb:10.6
container_name: ${APP_NAME}-db
healthcheck:
test: mysqladmin ping -h localhost --password=${DB_PASSWORD}
interval: 1s
retries: 15
deploy:
restart_policy:
condition: on-failure
command:
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_unicode_ci
- --skip-character-set-client-handshake
- --skip-innodb-read-only-compressed # Temporary fix for MariaDB 10.6
environment:
MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
volumes:
- ./data:/var/lib/mysql
#ports:
# - "${DB_PORT}:3306"
frontend:
image: frappe/erpnext:${APP_VERSION}
container_name: ${APP_NAME}-frontend
deploy:
restart_policy:
condition: on-failure
command:
- nginx-entrypoint.sh
environment:
BACKEND: backend:8000
FRAPPE_SITE_NAME_HEADER: frontend
SOCKETIO: websocket:9000
UPSTREAM_REAL_IP_ADDRESS: ${APP_HTTP_IP}
UPSTREAM_REAL_IP_HEADER: X-Forwarded-For
UPSTREAM_REAL_IP_RECURSIVE: "off"
PROXY_READ_TIMOUT: 120
CLIENT_MAX_BODY_SIZE: 50m
volumes:
- sites:/home/frappe/frappe-bench/sites
- logs:/home/frappe/frappe-bench/logs
ports:
- "${APP_HTTP_PORT}:8080"
queue-default:
image: frappe/erpnext:${APP_VERSION}
container_name: ${APP_NAME}-queue-default
deploy:
restart_policy:
condition: on-failure
command:
- bench
- worker
- --queue
- default
volumes:
- sites:/home/frappe/frappe-bench/sites
- logs:/home/frappe/frappe-bench/logs
queue-long:
image: frappe/erpnext:${APP_VERSION}
container_name: ${APP_NAME}-queue-long
deploy:
restart_policy:
condition: on-failure
command:
- bench
- worker
- --queue
- long
volumes:
- sites:/home/frappe/frappe-bench/sites
- logs:/home/frappe/frappe-bench/logs
queue-short:
image: frappe/erpnext:${APP_VERSION}
container_name: ${APP_NAME}-queue-short
deploy:
restart_policy:
condition: on-failure
command:
- bench
- worker
- --queue
- short
volumes:
- sites:/home/frappe/frappe-bench/sites
- logs:/home/frappe/frappe-bench/logs
redis-queue:
image: redis:6.2-alpine
container_name: ${APP_NAME}-redis-queue
deploy:
restart_policy:
condition: on-failure
volumes:
- ./redis-queue-data:/data
redis-cache:
image: redis:6.2-alpine
container_name: ${APP_NAME}-redis-cache
deploy:
restart_policy:
condition: on-failure
volumes:
- ./redis-cache-data:/data
redis-socketio:
image: redis:6.2-alpine
container_name: ${APP_NAME}-redis-socketio
deploy:
restart_policy:
condition: on-failure
volumes:
- ./redis-socketio-data:/data
scheduler:
image: frappe/erpnext:${APP_VERSION}
container_name: ${APP_NAME}-scheduler
deploy:
restart_policy:
condition: on-failure
command:
- bench
- schedule
volumes:
- sites:/home/frappe/frappe-bench/sites
- logs:/home/frappe/frappe-bench/logs
websocket:
image: frappe/erpnext:${APP_VERSION}
container_name: ${APP_NAME}-websocket
deploy:
restart_policy:
condition: on-failure
command:
- node
- /home/frappe/frappe-bench/apps/frappe/socketio.js
volumes:
- sites:/home/frappe/frappe-bench/sites
- logs:/home/frappe/frappe-bench/logs
volumes:
logs:
sites:
env.txt
下面是 env.txt
的內(nèi)容,之所以沒用 .env
是為了方便在 File Station
中方便修改,但是帶來的不方便之處是啟動時需要指定 --env-file
,當(dāng)然在 docker-compose.yml
中指定也是可以的
# ERPNext config
APP_NAME=erp
APP_VERSION=v14.23.0
APP_HTTP_IP=192.168.0.197
APP_HTTP_PORT=6380
APP_PASSWORD=admin
# MariaDB config
DB_HOST=db
DB_PASSWORD=twj9nwyoutRei9C4VV
DB_ROOT_PASSWORD=4aixKdghP3j56hPB8k
DB_PORT=3336
-
APP_NAME
: 主要影響生成的容器名稱的前綴
-
APP_VERSION
:ERPNext
的版本, 老蘇測試過v14.22.3
和v14.23.0
,其他版本沒試過; -
APP_HTTP_IP
:主機IP
,要根據(jù)你自己的群暉主機IP
修改; -
APP_HTTP_PORT
:這是訪問ERPNext
服務(wù)的的本地端口,不沖突就行; -
APP_PASSWORD
:管理員密碼,建議登錄成功之后再改; -
DB_HOST
:數(shù)據(jù)庫主機,不要改; -
DB_PASSWORD
:數(shù)據(jù)庫密碼,建議改; -
DB_ROOT_PASSWORD
:數(shù)據(jù)庫管理員密碼,建議改; -
DB_PORT
:數(shù)據(jù)庫本地端口,不沖突就行,默認老蘇在docker-compose.yml
中已經(jīng)注釋掉了端口;
上面兩個文件,老蘇放在了 https://github.com/wbsu2003/synology/tree/main/ERPNext
安裝
采用 docker-compose
方式運行
# 新建文件夾 erpnext 和 子目錄
mkdir -p /volume2/docker/erpnext/{data,redis-cache-data,redis-queue-data,redis-socketio-data}
# 進入 erpnext 目錄
cd /volume2/docker/erpnext
# 將 docker-compose.yml 和 env.txt 兩個文件放入當(dāng)前目錄
# 一鍵運行
docker-compose --env-file env.txt up -d
如果一鍵啟動總是超時,可以加個 timeout
參數(shù)
# 超時設(shè)置
docker-compose --env-file env.txt up -d --timeout 120
運行
如果你沒有修改 APP_HTTP_PORT
的值,你可以在瀏覽器中打開 http://群暉IP:6380
來訪問 ERPNext
.
第一次啟動的過程是比較長的,因為腳本中使用了 wait-for-it
,好幾處都是 -t 120
,老蘇甚至把數(shù)據(jù)庫的改為了 wait-for-it -t 240 db:3306;
,如果能看到登錄界面,說明安裝成功了
- 默認的賬號是
Administrator
,密碼就是前面設(shè)置的APP_PASSWORD
的值,如果你沒改的話,那就是admin
軟件啟動后,正常情況下,erp-configurator
和 erp-create-site
會停掉,因為它們已經(jīng)完成了自己的使命
但如果出現(xiàn)??的錯誤
在老蘇的機器上還是會有一定的幾率發(fā)生,不要慌,我們還有補救措施,請往下看
則還需要執(zhí)行一次下面的命令
參考文檔:
- https://github.com/frappe/frappe_docker/blob/main/docs/site-operations.md
- https://github.com/frappe/frappe_docker/issues/711
# 設(shè)置新站點
docker-compose --env-file env.txt exec backend bench new-site <site-name> --no-mariadb-socket --admin-password=<管理員密碼> --db-root-password=<數(shù)據(jù)庫root賬戶的密碼> --install-app erpnext --set-default
# 示例
docker-compose --env-file env.txt exec backend bench new-site frontend --no-mariadb-socket --admin-password=admin --db-root-password=4aixKdghP3j56hPB8k --install-app erpnext --set-default
其中:
-
<site-name>
對應(yīng)于docker-compose.yml
中前端的service name
的名稱frontend
,這個在nginx
的設(shè)置中也用到了; -
<管理員密碼>
對應(yīng)前面env.txt
中的APP_PASSWORD
的值; -
<數(shù)據(jù)庫root賬戶的密碼>
對應(yīng)前面env.txt
中的DB_ROOT_PASSWORD
的值;
之所以會出現(xiàn)這樣的情況,應(yīng)該還是容器編排的啟動順序上有問題,這些命令按道理在 erp-create-site
容器中應(yīng)該是要被執(zhí)行的
之后,如果容器停止了,再啟動也是需要時間的,你太快打開網(wǎng)址,會看到下面這樣的界面
登錄成功后,第一次還需要設(shè)置
語言有時候能彈出下拉,但是有時候又不行,不過可以直接輸入,現(xiàn)在已經(jīng)支持 簡體中文
了
國家支持下拉,但可能輸入更快
設(shè)置用戶
設(shè)置公司
設(shè)置組織
設(shè)置完成
現(xiàn)在可以開始使用了
至于反代,老蘇試過 npm
,正常設(shè)置就可以,無論你的域名有沒有端口,都是可以正常訪問的。
參考文檔
ERPNext: Free and Open Source Cloud ERP Software
地址:https://erpnext.com/
frappe/erpnext: Free and Open Source Enterprise Resource Planning (ERP)
地址:https://github.com/frappe/erpnext文章來源:http://www.zghlxwxcb.cn/news/detail-447318.html
frappe/frappe_docker: Docker images for production and development setups of the Frappe framework and ERPNext
地址:https://github.com/frappe/frappe_docker
Home
地址:https://docs.erpnext.com/文章來源地址http://www.zghlxwxcb.cn/news/detail-447318.html
到了這里,關(guān)于開源企業(yè)資源規(guī)劃ERPNext的安裝的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!