From 5c17797749d0206de3a9e3b618fdcbd4aa7e4683 Mon Sep 17 00:00:00 2001 From: DrMxrcy Date: Tue, 12 Nov 2024 16:19:14 -0500 Subject: [PATCH] Add: Chatwoot --- apps/dokploy/public/templates/chatwoot.svg | 3 + .../templates/chatwoot/docker-compose.yml | 117 ++++++++++++++++++ apps/dokploy/templates/chatwoot/index.ts | 41 ++++++ apps/dokploy/templates/templates.ts | 14 +++ 4 files changed, 175 insertions(+) create mode 100644 apps/dokploy/public/templates/chatwoot.svg create mode 100644 apps/dokploy/templates/chatwoot/docker-compose.yml create mode 100644 apps/dokploy/templates/chatwoot/index.ts diff --git a/apps/dokploy/public/templates/chatwoot.svg b/apps/dokploy/public/templates/chatwoot.svg new file mode 100644 index 000000000..56c9a7b8f --- /dev/null +++ b/apps/dokploy/public/templates/chatwoot.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/apps/dokploy/templates/chatwoot/docker-compose.yml b/apps/dokploy/templates/chatwoot/docker-compose.yml new file mode 100644 index 000000000..27885b8a3 --- /dev/null +++ b/apps/dokploy/templates/chatwoot/docker-compose.yml @@ -0,0 +1,117 @@ +version: "3.8" + +services: + base: &base + image: chatwoot/chatwoot:v3.14.1 + volumes: + - storage_data:/app/storage + networks: + - dokploy-network + + rails: + <<: *base + depends_on: + postgres: + condition: service_healthy + redis: + condition: service_healthy + environment: + - NODE_ENV=production + - RAILS_ENV=production + - INSTALLATION_ENV=docker + - FRONTEND_URL=https://${CHATWOOT_HOST} + - SECRET_KEY_BASE=${SECRET_KEY_BASE} + - POSTGRES_HOST=postgres + - POSTGRES_USERNAME=${POSTGRES_USERNAME} + - POSTGRES_PASSWORD=${POSTGRES_PASSWORD} + - POSTGRES_DATABASE=chatwoot_production + - REDIS_URL=redis://redis:6379 + - REDIS_PASSWORD=${REDIS_PASSWORD} + - ENABLE_ACCOUNT_SIGNUP=false + - MAILER_SENDER_EMAIL=Chatwoot + - FORCE_SSL=true + - RAILS_LOG_TO_STDOUT=true + - LOG_LEVEL=info + - LOG_SIZE=500 + - RAILS_MAX_THREADS=5 + - SMTP_DOMAIN=${CHATWOOT_HOST} + - SMTP_ADDRESS=${SMTP_ADDRESS} + - SMTP_PORT=${SMTP_PORT} + - SMTP_USERNAME=${SMTP_USERNAME} + - SMTP_PASSWORD=${SMTP_PASSWORD} + - SMTP_AUTHENTICATION=plain + - SMTP_ENABLE_STARTTLS_AUTO=true + entrypoint: docker/entrypoints/rails.sh + command: ['bundle', 'exec', 'rails', 's', '-p', '3000', '-b', '0.0.0.0'] + restart: always + + sidekiq: + <<: *base + depends_on: + postgres: + condition: service_healthy + redis: + condition: service_healthy + environment: + - NODE_ENV=production + - RAILS_ENV=production + - INSTALLATION_ENV=docker + - FRONTEND_URL=https://${CHATWOOT_HOST} + - SECRET_KEY_BASE=${SECRET_KEY_BASE} + - POSTGRES_HOST=postgres + - POSTGRES_USERNAME=${POSTGRES_USERNAME} + - POSTGRES_PASSWORD=${POSTGRES_PASSWORD} + - POSTGRES_DATABASE=chatwoot_production + - REDIS_URL=redis://redis:6379 + - REDIS_PASSWORD=${REDIS_PASSWORD} + - FORCE_SSL=true + - RAILS_LOG_TO_STDOUT=true + - LOG_LEVEL=info + - LOG_SIZE=500 + - RAILS_MAX_THREADS=5 + - SMTP_DOMAIN=${CHATWOOT_HOST} + - SMTP_ADDRESS=${SMTP_ADDRESS} + - SMTP_PORT=${SMTP_PORT} + - SMTP_USERNAME=${SMTP_USERNAME} + - SMTP_PASSWORD=${SMTP_PASSWORD} + - SMTP_AUTHENTICATION=plain + - SMTP_ENABLE_STARTTLS_AUTO=true + - MAILER_SENDER_EMAIL=Chatwoot + command: ['bundle', 'exec', 'sidekiq', '-C', 'config/sidekiq.yml'] + restart: always + + postgres: + image: postgres:12 + networks: + - dokploy-network + volumes: + - postgres_data:/var/lib/postgresql/data + environment: + - POSTGRES_DB=chatwoot_production + - POSTGRES_USER=${POSTGRES_USERNAME} + - POSTGRES_PASSWORD=${POSTGRES_PASSWORD} + healthcheck: + test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USERNAME}"] + interval: 10s + timeout: 5s + retries: 5 + restart: always + + redis: + image: redis:alpine + networks: + - dokploy-network + command: ["sh", "-c", "redis-server --requirepass \"${REDIS_PASSWORD}\""] + volumes: + - redis_data:/data + healthcheck: + test: ["CMD", "redis-cli", "ping"] + interval: 10s + timeout: 5s + retries: 5 + restart: always + +volumes: + storage_data: + postgres_data: + redis_data: \ No newline at end of file diff --git a/apps/dokploy/templates/chatwoot/index.ts b/apps/dokploy/templates/chatwoot/index.ts new file mode 100644 index 000000000..599b82f52 --- /dev/null +++ b/apps/dokploy/templates/chatwoot/index.ts @@ -0,0 +1,41 @@ +import { + type DomainSchema, + type Schema, + type Template, + generatePassword, + generateRandomDomain, + generateBase64, +} from "../utils"; + +export function generate(schema: Schema): Template { + const mainDomain = generateRandomDomain(schema); + const postgresUsername = "chatwoot"; + const postgresPassword = generatePassword(); + const redisPassword = generatePassword(); + const secretKeyBase = generateBase64(64); + + const domains: DomainSchema[] = [ + { + host: mainDomain, + port: 3000, + serviceName: "rails", + }, + ]; + + const envs = [ + `CHATWOOT_HOST=${mainDomain}`, + `POSTGRES_USERNAME=${postgresUsername}`, + `POSTGRES_PASSWORD=${postgresPassword}`, + `REDIS_PASSWORD=${redisPassword}`, + `SECRET_KEY_BASE=${secretKeyBase}`, + `SMTP_ADDRESS=${process.env.SMTP_ADDRESS || ''}`, + `SMTP_PORT=${process.env.SMTP_PORT || '587'}`, + `SMTP_USERNAME=${process.env.SMTP_USERNAME || ''}`, + `SMTP_PASSWORD=${process.env.SMTP_PASSWORD || ''}`, + ]; + + return { + domains, + envs, + }; +} \ No newline at end of file diff --git a/apps/dokploy/templates/templates.ts b/apps/dokploy/templates/templates.ts index 74d38c437..bae9a8f79 100644 --- a/apps/dokploy/templates/templates.ts +++ b/apps/dokploy/templates/templates.ts @@ -800,4 +800,18 @@ export const templates: TemplateData[] = [ tags: ["links", "sharing", "social"], load: () => import("./linkstack/index").then((m) => m.generate), }, + { + id: "chatwoot", + name: "Chatwoot", + version: "v3.14.1", + description: "Open-source customer engagement suite, an alternative to Intercom, Zendesk, Salesforce Service Cloud etc.", + logo: "chatwoot.svg", + links: { + github: "https://github.com/chatwoot/chatwoot", + website: "https://www.chatwoot.com", + docs: "https://www.chatwoot.com/docs", + }, + tags: ["customer-support", "live-chat", "helpdesk"], + load: () => import("./chatwoot/index").then((m) => m.generate), + }, ];