Skip to content

Commit 24d99d6

Browse files
authored
Merge pull request #2096 from Websoft9/dev
Upgrade ERPNext
2 parents 3e97d64 + 205baae commit 24d99d6

1,546 files changed

Lines changed: 526940 additions & 301 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ artifacts
66
mk.sh
77

88
.claude
9-
_bmad-output
9+
_bmad-output
10+
11+
# Pre-downloaded app sources

apps/erpnext/.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ W9_HRMS_BRANCH=version-16
66
W9_ID=erpnext
77
W9_POWER_PASSWORD=1PrMxExC45LsCT
88

9-
W9_HTTP_PORT_SET=9001
9+
W9_HTTP_PORT_SET=9019
1010
W9_HTTP_PORT=8080
1111
W9_URL=appname.example.com
1212
W9_LOGIN_USER=Administrator

apps/erpnext/Notes.md

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,2 @@
11
# ERPNext
22

3-
## Install
4-
5-
官方非常及时的更新了安装所需的镜像,且提供了灵活多变的 docker compose 文件以供用户使用。
6-
7-
由于过于灵活,导致理解起来有些困难。 实际上 ERPNext 的安装比较简单:
8-
9-
1. 将 example.env 另存为根目录 .env
10-
2. 将 compose.yaml 另存为根目录下 compose.yaml 或 docker-compose.yml,然后略加修改。接下来有两个可选方案:
11-
3. 方案一:使用 compose convert 命令合并多个 compose 为一个完整的 compose 文件(环境变量会替换),然后启动容器
12-
```
13-
docker compose -f compose.yaml -f src/overrides/compose.erpnext.yaml -f src/overrides/compose.redis.yaml -f src/overrides/compose.mariadb.yaml convert > docker-compose.yml
14-
```
15-
4. 方案二(推荐):启动时引入主 compose 文件以及有选择性的启动 overrides 文件夹下的 docker compose 文件 (多 compose 文件的用法)
16-
```
17-
docker compose -f docker-compose.yml -f src/overrides/compose.erpnext.yaml -f src/overrides/compose.redis.yaml -f src/overrides/compose.mariadb.yaml up -d
18-
```
19-
20-
5. 主服务 backend 中创建一个 erpnext 项目(此步骤是必须的,但很容易被忽略)
21-
```
22-
W9_URL=8.218.129.87
23-
docker compose exec backend bench new-site youurl --mariadb-root-password yourpassword --admin-password admin123
24-
25-
or
26-
27-
```
28-
参考:https://github1s.com/frappe/frappe_docker/blob/HEAD/docs/site-operations.md
29-
30-
## FAQ
31-
32-
#### 默认管理员账号密码?
33-
34-
username: Administrator
35-
password: admin
36-
37-
#### ERPNext 镜像与 Frappe 镜像有什么区别?
38-
39-
经过研究,ERPNext 是官方推出的新的镜像,感觉未来应该推荐使用它。
40-
41-
实验中发现 ERPNext 不会出现图片乱码问题
42-
43-
#### 究竟如何部署 ERPNext?
44-
45-
从官方源码中发现,安装文档指南(单一服务器)中对安装写得过于繁琐,但实际上只需采用 overrides 中多个 compose 文件即可快速安装。
46-
47-
这是怎么回事呢?通过官方的论坛中研究,发现这是文档更新不及时导致,也就是说overrides中的安装在文档中还没有体现,虽然它更具有效率。
48-
49-
50-
### 安装完成后执行命令,同步hrms资源,解决图片不显示
51-
```
52-
docker compose exec frontend bash -lc 'set -euxo pipefail; cd /home/frappe/frappe-bench; id; ls -ld apps/hrms/hrms/public; mkdir -p sites/assets/hrms; cp -a apps/hrms/hrms/public/. sites/assets/hrms/; ls -lah sites/assets/hrms; ls -lah sites/assets/hrms/images/frappe-hr-logo.svg'
53-
```
54-
55-
#### 与URL有关的变量有那些?
56-
57-
```
58-
echo "ROUTER=custom-one-example" > ~/gitops/custom-one-example.env
59-
echo "SITES=\`custom-one.example.com\`" >> ~/gitops/custom-one-example.env
60-
echo "BASE_SITE=one.example.com" >> ~/gitops/custom-one-example.env
61-
echo "BENCH_NETWORK=erpnext-one" >> ~/gitops/custom-one-example.env
62-
```
63-
64-
https://github.com/frappe/frappe_docker/blob/main/docs/single-server-example.md#create-custom-domain-to-existing-site

