DEV Community

sateshcharan
sateshcharan

Posted on

Streamlined Self-Hosting with Twenty CRM: 1-Click Docker Compose Setup

twenty crm

Hey folks! In my continued work with open-source projects, I recently came across Twenty CRM, an open-source CRM platform that has been making waves in the business world. Today, I’m going to walk you through how you can set up Twenty CRM in just a few clicks using Docker Compose. Whether you're self-hosting or setting up for production, this guide will show you how easy it is to get up and running with minimal effort.

docker compose

What is Docker Compose?
Docker Compose is a tool that simplifies running multi-container Docker applications by defining services, networks, and volumes in a single docker-compose.yml file. This makes it perfect for deploying an application like Twenty CRM in a streamlined, easy-to-manage way.

Overview of the 1-Click Docker Compose Setup

twenty crm

Setting up Twenty CRM using Docker Compose is designed to be simple and efficient. Follow the steps in this guide to install and configure the CRM platform with minimal hassle.

However, before jumping in, make sure you’ve got the required system specifications and Docker tools installed. Let's walk through the steps to get you started!


System Requirements
Before we begin, ensure you meet the following system requirements:

  • RAM: At least 2GB of RAM is required. Insufficient memory can cause processes to crash.

  • Docker & Docker Compose: Make sure both Docker and Docker Compose are installed and up-to-date on your system.


Option 1: One-Line Script Installation
The quickest way to install Twenty CRM is by running a single command. This option is perfect for users who want a fast and easy setup.

Run this command to install the latest stable version:

bash <(curl -sL https://git.new/20)
Enter fullscreen mode Exit fullscreen mode

To install a specific version or branch, use the following command, replacing x.y.z with your desired version number, and branch-name with the branch you want:

VERSION=x.y.z BRANCH=branch-name bash <(curl -sL https://git.new/20)
Enter fullscreen mode Exit fullscreen mode

Option 2: Manual Setup
For users who prefer a more hands-on approach, follow these manual steps:

Step 1: Set Up the Environment File
Create an .env file to configure your environment variables.

Copy the example environment file to a new .env file in your working directory:

curl -o .env https://raw.githubusercontent.com/twentyhq/twenty/main/packages/twenty-docker/.env.example
Enter fullscreen mode Exit fullscreen mode

Generate Secret Tokens by running this command four times to create unique strings:

openssl rand -base64 32
Enter fullscreen mode Exit fullscreen mode

Update your .env file with the generated values:

ACCESS_TOKEN_SECRET=first_random_string
LOGIN_TOKEN_SECRET=second_random_string
REFRESH_TOKEN_SECRET=third_random_string
FILE_TOKEN_SECRET=fourth_random_string
Enter fullscreen mode Exit fullscreen mode

Set the Postgres Password:

In the .env file, replace the placeholder POSTGRES_ADMIN_PASSWORD with a strong password:

POSTGRES_ADMIN_PASSWORD=my_strong_password
Enter fullscreen mode Exit fullscreen mode

Step 2: Download the Docker Compose File
Download the docker-compose.yml file into your working directory:

curl -O https://raw.githubusercontent.com/twentyhq/twenty/main/packages/twenty-docker/docker-compose.yml
Enter fullscreen mode Exit fullscreen mode

Step 3: Launch the Application
Start the Docker containers with:

docker-compose up -d
Enter fullscreen mode Exit fullscreen mode

Step 4: Access the Application
Once the containers are running, open your browser and navigate to http://localhost:3000 to access Twenty CRM.


Configuration
Exposing Twenty CRM to External Access
By default, Twenty runs on localhost at port 3000. If you want to expose it to external access, you need to configure the SERVER_URL in your .env file.

Understanding the SERVER_URL
Protocol: Use http or https, depending on whether you have SSL configured.
Domain/IP: Set this to the domain name or IP address where your application will be accessible.
Port: Include the port number if you're not using the default ports (80 for http, 443 for https).

Examples:
Direct access without SSL:

SERVER_URL=http://123.45.67.89:3000
Access via domain with SSL:
Enter fullscreen mode Exit fullscreen mode
SERVER_URL=https://mytwentyapp.com
Enter fullscreen mode Exit fullscreen mode

Once updated, restart the containers for changes to take effect:

docker-compose down
docker-compose up -d
Enter fullscreen mode Exit fullscreen mode

Troubleshooting
Unable to Log In
If you encounter login issues, try the following commands:

docker exec -it twenty-server-1 yarn
docker exec -it twenty-server-1 npx nx database:reset
Enter fullscreen mode Exit fullscreen mode

Then, restart the containers:

docker-compose down
docker-compose up -d
Enter fullscreen mode Exit fullscreen mode

Connection Issues Behind a Reverse Proxy
Make sure the SERVER_URL in your .env file matches the external access URL. Also, ensure your reverse proxy settings are properly configured to forward requests to the Twenty server, and restart both the reverse proxy and the Twenty containers.

Persistence and Data Volumes
The Docker Compose configuration automatically uses volumes to persist data for the database and server storage. This ensures your data remains intact, even if the containers are stopped or restarted.

Conclusion
Setting up Twenty CRM with Docker Compose is straightforward and efficient, whether you’re self-hosting or deploying in a production environment. By following the steps in this guide, you’ll have a fully functioning CRM in no time, with complete control over your data and infrastructure.

Give it a try, and experience Twenty CRM that grows with your business!

Thanks for reading! I hope you found this guide helpful. If you have any questions or run into issues, feel free to reach out to the Twenty CRM community for support. Cheers!

Top comments (0)