TwentyT
Twenty8mo ago
9 replies
Farrit

twenty can't find its database

I'm trying to run Twenty behind a reverse proxy (traefik) and I have been using a script to help manage/configure it (deplyrr).

In doing so, I'm trying to shoe-horn the .env's together by transplanting all of twenty's env variables into my other .env, and use the same ones that I am able to get working with twenty as a standalone stack, AND get twenty to fit into the formatting that deployrr uses - to be able to use the automation that it has setup with traefik... but I keep running into the same issue where the server cannot find the database at the database address.

I have all of the services split up into individual yml files (twenty-server.yml, twenty-worker.yml, twenty-db.yml) and redis is already running on my server, and has been associated (I assume correcly.. But I even if I create a second redis container using pre-defined settings, it doesn't seem to help)

Can anyone see what I'm doing incorrectly here?



services:
  twenty-server:
    image: twentycrm/twenty:${TAG:-latest}
    profiles: ["all", "twenty"]
    volumes:
      - $DOCKERDIR/appdata/twenty/server-local-data:/app/packages/twenty-server/.local-storage
    networks:
      - default
      - socket_proxy
    ports:
      - "$TWENTY_PORT:3000"
    environment:
      NODE_PORT: 3000
      PG_DATABASE_URL: postgres://${PG_DATABASE_USER:-postgres}:${PG_DATABASE_PASSWORD:-postgres}@${PG_DATABASE_HOST:-db}:${PG_DATABASE_PORT:-5432}/default      
      SERVER_URL: ${SERVER_URL}
      REDIS_URL: ${REDIS_URL:-redis://redis:6379}

      STORAGE_TYPE: ${STORAGE_TYPE}
      STORAGE_S3_REGION: ${STORAGE_S3_REGION}
      STORAGE_S3_NAME: ${STORAGE_S3_NAME}
      STORAGE_S3_ENDPOINT: ${STORAGE_S3_ENDPOINT}

      APP_SECRET: ${APP_SECRET}

    depends_on:
      twenty-db:
        condition: service_healthy
    healthcheck:
      test: curl --fail http://100.67.242.72:3000/healthz
      interval: 5s
      timeout: 5s
      retries: 20
    restart: always

volumes:
  db-data:
  server-local-data:


services:
  twenty-worker:
    image: twentycrm/twenty:${TAG:-latest}
    profiles: ["all", "twenty"]
    networks:
      - default
      - socket_proxy
    volumes:
      - $DOCKERDIR/appdata/twenty/server-local-data:/app/packages/twenty-server/${STORAGE_LOCAL_PATH:-.local-storage}
    command: ["yarn", "worker:prod"]
    environment:
      PG_DATABASE_URL: postgres://${PG_DATABASE_USER:-postgres}:${PG_DATABASE_PASSWORD:-postgres}@${PG_DATABASE_HOST:-db}:${PG_DATABASE_PORT:-5432}/default
      SERVER_URL: ${SERVER_URL}
      REDIS_URL: ${REDIS_URL:-redis://redis:6379}
      DISABLE_DB_MIGRATIONS: "true" # it already runs on the server

      STORAGE_TYPE: ${STORAGE_TYPE}
      STORAGE_S3_REGION: ${STORAGE_S3_REGION}
      STORAGE_S3_NAME: ${STORAGE_S3_NAME}
      STORAGE_S3_ENDPOINT: ${STORAGE_S3_ENDPOINT}

      APP_SECRET: ${APP_SECRET}

    depends_on:
      twenty-db:
        condition: service_healthy
      twenty-server:
        condition: service_healthy
    restart: always

volumes:
  db-data:
  server-local-data:


services:
  twenty-db:
    image: postgres:16
    profiles: ["all", "twenty"]
    networks:
      - default
      - socket_proxy
    volumes:
      - $DOCKERDIR/appdata/twenty/db-data:/var/lib/postgresql/data
    ports:
      - "$PG_DATABASE_PORT:5432"
    environment:
      POSTGRES_USER: ${PG_DATABASE_USER:-postgres}
      POSTGRES_PASSWORD: ${PG_DATABASE_PASSWORD:-postgres}
    healthcheck:
      test: pg_isready -U ${PG_DATABASE_USER:-postgres} -h localhost -d postgres
      interval: 5s
      timeout: 5s
      retries: 10
    restart: always

volumes:
 db-data:
 server-local-data:
image.png
Was this page helpful?