From 62a3707c100006b35896a797a9fe8e35f9c8d5f8 Mon Sep 17 00:00:00 2001 From: Hussain Nagaria Date: Wed, 29 Jan 2025 18:49:27 +0530 Subject: [PATCH 1/7] feat(template): frappe HR, open source HR & Payroll software --- apps/dokploy/public/templates/frappe-hr.svg | 5 + .../templates/frappe-hr/docker-compose.yml | 346 ++++++++++++++++++ apps/dokploy/templates/frappe-hr/index.ts | 37 ++ apps/dokploy/templates/templates.ts | 15 + 4 files changed, 403 insertions(+) create mode 100644 apps/dokploy/public/templates/frappe-hr.svg create mode 100644 apps/dokploy/templates/frappe-hr/docker-compose.yml create mode 100644 apps/dokploy/templates/frappe-hr/index.ts diff --git a/apps/dokploy/public/templates/frappe-hr.svg b/apps/dokploy/public/templates/frappe-hr.svg new file mode 100644 index 00000000..4cbf5164 --- /dev/null +++ b/apps/dokploy/public/templates/frappe-hr.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/apps/dokploy/templates/frappe-hr/docker-compose.yml b/apps/dokploy/templates/frappe-hr/docker-compose.yml new file mode 100644 index 00000000..3ed923ea --- /dev/null +++ b/apps/dokploy/templates/frappe-hr/docker-compose.yml @@ -0,0 +1,346 @@ +x-custom-image: &custom_image + image: ${IMAGE_NAME:-ghcr.io/frappe/hrms}:${VERSION:-version-15} + pull_policy: ${PULL_POLICY:-always} + deploy: + restart_policy: + condition: always + +services: + backend: + <<: *custom_image + volumes: + - sites:/home/frappe/frappe-bench/sites + networks: + - bench-network + healthcheck: + test: + - CMD + - wait-for-it + - '0.0.0.0:8000' + interval: 2s + timeout: 10s + retries: 30 + + frontend: + <<: *custom_image + command: + - nginx-entrypoint.sh + depends_on: + backend: + condition: service_started + required: true + websocket: + condition: service_started + required: true + environment: + BACKEND: backend:8000 + FRAPPE_SITE_NAME_HEADER: ${FRAPPE_SITE_NAME_HEADER:-$$host} + 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:/home/frappe/frappe-bench/sites + + networks: + - bench-network + + healthcheck: + test: + - CMD + - wait-for-it + - '0.0.0.0:8080' + interval: 2s + timeout: 30s + retries: 30 + + queue-default: + <<: *custom_image + command: + - bench + - worker + - --queue + - default + volumes: + - sites:/home/frappe/frappe-bench/sites + networks: + - bench-network + healthcheck: + test: + - CMD + - wait-for-it + - 'redis-queue:6379' + interval: 2s + timeout: 10s + retries: 30 + depends_on: + configurator: + condition: service_completed_successfully + required: true + + queue-long: + <<: *custom_image + command: + - bench + - worker + - --queue + - long + volumes: + - sites:/home/frappe/frappe-bench/sites + networks: + - bench-network + healthcheck: + test: + - CMD + - wait-for-it + - 'redis-queue:6379' + interval: 2s + timeout: 10s + retries: 30 + depends_on: + configurator: + condition: service_completed_successfully + required: true + + queue-short: + <<: *custom_image + command: + - bench + - worker + - --queue + - short + volumes: + - sites:/home/frappe/frappe-bench/sites + networks: + - bench-network + healthcheck: + test: + - CMD + - wait-for-it + - 'redis-queue:6379' + interval: 2s + timeout: 10s + retries: 30 + depends_on: + configurator: + condition: service_completed_successfully + required: true + + scheduler: + <<: *custom_image + healthcheck: + test: + - CMD + - wait-for-it + - 'redis-queue:6379' + interval: 2s + timeout: 10s + retries: 30 + command: + - bench + - schedule + depends_on: + configurator: + condition: service_completed_successfully + required: true + volumes: + - sites:/home/frappe/frappe-bench/sites + networks: + - bench-network + + websocket: + <<: *custom_image + healthcheck: + test: + - CMD + - wait-for-it + - '0.0.0.0:9000' + interval: 2s + timeout: 10s + retries: 30 + command: + - node + - /home/frappe/frappe-bench/apps/frappe/socketio.js + depends_on: + configurator: + condition: service_completed_successfully + required: true + volumes: + - sites:/home/frappe/frappe-bench/sites + networks: + - bench-network + + configurator: + <<: *custom_image + deploy: + mode: replicated + replicas: ${CONFIGURE:-0} + restart_policy: + condition: none + entrypoint: ["bash", "-c"] + command: + - > + [[ $${REGENERATE_APPS_TXT} == "1" ]] && ls -1 apps > sites/apps.txt; + [[ -n `grep -hs ^ sites/common_site_config.json | jq -r ".db_host // empty"` ]] && exit 0; + 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_QUEUE"; + 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 + SOCKETIO_PORT: "9000" + REGENERATE_APPS_TXT: "${REGENERATE_APPS_TXT:-0}" + volumes: + - sites:/home/frappe/frappe-bench/sites + networks: + - bench-network + + create-site: + <<: *custom_image + deploy: + mode: replicated + replicas: ${CREATE_SITE:-0} + restart_policy: + condition: none + entrypoint: ["bash", "-c"] + command: + - > + wait-for-it -t 120 db:3306; + wait-for-it -t 120 redis-cache:6379; + wait-for-it -t 120 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"; + [[ -d "sites/${SITE_NAME}" ]] && echo "${SITE_NAME} already exists" && exit 0; + bench new-site --mariadb-user-host-login-scope='%' --admin-password=$${ADMIN_PASSWORD} --db-root-username=root --db-root-password=$${DB_ROOT_PASSWORD} $${INSTALL_APP_ARGS} $${SITE_NAME}; + volumes: + - sites:/home/frappe/frappe-bench/sites + environment: + ADMIN_PASSWORD: ${ADMIN_PASSWORD} + DB_ROOT_PASSWORD: ${DB_ROOT_PASSWORD} + INSTALL_APP_ARGS: ${INSTALL_APP_ARGS} + SITE_NAME: ${SITE_NAME} + networks: + - bench-network + + migration: + <<: *custom_image + deploy: + mode: replicated + replicas: ${MIGRATE:-0} + restart_policy: + condition: none + entrypoint: ["bash", "-c"] + command: + - > + curl -f http://${SITE_NAME}:8080/api/method/ping || echo "Site busy" && exit 0; + bench --site all set-config -p maintenance_mode 1; + bench --site all set-config -p pause_scheduler 1; + bench --site all migrate; + bench --site all set-config -p maintenance_mode 0; + bench --site all set-config -p pause_scheduler 0; + volumes: + - sites:/home/frappe/frappe-bench/sites + networks: + - bench-network + + db: + image: mariadb:10.6 + deploy: + restart_policy: + condition: always + healthcheck: + test: mysqladmin ping -h localhost --password=${DB_ROOT_PASSWORD} + interval: 1s + retries: 20 + command: + - --character-set-server=utf8mb4 + - --collation-server=utf8mb4_unicode_ci + - --skip-character-set-client-handshake + - --skip-innodb-read-only-compressed + environment: + - MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD} + - MARIADB_ROOT_PASSWORD=${DB_ROOT_PASSWORD} + volumes: + - db-data:/var/lib/mysql + networks: + - bench-network + + redis-cache: + deploy: + restart_policy: + condition: always + image: redis:6.2-alpine + volumes: + - redis-cache-data:/data + networks: + - bench-network + healthcheck: + test: + - CMD + - redis-cli + - ping + interval: 5s + timeout: 5s + retries: 3 + + redis-queue: + deploy: + restart_policy: + condition: always + image: redis:6.2-alpine + volumes: + - redis-queue-data:/data + networks: + - bench-network + healthcheck: + test: + - CMD + - redis-cli + - ping + interval: 5s + timeout: 5s + retries: 3 + + redis-socketio: + deploy: + restart_policy: + condition: always + image: redis:6.2-alpine + volumes: + - redis-socketio-data:/data + networks: + - bench-network + healthcheck: + test: + - CMD + - redis-cli + - ping + interval: 5s + timeout: 5s + retries: 3 + +volumes: + db-data: + redis-cache-data: + redis-queue-data: + redis-socketio-data: + sites: + +networks: + bench-network: \ No newline at end of file diff --git a/apps/dokploy/templates/frappe-hr/index.ts b/apps/dokploy/templates/frappe-hr/index.ts new file mode 100644 index 00000000..7a2f501f --- /dev/null +++ b/apps/dokploy/templates/frappe-hr/index.ts @@ -0,0 +1,37 @@ +import { + type DomainSchema, + type Schema, + type Template, + generatePassword, + generateRandomDomain, +} from "../utils"; + +export function generate(schema: Schema): Template { + const dbRootPassword = generatePassword(32); + const adminPassword = generatePassword(32); + const mainDomain = generateRandomDomain(schema); + + const domains: DomainSchema[] = [ + { + host: mainDomain, + port: 8080, + serviceName: "frontend", + }, + ]; + + const envs = [ + `SITE_NAME=${mainDomain}`, + `ADMIN_PASSWORD=${adminPassword}`, + `DB_ROOT_PASSWORD=${dbRootPassword}`, + "MIGRATE=1", + "CREATE_SITE=1", + "CONFIGURE=1", + "REGENERATE_APPS_TXT=1", + "INSTALL_APP_ARGS=--install-app hrms", + "IMAGE_NAME=ghcr.io/frappe/hrms", + "VERSION=version-15", + "FRAPPE_SITE_NAME_HEADER=", + ]; + + return { envs, domains }; +} diff --git a/apps/dokploy/templates/templates.ts b/apps/dokploy/templates/templates.ts index 98bbdbc5..78cb39a2 100644 --- a/apps/dokploy/templates/templates.ts +++ b/apps/dokploy/templates/templates.ts @@ -1438,4 +1438,19 @@ export const templates: TemplateData[] = [ tags: ["sharing", "shortener", "url"], load: () => import("./shlink/index").then((m) => m.generate), }, + { + id: "frappe-hr", + name: "Frappe HR", + version: "version-15", + description: + "Feature rich HR & Payroll software. 100% FOSS and customizable.", + logo: "frappe-hr.svg", + links: { + github: "https://github.com/frappe/hrms", + docs: "https://docs.frappe.io/hr", + website: "https://frappe.io/hr", + }, + tags: ["hrms", "payroll", "leaves", "expenses", "attendance", "performace"], + load: () => import("./frappe-hr/index").then((m) => m.generate), + }, ]; From 20eb6d7985188d39d40ab6d732e9df2287910bb6 Mon Sep 17 00:00:00 2001 From: Franco Gamonal Date: Mon, 3 Feb 2025 10:27:35 -0300 Subject: [PATCH 2/7] Revert "feat: Updated PocketBase version to 0.25.0" --- apps/dokploy/templates/pocketbase/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/dokploy/templates/pocketbase/docker-compose.yml b/apps/dokploy/templates/pocketbase/docker-compose.yml index 485c0f85..cf5e94f1 100644 --- a/apps/dokploy/templates/pocketbase/docker-compose.yml +++ b/apps/dokploy/templates/pocketbase/docker-compose.yml @@ -1,7 +1,7 @@ version: "3.8" services: pocketbase: - image: spectado/pocketbase:0.25.0 + image: spectado/pocketbase:0.23.3 restart: unless-stopped volumes: - /etc/dokploy/templates/${HASH}/data:/pb_data From 9d988c9a9bc1bd22db1a2c722bf8d7f70a305e21 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Mon, 3 Feb 2025 21:49:20 -0600 Subject: [PATCH 3/7] Update package.json --- apps/dokploy/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/dokploy/package.json b/apps/dokploy/package.json index 14f7d27c..213c9073 100644 --- a/apps/dokploy/package.json +++ b/apps/dokploy/package.json @@ -1,6 +1,6 @@ { "name": "dokploy", - "version": "v0.18.1", + "version": "v0.18.2", "private": true, "license": "Apache-2.0", "type": "module", From 65780ee8528cfb78ba8d124884c83de52c7c24a7 Mon Sep 17 00:00:00 2001 From: Hussain Nagaria Date: Tue, 4 Feb 2025 13:57:49 +0530 Subject: [PATCH 4/7] feat: make db configurable --- apps/dokploy/templates/frappe-hr/docker-compose.yml | 4 +++- apps/dokploy/templates/frappe-hr/index.ts | 2 ++ apps/dokploy/templates/listmonk/index.ts | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/dokploy/templates/frappe-hr/docker-compose.yml b/apps/dokploy/templates/frappe-hr/docker-compose.yml index 3ed923ea..29ba0069 100644 --- a/apps/dokploy/templates/frappe-hr/docker-compose.yml +++ b/apps/dokploy/templates/frappe-hr/docker-compose.yml @@ -189,7 +189,7 @@ services: bench set-config -g redis_socketio "redis://$$REDIS_QUEUE"; bench set-config -gp socketio_port $$SOCKETIO_PORT; environment: - DB_HOST: db + DB_HOST: "${DB_HOST:-db}" DB_PORT: "3306" REDIS_CACHE: redis-cache:6379 REDIS_QUEUE: redis-queue:6379 @@ -262,6 +262,8 @@ services: db: image: mariadb:10.6 deploy: + mode: replicated + replicas: ${ENABLE_DB:-0} restart_policy: condition: always healthcheck: diff --git a/apps/dokploy/templates/frappe-hr/index.ts b/apps/dokploy/templates/frappe-hr/index.ts index 7a2f501f..1e6b9474 100644 --- a/apps/dokploy/templates/frappe-hr/index.ts +++ b/apps/dokploy/templates/frappe-hr/index.ts @@ -24,6 +24,8 @@ export function generate(schema: Schema): Template { `ADMIN_PASSWORD=${adminPassword}`, `DB_ROOT_PASSWORD=${dbRootPassword}`, "MIGRATE=1", + "ENABLE_DB=1", + "DB_HOST=db", "CREATE_SITE=1", "CONFIGURE=1", "REGENERATE_APPS_TXT=1", diff --git a/apps/dokploy/templates/listmonk/index.ts b/apps/dokploy/templates/listmonk/index.ts index 113b3862..2a25efca 100644 --- a/apps/dokploy/templates/listmonk/index.ts +++ b/apps/dokploy/templates/listmonk/index.ts @@ -17,7 +17,7 @@ export function generate(schema: Schema): Template { ]; const envs = [ - `# visit the page to setup your super admin user`, + "# visit the page to setup your super admin user", "# check config.toml in Advanced / Volumes for more options", ]; From 82cf0643d72b376b9432f3c600df67335dde0440 Mon Sep 17 00:00:00 2001 From: Hussain Nagaria Date: Tue, 4 Feb 2025 14:15:47 +0530 Subject: [PATCH 5/7] fix: site volume configurable --- apps/dokploy/templates/frappe-hr/docker-compose.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/dokploy/templates/frappe-hr/docker-compose.yml b/apps/dokploy/templates/frappe-hr/docker-compose.yml index 29ba0069..f4d13b5f 100644 --- a/apps/dokploy/templates/frappe-hr/docker-compose.yml +++ b/apps/dokploy/templates/frappe-hr/docker-compose.yml @@ -343,6 +343,10 @@ volumes: redis-queue-data: redis-socketio-data: sites: + driver_opts: + type: "${SITE_VOLUME_TYPE}" + o: "${SITE_VOLUME_OPTS}" + device: "${SITE_VOLUME_DEV}" networks: bench-network: \ No newline at end of file From 46411a5f4e28c12f2a6ed8f63329f461fa11cacd Mon Sep 17 00:00:00 2001 From: Hussain Nagaria Date: Tue, 4 Feb 2025 14:30:55 +0530 Subject: [PATCH 6/7] fix: create site should use configured db --- apps/dokploy/templates/frappe-hr/docker-compose.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/dokploy/templates/frappe-hr/docker-compose.yml b/apps/dokploy/templates/frappe-hr/docker-compose.yml index f4d13b5f..a7ce9b26 100644 --- a/apps/dokploy/templates/frappe-hr/docker-compose.yml +++ b/apps/dokploy/templates/frappe-hr/docker-compose.yml @@ -210,7 +210,7 @@ services: entrypoint: ["bash", "-c"] command: - > - wait-for-it -t 120 db:3306; + wait-for-it -t 120 $$DB_HOST:$$DB_PORT; wait-for-it -t 120 redis-cache:6379; wait-for-it -t 120 redis-queue:6379; export start=`date +%s`; @@ -231,10 +231,12 @@ services: volumes: - sites:/home/frappe/frappe-bench/sites environment: + SITE_NAME: ${SITE_NAME} ADMIN_PASSWORD: ${ADMIN_PASSWORD} + DB_HOST: ${DB_HOST:-db} + DB_PORT: "${DB_PORT:-3306}" DB_ROOT_PASSWORD: ${DB_ROOT_PASSWORD} INSTALL_APP_ARGS: ${INSTALL_APP_ARGS} - SITE_NAME: ${SITE_NAME} networks: - bench-network From 48642979c56a0ee7a79352301839457f9973bcda Mon Sep 17 00:00:00 2001 From: Hussain Nagaria Date: Tue, 4 Feb 2025 17:17:43 +0530 Subject: [PATCH 7/7] chore: make erpnext template more configurable --- apps/dokploy/templates/erpnext/docker-compose.yml | 14 +++++++++++--- apps/dokploy/templates/erpnext/index.ts | 2 ++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/apps/dokploy/templates/erpnext/docker-compose.yml b/apps/dokploy/templates/erpnext/docker-compose.yml index def916be..28cd8f6a 100644 --- a/apps/dokploy/templates/erpnext/docker-compose.yml +++ b/apps/dokploy/templates/erpnext/docker-compose.yml @@ -189,7 +189,7 @@ services: bench set-config -g redis_socketio "redis://$$REDIS_QUEUE"; bench set-config -gp socketio_port $$SOCKETIO_PORT; environment: - DB_HOST: db + DB_HOST: "${DB_HOST:-db}" DB_PORT: "3306" REDIS_CACHE: redis-cache:6379 REDIS_QUEUE: redis-queue:6379 @@ -210,7 +210,7 @@ services: entrypoint: ["bash", "-c"] command: - > - wait-for-it -t 120 db:3306; + wait-for-it -t 120 $$DB_HOST:$$DB_PORT; wait-for-it -t 120 redis-cache:6379; wait-for-it -t 120 redis-queue:6379; export start=`date +%s`; @@ -231,10 +231,12 @@ services: volumes: - sites:/home/frappe/frappe-bench/sites environment: + SITE_NAME: ${SITE_NAME} ADMIN_PASSWORD: ${ADMIN_PASSWORD} + DB_HOST: ${DB_HOST:-db} + DB_PORT: "${DB_PORT:-3306}" DB_ROOT_PASSWORD: ${DB_ROOT_PASSWORD} INSTALL_APP_ARGS: ${INSTALL_APP_ARGS} - SITE_NAME: ${SITE_NAME} networks: - bench-network @@ -262,6 +264,8 @@ services: db: image: mariadb:10.6 deploy: + mode: replicated + replicas: ${ENABLE_DB:-0} restart_policy: condition: always healthcheck: @@ -341,6 +345,10 @@ volumes: redis-queue-data: redis-socketio-data: sites: + driver_opts: + type: "${SITE_VOLUME_TYPE}" + o: "${SITE_VOLUME_OPTS}" + device: "${SITE_VOLUME_DEV}" networks: bench-network: \ No newline at end of file diff --git a/apps/dokploy/templates/erpnext/index.ts b/apps/dokploy/templates/erpnext/index.ts index 0be46c44..5b7543b9 100644 --- a/apps/dokploy/templates/erpnext/index.ts +++ b/apps/dokploy/templates/erpnext/index.ts @@ -24,6 +24,8 @@ export function generate(schema: Schema): Template { `ADMIN_PASSWORD=${adminPassword}`, `DB_ROOT_PASSWORD=${dbRootPassword}`, "MIGRATE=1", + "ENABLE_DB=1", + "DB_HOST=db", "CREATE_SITE=1", "CONFIGURE=1", "REGENERATE_APPS_TXT=1",