Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ artifacts
mk.sh

.claude
_bmad-output
_bmad-output

# Pre-downloaded app sources
2 changes: 1 addition & 1 deletion apps/erpnext/.env
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ W9_HRMS_BRANCH=version-16
W9_ID=erpnext
W9_POWER_PASSWORD=1PrMxExC45LsCT

W9_HTTP_PORT_SET=9001
W9_HTTP_PORT_SET=9019
W9_HTTP_PORT=8080
W9_URL=appname.example.com
W9_LOGIN_USER=Administrator
Expand Down
62 changes: 0 additions & 62 deletions apps/erpnext/Notes.md
Original file line number Diff line number Diff line change
@@ -1,64 +1,2 @@
# ERPNext

## Install

官方非常及时的更新了安装所需的镜像,且提供了灵活多变的 docker compose 文件以供用户使用。

由于过于灵活,导致理解起来有些困难。 实际上 ERPNext 的安装比较简单:

1. 将 example.env 另存为根目录 .env
2. 将 compose.yaml 另存为根目录下 compose.yaml 或 docker-compose.yml,然后略加修改。接下来有两个可选方案:
3. 方案一:使用 compose convert 命令合并多个 compose 为一个完整的 compose 文件(环境变量会替换),然后启动容器
```
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
```
4. 方案二(推荐):启动时引入主 compose 文件以及有选择性的启动 overrides 文件夹下的 docker compose 文件 (多 compose 文件的用法)
```
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
```

5. 主服务 backend 中创建一个 erpnext 项目(此步骤是必须的,但很容易被忽略)
```
W9_URL=8.218.129.87
docker compose exec backend bench new-site youurl --mariadb-root-password yourpassword --admin-password admin123

or

```
参考:https://github1s.com/frappe/frappe_docker/blob/HEAD/docs/site-operations.md

## FAQ

#### 默认管理员账号密码?

username: Administrator
password: admin

#### ERPNext 镜像与 Frappe 镜像有什么区别?

经过研究,ERPNext 是官方推出的新的镜像,感觉未来应该推荐使用它。

实验中发现 ERPNext 不会出现图片乱码问题

#### 究竟如何部署 ERPNext?

从官方源码中发现,安装文档指南(单一服务器)中对安装写得过于繁琐,但实际上只需采用 overrides 中多个 compose 文件即可快速安装。

这是怎么回事呢?通过官方的论坛中研究,发现这是文档更新不及时导致,也就是说overrides中的安装在文档中还没有体现,虽然它更具有效率。


### 安装完成后执行命令,同步hrms资源,解决图片不显示
```
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'
```

#### 与URL有关的变量有那些?

```
echo "ROUTER=custom-one-example" > ~/gitops/custom-one-example.env
echo "SITES=\`custom-one.example.com\`" >> ~/gitops/custom-one-example.env
echo "BASE_SITE=one.example.com" >> ~/gitops/custom-one-example.env
echo "BENCH_NETWORK=erpnext-one" >> ~/gitops/custom-one-example.env
```