apps/erpnext/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
This is an **[Docker Compose template](https://github.com/Websoft9/docker-library)** powered by [Websoft9](https://www.websoft9.com) based on Docker for ERPNext:
44

55

6-
- community: v16, v15, v14
6+
- community: v16
77

88

99
## System Requirements

apps/erpnext/docker-compose.yml

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -43,44 +43,18 @@ services:
4343
image: $W9_REPO:$W9_VERSION
4444
container_name: $W9_ID-create-site
4545
restart: none
46+
env_file:
47+
- .env
4648
volumes:
4749
- apps:/home/frappe/frappe-bench/apps
4850
- env:/home/frappe/frappe-bench/env
4951
- sites:/home/frappe/frappe-bench/sites
5052
- logs:/home/frappe/frappe-bench/logs
53+
- ./src/create-site.sh:/usr/local/bin/create-site.sh
54+
- ./src/hrms:/opt/hrms-src:ro
5155
entrypoint:
5256
- bash
53-
- -c
54-
command:
55-
- >
56-
set -e; wait-for-it -t 120 $W9_ID-mariadb:3306; wait-for-it -t 120 $W9_ID-redis-cache:6379; wait-for-it -t 120 $W9_ID-redis-queue:6379; export start=`date +%s`; until [[ -n `grep -hs ^ sites/common_site_config.json | jq -r ".db_host // empty"` ]] && \
57-
[[ -n `grep -hs ^ sites/common_site_config.json | jq -r ".redis_cache // empty"` ]] && \
58-
[[ -n `grep -hs ^ sites/common_site_config.json | jq -r ".redis_queue // empty"` ]];
59-
do
60-
echo "Waiting for sites/common_site_config.json to be created";
61-
sleep 5;
62-
if (( `date +%s`-start > 120 )); then
63-
echo "could not find sites/common_site_config.json with required keys";
64-
exit 1
65-
fi
66-
done; echo "sites/common_site_config.json found"; if [ ! -d sites/frontend ]; then
67-
bench new-site --mariadb-user-host-login-scope='%' --admin-password=$W9_LOGIN_PASSWORD --db-root-username=root --db-root-password=$W9_LOGIN_PASSWORD --install-app erpnext --set-default frontend;
68-
else
69-
echo "Site frontend already exists, skip new-site";
70-
fi; if [ ! -d apps/hrms ]; then
71-
bench get-app --branch $W9_HRMS_BRANCH hrms;
72-
fi; bench pip install -e apps/hrms; ls -1 apps > sites/apps.txt; if ! bench --site frontend list-apps | grep -qx hrms; then
73-
bench --site frontend install-app hrms;
74-
else
75-
echo "HRMS already installed on frontend";
76-
fi; mkdir -p sites/assets; rm -rf sites/assets/hrms; cp -a /home/frappe/frappe-bench/apps/hrms/hrms/public sites/assets/hrms; if command -v node >/dev/null 2>&1; then
77-
bench build --app hrms;
78-
else
79-
echo "node not found, skip bench build --app hrms";
80-
fi; if [ ! -f sites/assets/hrms/images/frappe-hr-logo.svg ]; then
81-
echo "ERROR: HRMS asset missing after build: sites/assets/hrms/images/frappe-hr-logo.svg";
82-
exit 1;
83-
fi; bench --site frontend migrate; bench --site frontend clear-cache; bench --site frontend clear-website-cache;
57+
- /usr/local/bin/create-site.sh
8458

8559
mariadb:
8660
image: mariadb:$W9_DB_VERSION
@@ -112,7 +86,13 @@ services:
11286
env_file:
11387
- .env
11488
command:
115-
- nginx-entrypoint.sh
89+
- bash
90+
- -c
91+
- >
92+
set -e; cd /home/frappe/frappe-bench; if [ -d apps/hrms/hrms/public ]; then
93+
mkdir -p sites/assets/hrms;
94+
cp -a apps/hrms/hrms/public/. sites/assets/hrms/;
95+
fi; exec nginx-entrypoint.sh
11696
environment:
11797
BACKEND: $W9_ID-backend:8000
11898
FRAPPE_SITE_NAME_HEADER: frontend

apps/erpnext/src/after_up.sh

Lines changed: 0 additions & 1 deletion
This file was deleted.

apps/erpnext/src/compose.yaml

Lines changed: 0 additions & 72 deletions
This file was deleted.

apps/erpnext/src/create-site.sh

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/bin/bash
2+
# create-site.sh — one-shot ERPNext + HRMS site initializer.
3+
#
4+
# HRMS is installed from a locally pre-downloaded copy at ./src/hrms/
5+
# (mounted read-only at /opt/hrms-src). No runtime GitHub access needed.
6+
#
7+
# Before first `docker compose up`, place HRMS source code into src/hrms/:
8+
# git clone --depth 1 --branch version-16 https://github.com/frappe/hrms src/hrms
9+
set -e
10+
11+
# ── 1. Wait for infrastructure ────────────────────────────────────────────────
12+
wait-for-it -t 120 "${W9_ID}-mariadb:3306"
13+
wait-for-it -t 120 "${W9_ID}-redis-cache:6379"
14+
wait-for-it -t 120 "${W9_ID}-redis-queue:6379"
15+
16+
# ── 2. Wait for configurator to write common_site_config.json ─────────────────
17+
export start=$(date +%s)
18+
until [[ -n $(grep -hs ^ sites/common_site_config.json | jq -r ".db_host // empty") ]] && \
19+
[[ -n $(grep -hs ^ sites/common_site_config.json | jq -r ".redis_cache // empty") ]] && \
20+
[[ -n $(grep -hs ^ sites/common_site_config.json | jq -r ".redis_queue // empty") ]]; do
21+
echo "Waiting for sites/common_site_config.json..."
22+
sleep 5
23+
if (( $(date +%s) - start > 120 )); then
24+
echo "ERROR: timed out waiting for common_site_config.json"
25+
exit 1
26+
fi
27+
done
28+
echo "common_site_config.json ready"
29+
30+
# ── 3. Create site with ERPNext (official pattern, idempotent) ────────────────
31+
if [ ! -d sites/frontend ]; then
32+
bench new-site \
33+
--mariadb-user-host-login-scope='%' \
34+
--admin-password="${W9_LOGIN_PASSWORD}" \
35+
--db-root-username=root \
36+
--db-root-password="${W9_LOGIN_PASSWORD}" \
37+
--install-app erpnext \
38+
--set-default frontend
39+
else
40+
echo "Site frontend already exists, skipping"
41+
fi
42+
43+
# ── 4. Copy pre-downloaded HRMS and register into Python env ──────────────────
44+
# Must happen after bench new-site so the Python env is fully initialized.
45+
if [ ! -d apps/hrms ]; then
46+
if [ ! -f /opt/hrms-src/setup.py ] && [ ! -f /opt/hrms-src/pyproject.toml ]; then
47+
echo "ERROR: /opt/hrms-src is empty. Run 'bash src/get-hrms.sh' on the host first."
48+
exit 1
49+
fi
50+
echo "Copying HRMS from local source..."
51+
cp -a /opt/hrms-src apps/hrms
52+
fi
53+
bench pip install -e apps/hrms
54+
ls -1 apps > sites/apps.txt
55+
56+
# ── 5. Install HRMS on site ───────────────────────────────────────────────────
57+
if ! bench --site frontend list-apps | grep -qx hrms; then
58+
bench --site frontend install-app hrms
59+
else
60+
echo "HRMS already installed, skipping"
61+
fi
62+
63+
# ── 6. HRMS static assets ─────────────────────────────────────────────────────
64+
# Keep create-site minimal. HRMS static files are synchronized in frontend
65+
# service startup command before nginx starts.

apps/erpnext/src/encrypt.sh

Lines changed: 0 additions & 12 deletions
This file was deleted.

apps/erpnext/src/example.env

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)