Skip to content

Commit

Permalink
add frappe
Browse files Browse the repository at this point in the history
  • Loading branch information
chendelin1982 authored Mar 1, 2024
1 parent 0926bcd commit d0a5768
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 254 deletions.
20 changes: 15 additions & 5 deletions apps/frappe/.env
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
W9_REPO=frappe/erpnext-worker
# Support ERPNext version: v13,v14
W9_VERSION=v14
W9_REPO=frappe/bench
W9_VERSION=latest
W9_DIST=community

W9_POWER_PASSWORD=tfhdjX1vHiwGAi

#### -- Not allowed to edit below environments when recreate app based on existing data -- ####
W9_ID=erpnext
W9_ID=frappe
W9_HTTP_PORT_SET=9001
W9_HTTP_PORT=8080
W9_HTTP_PORT=8000
W9_URL=appname.example.com

W9_LOGIN_USER=Administrator
W9_LOGIN_PASSWORD=$W9_POWER_PASSWORD

W9_DB_EXPOSE="mariadb"
W9_NETWORK=websoft9
#### ----------------------------------------------------------------------------------------- ####

# envrionment from: https://github.com/frappe/frappe_docker/blob/main/example.env

DB_HOST=$W9_ID-mariadb
DB_PORT=3303
DB_PASSWORD=$W9_POWER_PASSWORD

REDIS_CACHE=$W9_ID-redis
REDIS_QUEUE=$W9_ID-redis
62 changes: 4 additions & 58 deletions apps/frappe/Notes.md
Original file line number Diff line number Diff line change
@@ -1,59 +1,5 @@
# ERPNext
# Frappe

## 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中的安装在文档中还没有体现,虽然它更具有效率。


