From 6d2e588d51e9ad1275fd8fc7c33be2156875e99e Mon Sep 17 00:00:00 2001 From: chendelin1982 <27513732@qq.com> Date: Mon, 30 May 2022 18:19:23 +0800 Subject: [PATCH] update v13.30.0 --- .env | 58 +++++++----- Notes.md | 32 ++++++- compose.erpnext.yaml | 24 +++++ compose.mariadb.yaml | 27 ++++++ compose.noproxy.yaml | 4 + compose.redis.yaml | 16 ++++ docker-compose.yml | 206 ++++++++++++------------------------------- 7 files changed, 191 insertions(+), 176 deletions(-) create mode 100644 compose.erpnext.yaml create mode 100644 compose.mariadb.yaml create mode 100644 compose.noproxy.yaml create mode 100644 compose.redis.yaml diff --git a/.env b/.env index ffede66..ee8d44a 100644 --- a/.env +++ b/.env @@ -1,26 +1,40 @@ -# Add this file -# Initial db root password is 123456 -# Initial login username: Administrator and login password: admin -# APP_PORT can't set 9001, otherwise container erpnext-python will be error +# Reference: https://github.com/frappe/frappe_docker/blob/main/docs/images-and-compose-files.md -DB_MRAIADB_USER=root -DB_MARIADB_PASSWORD=123456 -DB_MARIADB_HOST=mariadb -DB_MARIADB_PORT=3306 -DB_MARIADB_VERSION=10.6 +FRAPPE_VERSION=v13.30.0 -DB_REDIS_VERSION=latest +# Only with ERPNext override +ERPNEXT_VERSION=v13.31.1 -APP_VERSION=v12 -APP_PORT=8000 -APP_USER=Administrator -APP_PASSWORD=admin -APP_SITE_URL=erp.example.com -APP_SITE_NAME=`erp.example.com` -APP_INSTALL_APPS=erpnext -APP_NAME=erpnext -VOLUMES_PATH_PREFIX=./volumes +DB_PASSWORD=123 -LETSENCRYPT_EMAIL=email@example.com -SKIP_NGINX_TEMPLATE_GENERATION=0 -WORKER_CLASS=gthread +# Only if you use external database +DB_HOST= +DB_PORT= + +# Only if you use external Redis +REDIS_CACHE= +REDIS_QUEUE= +REDIS_SOCKETIO= + +# Only with HTTPS override +LETSENCRYPT_EMAIL=mail@example.com + +# These environment variables are not required. + +# Default value is `$$host` which resolves site by host. For example, if your host is `example.com`, +# site's name should be `example.com`, or if host is `127.0.0.1` (local debugging), it should be `127.0.0.1`. +# This variable allows to override described behavior. Let's say you create site named `mysite` +# and do want to access it by `127.0.0.1` host. Than you would set this variable to `mysite`. +FRAPPE_SITE_NAME_HEADER= + +# Default value is `127.0.0.1`. Set IP address as our trusted upstream address. +UPSTREAM_REAL_IP_ADDRESS= + +# Default value is `X-Forwarded-For`. Set request header field whose value will be used to replace the client address +UPSTREAM_REAL_IP_HEADER= + +# Allowed values are on|off. Default value is `off`. If recursive search is disabled, +# the original client address that matches one of the trusted addresses +# is replaced by the last address sent in the request header field defined by the real_ip_header directive. +# If recursive search is enabled, the original client address that matches one of the trusted addresses is replaced by the last non-trusted address sent in the request header field. +UPSTREAM_REAL_IP_RECURSIVE= diff --git a/Notes.md b/Notes.md index f8ed8ae..0948502 100644 --- a/Notes.md +++ b/Notes.md @@ -1,6 +1,30 @@ -## About +# ERPNext -This repository is forked from ONLYOFFICE/Docker-CommunityServer, we have the following modifications are provided +## About Install -* replace README.md -* add README-zh.md, CHANGELOG.md, Note.md, License.md, docker-compose.yml,.env, src, .github folder +官方非常及时的更新了安装所需的镜像,且提供了灵活多变的 docker compose 文件以供用户使用。 + +由于过于灵活,导致理解起来有些困难。 实际上 ERPNext 的安装比较简单: + +1. 将 example.env 另存成 .env +2. 启动时引入主 compose 文件以及有选择性的启动 overrides 文件夹下的 docker compose 文件 (多 compose 文件的用法) +``` +docker compose -f compose.yaml -f ./overrides/compose.mariadb.yaml -f ... up -d +``` + +3. 主服务 backend 中创建一个 erpnext 项目(此步骤很容易被忽略) +``` +docker-compose exec backend bench new-site --mariadb-root-password --admin-password +``` +参考:https://github1s.com/frappe/frappe_docker/blob/HEAD/docs/site-operations.md + +## FAQ + +#### 默认管理员账号密码? + +username: Administrator +password: admin + +#### ERPNext 镜像与 Frappe 镜像有什么区别? + +有待研究,实验中发现 ERPNext 不会出现图片乱码问题 \ No newline at end of file diff --git a/compose.erpnext.yaml b/compose.erpnext.yaml new file mode 100644 index 0000000..36f10ad --- /dev/null +++ b/compose.erpnext.yaml @@ -0,0 +1,24 @@ +x-erpnext-backend-image: &erpnext_backend_image + image: frappe/erpnext-worker:${ERPNEXT_VERSION:?No ERPNext version set} + +services: + configurator: + <<: *erpnext_backend_image + + backend: + <<: *erpnext_backend_image + + frontend: + image: frappe/erpnext-nginx:${ERPNEXT_VERSION} + + queue-short: + <<: *erpnext_backend_image + + queue-default: + <<: *erpnext_backend_image + + queue-long: + <<: *erpnext_backend_image + + scheduler: + <<: *erpnext_backend_image diff --git a/compose.mariadb.yaml b/compose.mariadb.yaml new file mode 100644 index 0000000..cd719b6 --- /dev/null +++ b/compose.mariadb.yaml @@ -0,0 +1,27 @@ +services: + configurator: + environment: + DB_HOST: db + DB_PORT: 3306 + depends_on: + db: + condition: service_healthy + + db: + image: mariadb:10.6 + healthcheck: + test: mysqladmin ping -h localhost --password=${DB_PASSWORD} + interval: 1s + retries: 15 + 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_PASSWORD:?No db password set} + volumes: + - db-data:/var/lib/mysql + +volumes: + db-data: diff --git a/compose.noproxy.yaml b/compose.noproxy.yaml new file mode 100644 index 0000000..5c4f83c --- /dev/null +++ b/compose.noproxy.yaml @@ -0,0 +1,4 @@ +services: + frontend: + ports: + - 8080:8080 diff --git a/compose.redis.yaml b/compose.redis.yaml new file mode 100644 index 0000000..5bd3a0a --- /dev/null +++ b/compose.redis.yaml @@ -0,0 +1,16 @@ +services: + configurator: + environment: + REDIS_CACHE: redis:6379/0 + REDIS_QUEUE: redis:6379/1 + REDIS_SOCKETIO: redis:6379/2 + depends_on: + - redis + + redis: + image: redis:6.2-alpine + volumes: + - redis-data:/data + +volumes: + redis-data: diff --git a/docker-compose.yml b/docker-compose.yml index 4730152..7ac9d4a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,166 +1,72 @@ -# image: https://hub.docker.com/r/frappe/erpnext-worker +x-depends-on-configurator: &depends_on_configurator + depends_on: + configurator: + condition: service_completed_successfully -version: "3.8" +x-backend-defaults: &backend_defaults + <<: *depends_on_configurator + image: frappe/frappe-worker:${FRAPPE_VERSION:?No Frappe version set} + volumes: + - sites:/home/frappe/frappe-bench/sites services: - erpnext-nginx: - image: frappe/erpnext-nginx:${APP_VERSION} - container_name: ${APP_NAME}-nginx - restart: always - ports: - - ${APP_PORT}:8080 + configurator: + <<: *backend_defaults + command: configure.py environment: - - FRAPPE_PY=erpnext-python - - FRAPPE_PY_PORT=8000 - - FRAPPE_SOCKETIO=frappe-socketio - - SOCKETIO_PORT=9000 - - SKIP_NGINX_TEMPLATE_GENERATION=${SKIP_NGINX_TEMPLATE_GENERATION} - volumes: - - sites-vol:/var/www/html/sites:rw - - assets-vol:/assets:rw + DB_HOST: ${DB_HOST} + DB_PORT: ${DB_PORT} + REDIS_CACHE: ${REDIS_CACHE} + REDIS_QUEUE: ${REDIS_QUEUE} + REDIS_SOCKETIO: ${REDIS_SOCKETIO} + SOCKETIO_PORT: 9000 + depends_on: {} - erpnext-python: - image: frappe/erpnext-worker:${APP_VERSION} - container_name: ${APP_NAME}-worker - restart: always + backend: + <<: *backend_defaults + volumes: + - sites:/home/frappe/frappe-bench/sites + - assets:/home/frappe/frappe-bench/sites/assets:ro + + frontend: + image: frappe/frappe-nginx:${FRAPPE_VERSION} environment: - - MARIADB_HOST=${DB_MARIADB_HOST} - - REDIS_CACHE=redis-cache:6379 - - REDIS_QUEUE=redis-queue:6379 - - REDIS_SOCKETIO=redis-socketio:6379 - - SOCKETIO_PORT=9000 - - AUTO_MIGRATE=1 - - WORKER_CLASS=${WORKER_CLASS} + BACKEND: backend:8000 + SOCKETIO: websocket:9000 + FRAPPE_SITE_NAME_HEADER: ${FRAPPE_SITE_NAME_HEADER:-$$host} + UPSTREAM_REAL_IP_ADDRESS: ${UPSTREAM_REAL_IP_ADDRESS:-127.0.0.1} + UPSTREAM_REAL_IP_HEADER: ${UPSTREAM_REAL_IP_HEADER:-X-Forwarded-For} + UPSTREAM_REAL_IP_RECURSIVE: ${UPSTREAM_REAL_IP_RECURSIVE:-off} volumes: - - sites-vol:/home/frappe/frappe-bench/sites:rw - - assets-vol:/home/frappe/frappe-bench/sites/assets:rw - - frappe-socketio: - image: frappe/frappe-socketio:${APP_VERSION} - container_name: ${APP_NAME}-socketio - restart: always + - sites:/usr/share/nginx/html/sites + - assets:/usr/share/nginx/html/assets depends_on: - - redis-socketio - volumes: - - sites-vol:/home/frappe/frappe-bench/sites:rw - - logs-vol:/home/frappe/frappe-bench/logs:rw + - backend + - websocket - erpnext-worker-default: - image: frappe/erpnext-worker:${APP_VERSION} - container_name: ${APP_NAME}-worker-default - restart: always - command: worker - depends_on: - - redis-queue - - redis-cache + websocket: + <<: *depends_on_configurator + image: frappe/frappe-socketio:${FRAPPE_VERSION} volumes: - - sites-vol:/home/frappe/frappe-bench/sites:rw - - logs-vol:/home/frappe/frappe-bench/logs:rw + - sites:/home/frappe/frappe-bench/sites - erpnext-worker-short: - image: frappe/erpnext-worker:${APP_VERSION} - container_name: ${APP_NAME}-worker-short - restart: always - command: worker - environment: - - WORKER_TYPE=short - depends_on: - - redis-queue - - redis-cache - volumes: - - sites-vol:/home/frappe/frappe-bench/sites:rw - - logs-vol:/home/frappe/frappe-bench/logs:rw + queue-short: + <<: *backend_defaults + command: bench worker --queue short - erpnext-worker-long: - image: frappe/erpnext-worker:${APP_VERSION} - container_name: ${APP_NAME}-worker-long - restart: always - command: worker - environment: - - WORKER_TYPE=long - depends_on: - - redis-queue - - redis-cache - volumes: - - sites-vol:/home/frappe/frappe-bench/sites:rw + queue-default: + <<: *backend_defaults + command: bench worker --queue default - erpnext-schedule: - image: frappe/erpnext-worker:${APP_VERSION} - container_name: ${APP_NAME}-schedule - restart: always - command: schedule - depends_on: - - redis-queue - - redis-cache - volumes: - - sites-vol:/home/frappe/frappe-bench/sites:rw - - logs-vol:/home/frappe/frappe-bench/logs:rw + queue-long: + <<: *backend_defaults + command: bench worker --queue long - redis-cache: - image: redis:${DB_REDIS_VERSION} - container_name: ${APP_NAME}-redis-cache - restart: always - volumes: - - redis-cache-vol:/data - - redis-queue: - image: redis:${DB_REDIS_VERSION} - container_name: ${APP_NAME}-redis-queue - restart: always - volumes: - - redis-queue-vol:/data - - redis-socketio: - image: redis:${DB_REDIS_VERSION} - container_name: ${APP_NAME}-redis-socketio - restart: always - volumes: - - redis-socketio-vol:/data - - mariadb: - image: mariadb:${DB_MARIADB_VERSION} - container_name: ${APP_NAME}-db - restart: always - ports: - - ${DB_MARIADB_PORT}:3306 - 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_MARIADB_PASSWORD} - - MYSQL_INITDB_SKIP_TZINFO=1 - volumes: - - mariadb-vol:/var/lib/mysql - - site-creator: - image: frappe/erpnext-worker:${APP_VERSION} - container_name: ${APP_NAME}-site-creator - restart: "no" - command: new - depends_on: - - erpnext-python - environment: - - SITE_NAME=${APP_SITE_URL} - - SITES=${APP_SITE_NAME} - - DB_ROOT_USER=${DB_MRAIADB_USER} - - MYSQL_ROOT_PASSWORD=${DB_MARIADB_PASSWORD} - - ADMIN_PASSWORD=${APP_PASSWORD} - - INSTALL_APPS=${APP_INSTALL_APPS} - volumes: - - sites-vol:/home/frappe/frappe-bench/sites:rw - - logs-vol:/home/frappe/frappe-bench/logs:rw + scheduler: + <<: *backend_defaults + command: bench schedule +# ERPNext requires local assets access (Frappe does not) volumes: - sites-vol: - assets-vol: - logs-vol: - mariadb-vol: - redis-cache-vol: - redis-queue-vol: - redis-socketio-vol: - -networks: - default: - name: "${APP_NAME}" + sites: + assets: \ No newline at end of file