fix(template): Twenty DB

This commit is contained in:
DrMxrcy
2024-11-21 10:18:38 -05:00
parent e9956a66da
commit d4b8985d71
2 changed files with 24 additions and 18 deletions

View File

@@ -23,7 +23,7 @@ services:
- twenty-docker-data:/app/docker-data - twenty-docker-data:/app/docker-data
environment: environment:
PORT: 3000 PORT: 3000
PG_DATABASE_URL: postgres://${PGUSER}:${PGPASSWORD}@twenty-db:5432/default PG_DATABASE_URL: postgres://${DB_USER}:${DB_PASSWORD}@twenty-postgres:5432/twenty
SERVER_URL: https://${TWENTY_HOST} SERVER_URL: https://${TWENTY_HOST}
FRONT_BASE_URL: https://${TWENTY_HOST} FRONT_BASE_URL: https://${TWENTY_HOST}
REDIS_URL: redis://twenty-redis:6379 REDIS_URL: redis://twenty-redis:6379
@@ -34,7 +34,7 @@ services:
depends_on: depends_on:
twenty-change-vol-ownership: twenty-change-vol-ownership:
condition: service_completed_successfully condition: service_completed_successfully
twenty-db: twenty-postgres:
condition: service_healthy condition: service_healthy
healthcheck: healthcheck:
test: curl --fail http://localhost:3000/healthz test: curl --fail http://localhost:3000/healthz
@@ -49,7 +49,7 @@ services:
- dokploy-network - dokploy-network
command: ["yarn", "worker:prod"] command: ["yarn", "worker:prod"]
environment: environment:
PG_DATABASE_URL: postgres://${PGUSER}:${PGPASSWORD}@twenty-db:5432/default PG_DATABASE_URL: postgres://${DB_USER}:${DB_PASSWORD}@twenty-postgres:5432/twenty
SERVER_URL: https://${TWENTY_HOST} SERVER_URL: https://${TWENTY_HOST}
FRONT_BASE_URL: https://${TWENTY_HOST} FRONT_BASE_URL: https://${TWENTY_HOST}
REDIS_URL: redis://twenty-redis:6379 REDIS_URL: redis://twenty-redis:6379
@@ -57,25 +57,24 @@ services:
STORAGE_TYPE: local STORAGE_TYPE: local
APP_SECRET: ${APP_SECRET} APP_SECRET: ${APP_SECRET}
depends_on: depends_on:
twenty-db: twenty-postgres:
condition: service_healthy condition: service_healthy
twenty-server: twenty-server:
condition: service_healthy condition: service_healthy
restart: always restart: always
twenty-db: twenty-postgres:
image: twentycrm/twenty-postgres-spilo:latest image: postgres:16-alpine
networks: networks:
- dokploy-network - dokploy-network
volumes: volumes:
- twenty-db-data:/home/postgres/pgdata - twenty-postgres-data:/var/lib/postgresql/data
environment: environment:
PGUSER_SUPERUSER: ${PGUSER} POSTGRES_USER: ${DB_USER}
PGPASSWORD_SUPERUSER: ${PGPASSWORD} POSTGRES_PASSWORD: ${DB_PASSWORD}
ALLOW_NOSSL: "true" POSTGRES_DB: twenty
SPILO_PROVIDER: "local"
healthcheck: healthcheck:
test: pg_isready -U ${PGUSER} -h localhost -d postgres test: ["CMD-SHELL", "pg_isready -U ${DB_USER} -d twenty"]
interval: 5s interval: 5s
timeout: 5s timeout: 5s
retries: 10 retries: 10
@@ -85,6 +84,8 @@ services:
image: redis:latest image: redis:latest
networks: networks:
- dokploy-network - dokploy-network
volumes:
- twenty-redis-data:/data
healthcheck: healthcheck:
test: ["CMD", "redis-cli", "ping"] test: ["CMD", "redis-cli", "ping"]
interval: 5s interval: 5s
@@ -92,7 +93,12 @@ services:
retries: 10 retries: 10
restart: always restart: always
networks:
dokploy-network:
external: true
volumes: volumes:
twenty-docker-data: twenty-docker-data:
twenty-db-data: twenty-postgres-data:
twenty-server-local-data: twenty-server-local-data:
twenty-redis-data:

View File

@@ -9,8 +9,8 @@ import {
export function generate(schema: Schema): Template { export function generate(schema: Schema): Template {
const mainDomain = generateRandomDomain(schema); const mainDomain = generateRandomDomain(schema);
const pgPassword = generatePassword(); const dbPassword = generatePassword();
const pgUser = "twenty"; const dbUser = "twenty";
const appSecret = generateBase64(32); const appSecret = generateBase64(32);
const domains: DomainSchema[] = [ const domains: DomainSchema[] = [
@@ -23,8 +23,8 @@ export function generate(schema: Schema): Template {
const envs = [ const envs = [
`TWENTY_HOST=${mainDomain}`, `TWENTY_HOST=${mainDomain}`,
`PGUSER=${pgUser}`, `DB_USER=${dbUser}`,
`PGPASSWORD=${pgPassword}`, `DB_PASSWORD=${dbPassword}`,
`APP_SECRET=${appSecret}`, `APP_SECRET=${appSecret}`,
"# Optional: Configure storage path", "# Optional: Configure storage path",
"# STORAGE_LOCAL_PATH=.local-storage", "# STORAGE_LOCAL_PATH=.local-storage",