#### 与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
- [Install requirement](https://github.com/frappe/bench/blob/develop/docs/installation.md#1-install-prerequisites)
- Create Frappe by bench
- What depends need? redis, db?
26 changes: 0 additions & 26 deletions apps/frappe/README.md

This file was deleted.

189 changes: 26 additions & 163 deletions apps/frappe/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,185 +1,48 @@
# old image: https://hub.docker.com/r/frappe/erpnext-worker/tags
# new image: https://hub.docker.com/r/frappe/erpnext/tags
# docs: https://github.com/frappe/frappe_docker/blob/main/pwd.yml

version: "3.8"
# image: https://hub.docker.com/r/frappe/bench
# docs: https://github.com/frappe/bench#installation

services:
backend:
image: $W9_REPO:$W9_VERSION
container_name: $W9_ID-backend
deploy:
restart_policy:
condition: on-failure
volumes:
- sites:/home/frappe/frappe-bench/sites
- assets:/home/frappe/frappe-bench/sites/assets

configurator:
image: $W9_REPO:$W9_VERSION
container_name: $W9_ID-configurator
command:
- configure.py
environment:
DB_HOST: $W9_ID-mariadb
DB_PORT: "3306"
REDIS_CACHE: redis:6379/0
REDIS_QUEUE: redis:6379/1
REDIS_SOCKETIO: redis:6379/2
SOCKETIO_PORT: "9000"
volumes:
- sites:/home/frappe/frappe-bench/sites

create-site:
frappe:
image: $W9_REPO:$W9_VERSION
container_name: $W9_ID-create-site
deploy:
restart_policy:
condition: on-failure
volumes:
- sites:/home/frappe/frappe-bench/sites
- assets:/home/frappe/frappe-bench/sites/assets
entrypoint:
- bash
- -c
command:
- >
wait-for-it -t 20 mariadb:3306;
wait-for-it -t 20 redis:6379;
export start=`date +%s`;
until [[ -n `grep -hs ^ common_site_config.json | jq -r ".db_host // empty"` ]] && \
[[ -n `grep -hs ^ common_site_config.json | jq -r ".redis_cache // empty"` ]] && \
[[ -n `grep -hs ^ common_site_config.json | jq -r ".redis_queue // empty"` ]];
do
echo "Waiting for common_site_config.json to be created";
sleep 5;
if (( `date +%s`-start > 20 )); then
echo "could not find common_site_config.json with required keys";
exit 1
fi
done;
echo "common_site_config.json found";
bench new-site frontend --admin-password=$W9_LOGIN_PASSWORD --db-root-password=$W9_LOGIN_PASSWORD --install-app erpnext;
mariadb:
image: mariadb:10.6
container_name: $W9_ID-mariadb
healthcheck:
test: mysqladmin ping -h localhost --password=$W9_POWER_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: $W9_POWER_PASSWORD
volumes:
- db-data:/var/lib/mysql

frontend:
image: frappe/erpnext-nginx:$W9_VERSION
container_name: $W9_ID
deploy:
restart_policy:
condition: on-failure
environment:
BACKEND: backend:8000
FRAPPE_SITE_NAME_HEADER: frontend
SOCKETIO: websocket:9000
UPSTREAM_REAL_IP_ADDRESS: 127.0.0.1
UPSTREAM_REAL_IP_HEADER: X-Forwarded-For
UPSTREAM_REAL_IP_RECURSIVE: "off"
volumes:
- sites:/usr/share/nginx/html/sites
- assets:/usr/share/nginx/html/assets
restart: unless-stopped
tty: true
ports:
- $W9_HTTP_PORT_SET:8080
- $W9_HTTP_PORT_SET:8000
env_file: .env
depends_on:
- mariadb
- redis

queue-default:
image: $W9_REPO:$W9_VERSION
container_name: $W9_ID-queue-default
deploy:
restart_policy:
condition: on-failure
command:
- bench
- worker
- --queue
- default
volumes:
- sites:/home/frappe/frappe-bench/sites

queue-long:
image: $W9_REPO:$W9_VERSION
container_name: $W9_ID-queue-long
deploy:
restart_policy:
condition: on-failure
command:
- bench
- worker
- --queue
- long
volumes:
- sites:/home/frappe/frappe-bench/sites

queue-short:
image: $W9_REPO:$W9_VERSION
container_name: $W9_ID-queue-short
deploy:
restart_policy:
condition: on-failure
command:
- bench
- worker
- --queue
- short
mariadb:
image: mariadb:10.4
container_name: $W9_ID-mariadb
restart: unless-stopped
command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --innodb_log_buffer_size=30M
volumes:
- sites:/home/frappe/frappe-bench/sites

- mariadb:/var/lib/mysql
environment:
MYSQL_DATABASE: $W9_ID
MYSQL_USER: frappe
MYSQL_PASSWORD: $W9_POWER_PASSWORD
MYSQL_ROOT_PASSWORD: $W9_POWER_PASSWORD

redis:
image: redis:6.2-alpine
container_name: $W9_ID-redis
deploy:
restart_policy:
condition: on-failure
volumes:
- redis-data:/data

scheduler:
image: $W9_REPO:$W9_VERSION
container_name: $W9_ID-scheduler
deploy:
restart_policy:
condition: on-failure
command:
- bench
- schedule
volumes:
- sites:/home/frappe/frappe-bench/sites

websocket:
image: frappe/frappe-socketio:$W9_VERSION
container_name: $W9_ID-websocket
deploy:
restart_policy:
condition: on-failure
volumes:
- sites:/home/frappe/frappe-bench/sites
- redis:/data

volumes:
assets:
db-data:
redis-data:
sites:

mariadb:
redis:

networks:
default:
name: $W9_NETWORK
external: true
external: true
4 changes: 2 additions & 2 deletions apps/frappe/variables.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "erpnext",
"trademark": "ERPNext",
"name": "frappe",
"trademark": "Frappe",
"release": true,
"fork_url": "https://github.com/frappe/frappe_docker.git",
"edition": [
Expand Down

0 comments on commit d0a5768

Please sign in to comment.