mirror of
https://github.com/lingble/twenty.git
synced 2025-10-29 20:02:29 +00:00
* Update scripts and documentation to use nx and new monorepo architecture * Start fixing docker * Migrate eslint plugin and postgres setup * Fix docker * Fix patches * Fix * fix: wip try to fix the patches * Apply patches --------- Co-authored-by: Jérémy Magrin <jeremy.magrin@gmail.com>
135 lines
4.0 KiB
Plaintext
135 lines
4.0 KiB
Plaintext
---
|
|
title: Docker Setup
|
|
sidebar_position: 3
|
|
description: Set up the project with Docker
|
|
sidebar_custom_props:
|
|
icon: TbBrandDocker
|
|
---
|
|
|
|
import Tabs from '@theme/Tabs';
|
|
import TabItem from '@theme/TabItem';
|
|
|
|
This guide will walk you through provisioning the project with Docker. This comes with the following advantages:
|
|
- It provides the exact same environment as the core development team.
|
|
- It includes some extra dependencies (such as `playwright`) that you might need if you wish to contribute to some advanced areas of the project.
|
|
- It provisions a PostgreSQL database.
|
|
|
|
:::info
|
|
Avoid setting up the project with Docker if you are a Windows (WSL) user, unless you have experience with it, as it will make troubleshooting harder.
|
|
If you are a Windows user, it's better to use the [yarn installation](/contributor/local-setup/yarn-setup).
|
|
:::
|
|
|
|
## Prerequisites
|
|
|
|
Make sure you have the latest [Docker](https://docs.docker.com/get-docker/) and [git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) versions installed on your computer.
|
|
|
|
You can run `docker --version` to verify the installation.
|
|
|
|
## Step 1: Git Clone
|
|
|
|
In your terminal, run the following command:
|
|
|
|
:::info Note
|
|
|
|
It's better to use SSH for this step. If you already haven't set up SSH keys, please do so first. You can learn more about it [here](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/about-ssh).
|
|
|
|
:::
|
|
|
|
<Tabs>
|
|
<TabItem value="ssh" label="SSH (Recommended)" default>
|
|
|
|
```bash
|
|
git clone git@github.com:twentyhq/twenty.git
|
|
```
|
|
</TabItem>
|
|
<TabItem value="https" label="HTTPS" >
|
|
|
|
```bash
|
|
git clone https://github.com/twentyhq/twenty.git
|
|
```
|
|
|
|
</TabItem>
|
|
</Tabs>
|
|
|
|
## Step 2: Setup environment variables
|
|
|
|
You need to set some environment variables before you can work on the project. Locally, it's better to set them through `.env` files.
|
|
|
|
```bash
|
|
cd twenty
|
|
cp ./packages/twenty-front/.env.example ./packages/twenty-front/.env
|
|
cp ./packages/twenty-server/.env.example ./packages/twenty-server/.env
|
|
```
|
|
|
|
The default values should work out of the box, except for the postgres URL, which requires a small modification.
|
|
|
|
Open `./packages/twenty-server/.env` and change to the following:
|
|
|
|
```bash
|
|
PG_DATABASE_URL=postgres://twenty:twenty@postgres:5432/default?connection_limit=1
|
|
```
|
|
|
|
|
|
## Step 3: Build
|
|
|
|
The project includes an environment containerized with Docker and orchestrated with `docker-compose`.
|
|
This installation method will also provision a PostgreSQL container.
|
|
|
|
|
|
```bash
|
|
make -C packages/twenty-docker dev-build
|
|
```
|
|
|
|
## Step 4: Migrate & seed
|
|
|
|
Before running the project, you need to initialize the database by running the migrations and seed.
|
|
|
|
Start the containers:
|
|
```bash
|
|
make -C packages/twenty-docker dev-up
|
|
```
|
|
|
|
Setup database, run migrations, and seed:
|
|
```bash
|
|
make -C packages/twenty-docker dev-server-database-init
|
|
```
|
|
|
|
## Step 5: Start Twenty
|
|
|
|
Run the project with the following commands from the `root` folder:
|
|
|
|
```bash
|
|
make -C packages/twenty-docker dev-server-start
|
|
```
|
|
|
|
```bash
|
|
make -C packages/twenty-docker dev-front-start
|
|
```
|
|
|
|
You should now have:
|
|
- **Frontend** available on: [http://localhost:3001](http://localhost:3001)
|
|
- **Server** available on: [http://localhost:3000/graphql](http://localhost:3000/graphql)
|
|
- **Postgres** available on [http://localhost:5432](http://localhost:5432) and containing database named `default`
|
|
|
|
Sign in using a seeded demo account `tim@apple.dev` (password: `Applecar2025`) to start using Twenty.
|
|
|
|
### Optional
|
|
|
|
If you don't want to use the `make` command and work directly from the container, you can also ssh directly into the container:
|
|
|
|
```bash
|
|
make -C packages/twenty-docker dev-sh
|
|
```
|
|
Then run commands through yarn and nx:
|
|
```bash
|
|
yarn nx run twenty-server:database:init
|
|
```
|
|
|
|
|
|
### Troubleshooting
|
|
|
|
#### Docker throws errors while setting up local environment
|
|
|
|
If by any chance you run into problems with Docker, you should change the `docker-compose` to `docker compose` in `./infra/dev/Makefile` as `docker-compose` is an old version
|
|
that's becoming obsolete. (You can find more info [here](https://docs.docker.com/compose/migrate/))
|