https://github.com/frappe/frappe_docker/blob/main/docs/single-server-example.md#create-custom-domain-to-existing-site
2 changes: 1 addition & 1 deletion apps/erpnext/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This is an **[Docker Compose template](https://github.com/Websoft9/docker-library)** powered by [Websoft9](https://www.websoft9.com) based on Docker for ERPNext:


- community: v16, v15, v14
- community: v16


## System Requirements
Expand Down
44 changes: 12 additions & 32 deletions apps/erpnext/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,44 +43,18 @@ services:
image: $W9_REPO:$W9_VERSION
container_name: $W9_ID-create-site
restart: none
env_file:
- .env
volumes:
- apps:/home/frappe/frappe-bench/apps
- env:/home/frappe/frappe-bench/env
- sites:/home/frappe/frappe-bench/sites
- logs:/home/frappe/frappe-bench/logs
- ./src/create-site.sh:/usr/local/bin/create-site.sh
- ./src/hrms:/opt/hrms-src:ro
entrypoint:
- bash
- -c
command:
- >
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"` ]] && \
[[ -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"; if [ ! -d sites/frontend ]; then
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;
else
echo "Site frontend already exists, skip new-site";
fi; if [ ! -d apps/hrms ]; then
bench get-app --branch $W9_HRMS_BRANCH hrms;
fi; bench pip install -e apps/hrms; ls -1 apps > sites/apps.txt; if ! bench --site frontend list-apps | grep -qx hrms; then
bench --site frontend install-app hrms;
else
echo "HRMS already installed on frontend";
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
bench build --app hrms;
else
echo "node not found, skip bench build --app hrms";
fi; if [ ! -f sites/assets/hrms/images/frappe-hr-logo.svg ]; then
echo "ERROR: HRMS asset missing after build: sites/assets/hrms/images/frappe-hr-logo.svg";
exit 1;
fi; bench --site frontend migrate; bench --site frontend clear-cache; bench --site frontend clear-website-cache;
- /usr/local/bin/create-site.sh

mariadb:
image: mariadb:$W9_DB_VERSION
Expand Down Expand Up @@ -112,7 +86,13 @@ services:
env_file:
- .env
command:
- nginx-entrypoint.sh
- bash
- -c
- >
set -e; cd /home/frappe/frappe-bench; if [ -d apps/hrms/hrms/public ]; then
mkdir -p sites/assets/hrms;
cp -a apps/hrms/hrms/public/. sites/assets/hrms/;
fi; exec nginx-entrypoint.sh
environment:
BACKEND: $W9_ID-backend:8000
FRAPPE_SITE_NAME_HEADER: frontend
Expand Down
1 change: 0 additions & 1 deletion apps/erpnext/src/after_up.sh

This file was deleted.

72 changes: 0 additions & 72 deletions apps/erpnext/src/compose.yaml

This file was deleted.

65 changes: 65 additions & 0 deletions apps/erpnext/src/create-site.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/bin/bash
# create-site.sh — one-shot ERPNext + HRMS site initializer.
#
# HRMS is installed from a locally pre-downloaded copy at ./src/hrms/
# (mounted read-only at /opt/hrms-src). No runtime GitHub access needed.
#
# Before first `docker compose up`, place HRMS source code into src/hrms/:
# git clone --depth 1 --branch version-16 https://github.com/frappe/hrms src/hrms
set -e

# ── 1. Wait for infrastructure ────────────────────────────────────────────────
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"

# ── 2. Wait for configurator to write common_site_config.json ─────────────────
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..."
sleep 5
if (( $(date +%s) - start > 120 )); then
echo "ERROR: timed out waiting for common_site_config.json"
exit 1
fi
done
echo "common_site_config.json ready"

# ── 3. Create site with ERPNext (official pattern, idempotent) ────────────────
if [ ! -d sites/frontend ]; then
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
else
echo "Site frontend already exists, skipping"
fi

# ── 4. Copy pre-downloaded HRMS and register into Python env ──────────────────
# Must happen after bench new-site so the Python env is fully initialized.
if [ ! -d apps/hrms ]; then
if [ ! -f /opt/hrms-src/setup.py ] && [ ! -f /opt/hrms-src/pyproject.toml ]; then
echo "ERROR: /opt/hrms-src is empty. Run 'bash src/get-hrms.sh' on the host first."
exit 1
fi
echo "Copying HRMS from local source..."
cp -a /opt/hrms-src apps/hrms
fi
bench pip install -e apps/hrms
ls -1 apps > sites/apps.txt

# ── 5. Install HRMS on site ───────────────────────────────────────────────────
if ! bench --site frontend list-apps | grep -qx hrms; then
bench --site frontend install-app hrms
else
echo "HRMS already installed, skipping"
fi

# ── 6. HRMS static assets ─────────────────────────────────────────────────────
# Keep create-site minimal. HRMS static files are synchronized in frontend
# service startup command before nginx starts.
12 changes: 0 additions & 12 deletions apps/erpnext/src/encrypt.sh

This file was deleted.

40 changes: 0 additions & 40 deletions apps/erpnext/src/example.env

This file was deleted.

4 changes: 0 additions & 4 deletions apps/erpnext/src/filelist

This file was deleted.

1 change: 0 additions & 1 deletion apps/erpnext/src/get_version.sh

This file was deleted.

15 changes: 15 additions & 0 deletions apps/erpnext/src/hrms/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Root editor config file
root = true

# Common settings
[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8

# js indentation settings
[{*.js,*.ts,*.vue,*.css,*.scss,*.html}]
indent_style = tab
indent_size = 4
max_line_length = 99
Loading
Loading