Skip to main content

Twenty

mkdir -vp /srv/Files/Twenty/{data,db} \
&& touch /srv/Files/Twenty/.env \
&& touch /srv/Files/Twenty/docker-compose.yml \
&& chmod -R 777 /srv/Files/Twenty/

Edit .env

TAG=latest

POSTGRES_ADMIN_PASSWORD=STRONGPASSWORD

PG_DATABASE_HOST=db:5432

SERVER_URL=http://localhost:3000 #EDIT THIS to reflect web server adress and port you want to use, eg http://192.168.1.103:9171
# Uncoment if you are serving your front on another server than the API (eg. bucket)
# FRONT_BASE_URL=http://localhost:3000

# Use openssl rand -base64 32 for each secret
ACCESS_TOKEN_SECRET=
LOGIN_TOKEN_SECRET=
REFRESH_TOKEN_SECRET=
FILE_TOKEN_SECRET=

SIGN_IN_PREFILLED=true

STORAGE_TYPE=local

# STORAGE_S3_REGION=eu-west3
# STORAGE_S3_NAME=my-bucket
# STORAGE_S3_ENDPOINT=

Edit docker-compose.yml. In this example, persistent bound volumes are used

version: "3.9"
name: twenty

services:
  server:
    image: twentycrm/twenty:${TAG}
    volumes:
      - /srv/Files/Twenty/data:/app/${STORAGE_LOCAL_PATH:-.local-storage}
    ports:
      - "3000:3000" #has to match your .env, eg 9171:3000
    environment:
      PORT: 3000 #don't change
      PG_DATABASE_URL: postgres://twenty:twenty@${PG_DATABASE_HOST}/default
      SERVER_URL: ${SERVER_URL}
      FRONT_BASE_URL: ${FRONT_BASE_URL:-$SERVER_URL}

      ENABLE_DB_MIGRATIONS: "true"

      SIGN_IN_PREFILLED: ${SIGN_IN_PREFILLED}
      STORAGE_TYPE: ${STORAGE_TYPE}
      STORAGE_S3_REGION: ${STORAGE_S3_REGION}
      STORAGE_S3_NAME: ${STORAGE_S3_NAME}
      STORAGE_S3_ENDPOINT: ${STORAGE_S3_ENDPOINT}
      ACCESS_TOKEN_SECRET: ${ACCESS_TOKEN_SECRET}
      LOGIN_TOKEN_SECRET: ${LOGIN_TOKEN_SECRET}
      REFRESH_TOKEN_SECRET: ${REFRESH_TOKEN_SECRET}
      FILE_TOKEN_SECRET: ${FILE_TOKEN_SECRET}
    depends_on:
      db:
        condition: service_healthy
    healthcheck:
      test: curl --fail http://localhost:3000/healthz #don't change
      interval: 5s
      timeout: 5s
      retries: 10
    restart: always

  db:
    image: twentycrm/twenty-postgres:${TAG}
    volumes:
      - /srv/Files/Twenty/db:/bitnami/postgresql
    environment:
      POSTGRES_PASSWORD: ${POSTGRES_ADMIN_PASSWORD}
    healthcheck:
      test: pg_isready -U twenty -d default
      interval: 5s
      timeout: 5s
      retries: 10
    restart: always

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