Install Twenty using Docker on Macbook

Hello I would like to install Twenty on my laptop (Mac) for local use. I never used Docker, but I already setup some "old style" servers. So I installed Docker Desktop and I pulled the three main images: server, front and postgres. When I launch the server, I have the following error: Error: connect ECONNREFUSED 127.0.0.1:5432 Obviously it is normal, as I did not setup any user/pwd for postgres. I saw that I need to create a ".env" config file, but I don't know where I put this file in Docker desktop. Could you help me? Thanks a lot
51 Replies
greg [iero]
greg [iero]9mo ago
Et Bravo @charles pour cet outil, sounds awesome OK nevermind, I installed using yarn and it works.
charles
charles9mo ago
Sorry about the slow response! Sounds good 🙂 (Your .env file needed to be created in your twenty-server folder, it is not specific to docker)
greg [iero]
greg [iero]9mo ago
No problem, I'm not used to play with docker and I did not find this folder. Yarn was easier with my skills 🙂
charles
charles9mo ago
perfect! we started with Docker but figured out it was easier for everybody to use yarn directly
greg [iero]
greg [iero]9mo ago
Because I need graphql, I try to go using docker. I propose to update the documentation after that 🙂 Here is what I used: Launch database with a port bidding to be able to backup run --name twenty-postgres -e POSTGRES_USER=twenty -e ALLOW_EMPTY_PASSWORD=yes -p 5432:5432 -d twentycrm/twenty-postgres:latest Is it a good thing to use ALLOW_EMPTY_PASSWORD or do I need to setup a password here? I setup ~/twenty/.env file:
PG_DATABASE_URL=postgres://twenty:twenty@postgres:5432/default
FRONT_BASE_URL=http://localhost:3001
ACCESS_TOKEN_SECRET=random_string_access
LOGIN_TOKEN_SECRET=random_string_login
REFRESH_TOKEN_SECRET=random_string_refresh
SIGN_IN_PREFILLED=false
PG_DATABASE_URL=postgres://twenty:twenty@postgres:5432/default
FRONT_BASE_URL=http://localhost:3001
ACCESS_TOKEN_SECRET=random_string_access
LOGIN_TOKEN_SECRET=random_string_login
REFRESH_TOKEN_SECRET=random_string_refresh
SIGN_IN_PREFILLED=false
After, I launch the server : docker run --env-file ~twenty/.env --name twenty-server -d twentycrm/twenty-server But I get an error here:
[Nest] 1 - ERROR [TypeOrmModule] Unable to connect to the database (metadata). Retrying (1)...
Error: getaddrinfo ENOTFOUND postgres
[Nest] 1 - ERROR [TypeOrmModule] Unable to connect to the database (metadata). Retrying (1)...
Error: getaddrinfo ENOTFOUND postgres
I suspect I'm not using .env the right way. Any idea how to proceed? ok, it almost works compose.yaml
version: "3.9"
services:

twenty-front:
image: twentycrm/twenty-front:${TAG}
ports:
- 3001:3000
environment:
- SIGN_IN_PREFILLED=${SIGN_IN_PREFILLED}
- REACT_APP_SERVER_BASE_URL=${LOCAL_SERVER_URL}
- REACT_APP_SERVER_AUTH_URL=${LOCAL_SERVER_URL}/auth
- REACT_APP_SERVER_FILES_URL ${LOCAL_SERVER_URL}/files
depends_on:
- twenty-back

twenty-back:
image: twentycrm/twenty-server:${TAG}
ports:
- 3000:3000
environment:
- SIGN_IN_PREFILLED=${SIGN_IN_PREFILLED}
- PG_DATABASE_URL=${PG_DATABASE_URL}
- FRONT_BASE_URL=${FRONT_BASE_URL}
- PORT=3000
- STORAGE_TYPE=local
- STORAGE_LOCAL_PATH=.local-storage
- ACCESS_TOKEN_SECRET=${ACCESS_TOKEN_SECRET}
- LOGIN_TOKEN_SECRET=${LOGIN_TOKEN_SECRET}
- REFRESH_TOKEN_SECRET=${REFRESH_TOKEN_SECRET}
depends_on:
- twenty-db

twenty-db:
image: twentycrm/twenty-postgres:${TAG}
volumes:
- twenty-db-data:/var/lib/postgresql/data
ports:
- 5432:5432
environment:
- POSTGRESQL_USER=${POSTGRES_USER}
- POSTGRESQL_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRESQL_DB=default

volumes:
twenty-db-data:
version: "3.9"
services:

twenty-front:
image: twentycrm/twenty-front:${TAG}
ports:
- 3001:3000
environment:
- SIGN_IN_PREFILLED=${SIGN_IN_PREFILLED}
- REACT_APP_SERVER_BASE_URL=${LOCAL_SERVER_URL}
- REACT_APP_SERVER_AUTH_URL=${LOCAL_SERVER_URL}/auth
- REACT_APP_SERVER_FILES_URL ${LOCAL_SERVER_URL}/files
depends_on:
- twenty-back

twenty-back:
image: twentycrm/twenty-server:${TAG}
ports:
- 3000:3000
environment:
- SIGN_IN_PREFILLED=${SIGN_IN_PREFILLED}
- PG_DATABASE_URL=${PG_DATABASE_URL}
- FRONT_BASE_URL=${FRONT_BASE_URL}
- PORT=3000
- STORAGE_TYPE=local
- STORAGE_LOCAL_PATH=.local-storage
- ACCESS_TOKEN_SECRET=${ACCESS_TOKEN_SECRET}
- LOGIN_TOKEN_SECRET=${LOGIN_TOKEN_SECRET}
- REFRESH_TOKEN_SECRET=${REFRESH_TOKEN_SECRET}
depends_on:
- twenty-db

twenty-db:
image: twentycrm/twenty-postgres:${TAG}
volumes:
- twenty-db-data:/var/lib/postgresql/data
ports:
- 5432:5432
environment:
- POSTGRESQL_USER=${POSTGRES_USER}
- POSTGRESQL_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRESQL_DB=default

volumes:
twenty-db-data:
.env file:
TAG=latest
PG_DATABASE_URL=postgres://twenty:XXXXX@twenty-db:5432/default

FRONT_BASE_URL=http://localhost:3001
LOCAL_SERVER_URL=http://localhost:3000

ACCESS_TOKEN_SECRET=XXXXX
LOGIN_TOKEN_SECRET=XXXXX
REFRESH_TOKEN_SECRET=XXXXX
SIGN_IN_PREFILLED=false

POSTGRES_USER=twenty
#POSTGRES_PASSWORD=twenty
POSTGRES_PASSWORD=XXXXX
POSTGRES_ADMIN_PASSWORD=XXXXX
TAG=latest
PG_DATABASE_URL=postgres://twenty:XXXXX@twenty-db:5432/default

FRONT_BASE_URL=http://localhost:3001
LOCAL_SERVER_URL=http://localhost:3000

ACCESS_TOKEN_SECRET=XXXXX
LOGIN_TOKEN_SECRET=XXXXX
REFRESH_TOKEN_SECRET=XXXXX
SIGN_IN_PREFILLED=false

POSTGRES_USER=twenty
#POSTGRES_PASSWORD=twenty
POSTGRES_PASSWORD=XXXXX
POSTGRES_ADMIN_PASSWORD=XXXXX
and launch with: docker-compose up -d
charles
charles9mo ago
you should have one .env in twenty-server and one .env in twenty-front (from the docs Step 2: https://docs.twenty.com/start/local-setup/docker-setup)
Welcome | Twenty - Documentation
Twenty is a CRM designed to fit your unique business needs.
charles
charles9mo ago
also, do not use twenty as your container postgres user, it needs to stay "postgres" while the container is initializing (make sure to drop the data so the init.sql script is indeed executed), it will create the "twenty" super user by itself
greg [iero]
greg [iero]9mo ago
Erk. Ok I ve done a docker-compose down and restarted with postgres instead of twenty and I get in twenty-postgres log:
FATAL: password authentication failed for user "twenty"
FATAL: password authentication failed for user "twenty"
I'll try a clean install.
charles
charles9mo ago
yes, make sure that your container postgres user (the one used to boot the postgres container is "postgres") twenty user should be created later during the docker boot while running the init.sql script @iero let's discuss here make sure to drop your twenty-postgres container + the associated volumes Then make sure to provide "postgres" as the default POSTGRES_USER when you run your docker container Once done, could you paste your docker logs here?
greg [iero]
greg [iero]9mo ago
OK, ti drop the container, I just need to do
iero@endor ~/Twenty % docker-compose down [16:53:11]
[+] Running 4/4
✔ Container twenty-twenty-front-1 Removed 0.5s
✔ Container twenty-twenty-back-1 Removed 0.0s
✔ Container twenty-twenty-db-1 Removed 0.2s
✔ Network twenty_default Removed
iero@endor ~/Twenty % docker-compose down [16:53:11]
[+] Running 4/4
✔ Container twenty-twenty-front-1 Removed 0.5s
✔ Container twenty-twenty-back-1 Removed 0.0s
✔ Container twenty-twenty-db-1 Removed 0.2s
✔ Network twenty_default Removed
charles
charles9mo ago
you also need to drop the volumes what do you have in docker volumes?
greg [iero]
greg [iero]9mo ago
OK, I removed all containers and volumes
greg [iero]
greg [iero]9mo ago
I just have those images
No description
greg [iero]
greg [iero]9mo ago
the first one is from the git and others from the compose.yaml above Here is my .env
TAG=latest

PG_DATABASE_URL=postgres://twenty:PWD1@twenty-db:5432/default

FRONT_BASE_URL=http://localhost:3001
LOCAL_SERVER_URL=http://localhost:3000

ACCESS_TOKEN_SECRET=PWD2
LOGIN_TOKEN_SECRET=PWD3
REFRESH_TOKEN_SECRET=PWD4
SIGN_IN_PREFILLED=false

POSTGRES_USER=postgres
POSTGRES_PASSWORD=PWD1
POSTGRES_ADMIN_PASSWORD=PWD1
TAG=latest

PG_DATABASE_URL=postgres://twenty:PWD1@twenty-db:5432/default

FRONT_BASE_URL=http://localhost:3001
LOCAL_SERVER_URL=http://localhost:3000

ACCESS_TOKEN_SECRET=PWD2
LOGIN_TOKEN_SECRET=PWD3
REFRESH_TOKEN_SECRET=PWD4
SIGN_IN_PREFILLED=false

POSTGRES_USER=postgres
POSTGRES_PASSWORD=PWD1
POSTGRES_ADMIN_PASSWORD=PWD1
charles
charles9mo ago
where is your .env located? Actually, I looked at your docker-compose, it should work :p could you up your docker-compose? what are the logs of twenty-postgres
greg [iero]
greg [iero]9mo ago
I have put here:
iero@endor ~/Twenty % pwd [17:02:07]
/Users/iero/Twenty

iero@endor ~/Twenty % ls -ahl [17:02:52]
total 40
drwxr-xr-x 7 iero staff 224B Feb 13 17:02 .
drwxr-x---+ 32 iero staff 1.0K Feb 13 17:02 ..
-rw-r--r-- 1 iero staff 12K Feb 13 17:01 .compose.yaml.swp
-rw-r--r-- 1 iero staff 2.1K Feb 13 13:16 .env
-rw-r--r-- 1 iero staff 1.1K Feb 13 13:30 compose.yaml
drwxr-xr-x 3 iero staff 96B Feb 13 09:58 server
drwxr-xr-x 29 iero staff 928B Feb 13 13:39 twenty
iero@endor ~/Twenty % pwd [17:02:07]
/Users/iero/Twenty

iero@endor ~/Twenty % ls -ahl [17:02:52]
total 40
drwxr-xr-x 7 iero staff 224B Feb 13 17:02 .
drwxr-x---+ 32 iero staff 1.0K Feb 13 17:02 ..
-rw-r--r-- 1 iero staff 12K Feb 13 17:01 .compose.yaml.swp
-rw-r--r-- 1 iero staff 2.1K Feb 13 13:16 .env
-rw-r--r-- 1 iero staff 1.1K Feb 13 13:30 compose.yaml
drwxr-xr-x 3 iero staff 96B Feb 13 09:58 server
drwxr-xr-x 29 iero staff 928B Feb 13 13:39 twenty
` I launch
iero@endor ~/Twenty % docker-compose up --build -d [17:04:02]
[+] Running 3/5
⠦ Network twenty_default Created 0.6s
⠦ Volume "twenty_twenty-db-data" Created 0.6s
✔ Container twenty-twenty-db-1 Started 0.3s
✔ Container twenty-twenty-back-1 Started 0.3s
✔ Container twenty-twenty-front-1 Started
iero@endor ~/Twenty % docker-compose up --build -d [17:04:02]
[+] Running 3/5
⠦ Network twenty_default Created 0.6s
⠦ Volume "twenty_twenty-db-data" Created 0.6s
✔ Container twenty-twenty-db-1 Started 0.3s
✔ Container twenty-twenty-back-1 Started 0.3s
✔ Container twenty-twenty-front-1 Started
charles
charles9mo ago
what are the logs of twenty-twenty-db-1 ?
charles
charles9mo ago
2024-02-13 17:04:14 2024-02-13 16:04:14.551 GMT [154] FATAL: password authentication failed for user "twenty" this is not normal how does your postgres container know about "twenty" user?
greg [iero]
greg [iero]9mo ago
Indeed that is why I'm lost 🙂 Because it was here before and he kept it somewhere ?
charles
charles9mo ago
is the compose.yml posted higher in the discussion still up-to-date?
greg [iero]
greg [iero]9mo ago
yes
version: "3.9"
services:

twenty-front:
image: twentycrm/twenty-front:${TAG}
ports:
- 3001:3000
environment:
- SIGN_IN_PREFILLED=${SIGN_IN_PREFILLED}
- REACT_APP_SERVER_BASE_URL=${LOCAL_SERVER_URL}
- REACT_APP_SERVER_AUTH_URL=${LOCAL_SERVER_URL}/auth
- REACT_APP_SERVER_FILES_URL ${LOCAL_SERVER_URL}/files
depends_on:
- twenty-back

twenty-back:
image: twentycrm/twenty-server:${TAG}
ports:
- 3000:3000
environment:
- SIGN_IN_PREFILLED=${SIGN_IN_PREFILLED}
- PG_DATABASE_URL=${PG_DATABASE_URL}
- FRONT_BASE_URL=${FRONT_BASE_URL}
- PORT=3000
- STORAGE_TYPE=local
- STORAGE_LOCAL_PATH=.local-storage
- ACCESS_TOKEN_SECRET=${ACCESS_TOKEN_SECRET}
- LOGIN_TOKEN_SECRET=${LOGIN_TOKEN_SECRET}
- REFRESH_TOKEN_SECRET=${REFRESH_TOKEN_SECRET}
depends_on:
- twenty-db

twenty-db:
image: twentycrm/twenty-postgres:${TAG}
volumes:
- twenty-db-data:/var/lib/postgresql/data
ports:
- 5432:5432
environment:
- POSTGRESQL_USER=${POSTGRES_USER}
- POSTGRESQL_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRESQL_DB=default

volumes:
twenty-db-data:
~
version: "3.9"
services:

twenty-front:
image: twentycrm/twenty-front:${TAG}
ports:
- 3001:3000
environment:
- SIGN_IN_PREFILLED=${SIGN_IN_PREFILLED}
- REACT_APP_SERVER_BASE_URL=${LOCAL_SERVER_URL}
- REACT_APP_SERVER_AUTH_URL=${LOCAL_SERVER_URL}/auth
- REACT_APP_SERVER_FILES_URL ${LOCAL_SERVER_URL}/files
depends_on:
- twenty-back

twenty-back:
image: twentycrm/twenty-server:${TAG}
ports:
- 3000:3000
environment:
- SIGN_IN_PREFILLED=${SIGN_IN_PREFILLED}
- PG_DATABASE_URL=${PG_DATABASE_URL}
- FRONT_BASE_URL=${FRONT_BASE_URL}
- PORT=3000
- STORAGE_TYPE=local
- STORAGE_LOCAL_PATH=.local-storage
- ACCESS_TOKEN_SECRET=${ACCESS_TOKEN_SECRET}
- LOGIN_TOKEN_SECRET=${LOGIN_TOKEN_SECRET}
- REFRESH_TOKEN_SECRET=${REFRESH_TOKEN_SECRET}
depends_on:
- twenty-db

twenty-db:
image: twentycrm/twenty-postgres:${TAG}
volumes:
- twenty-db-data:/var/lib/postgresql/data
ports:
- 5432:5432
environment:
- POSTGRESQL_USER=${POSTGRES_USER}
- POSTGRESQL_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRESQL_DB=default

volumes:
twenty-db-data:
~
charles
charles9mo ago
could you do docker volume ls ?
greg [iero]
greg [iero]9mo ago
iero@endor ~/Twenty % docker volume ls [17:06:13]
DRIVER VOLUME NAME
local 4bb99d3fcc69ee753c239c2aece15f43756746870484b3e6195fb91d673f9915
local 11506ddaf0fa0cc9b7b04c31031597684ec95fcaa8d7ea36baa72b6af9e21b67
local 696868b2331fd8904de7db3e2faf9321269cf29749e7a7f7b28d8a3aa171df24
local bc2a01a14b6575a2a234e1da1436863f9d53af2abc705f00a4fab25a58b5fa8d
local f0b23237957160b11c46bc41c5b9d74052315c95f9b7ff81bd82ee5073e996f5
local f3cf53931d6727ecc9857325ec58461013b6ebc8289ac8207cdc772f0d82861f
local twenty_twenty-db-data
iero@endor ~/Twenty % docker volume ls [17:06:13]
DRIVER VOLUME NAME
local 4bb99d3fcc69ee753c239c2aece15f43756746870484b3e6195fb91d673f9915
local 11506ddaf0fa0cc9b7b04c31031597684ec95fcaa8d7ea36baa72b6af9e21b67
local 696868b2331fd8904de7db3e2faf9321269cf29749e7a7f7b28d8a3aa171df24
local bc2a01a14b6575a2a234e1da1436863f9d53af2abc705f00a4fab25a58b5fa8d
local f0b23237957160b11c46bc41c5b9d74052315c95f9b7ff81bd82ee5073e996f5
local f3cf53931d6727ecc9857325ec58461013b6ebc8289ac8207cdc772f0d82861f
local twenty_twenty-db-data
something I noticed is that I use 'POSTGRESQL_PASSWORD' in the yaml file and not POSTGRES_PASSWORD be cause he asks me to set a password
charles
charles9mo ago
(i'm trying to replicate) ok, your postgres container can actually be fine could you ssh into your postgres container and run: psql -U twenty default
greg [iero]
greg [iero]9mo ago
I think that the server ask for the user twenty:
2024-02-13 17:06:39 [Nest] 1 - 02/13/2024, 4:06:39 PM LOG [InstanceLoader] EmailModule dependencies initialized +0ms
2024-02-13 17:06:39 [Nest] 1 - 02/13/2024, 4:06:39 PM LOG [InstanceLoader] AnalyticsModule dependencies initialized +0ms
2024-02-13 17:06:39 [Nest] 1 - 02/13/2024, 4:06:39 PM LOG [InstanceLoader] FileModule dependencies initialized +0ms
2024-02-13 17:06:39 [Nest] 1 - 02/13/2024, 4:06:39 PM ERROR [TypeOrmModule] Unable to connect to the database (core). Retrying (1)...
2024-02-13 17:06:39 error: password authentication failed for user "twenty"
2024-02-13 17:06:39 at Parser.parseErrorMessage (/app/node_modules/pg-protocol/dist/parser.js:287:98)
2024-02-13 17:06:39 at Parser.handlePacket (/app/node_modules/pg-protocol/dist/parser.js:126:29)
2024-02-13 17:06:39 at Parser.parse (/app/node_modules/pg-protocol/dist/parser.js:39:38)
2024-02-13 17:06:39 at Socket.<anonymous> (/app/node_modules/pg-protocol/dist/index.js:11:42)
2024-02-13 17:06:39 at Socket.emit (node:events:513:28)
2024-02-13 17:06:39 at Socket.emit (node:domain:489:12)
2024-02-13 17:06:39 at addChunk (node:internal/streams/readable:324:12)
2024-02-13 17:06:39 at readableAddChunk (node:internal/streams/readable:297:9)
2024-02-13 17:06:39 at Readable.push (node:internal/streams/readable:234:10)
2024-02-13 17:06:39 at TCP.onStreamRead (node:internal/stream_base_commons:190:23)
2024-02-13 17:06:39 [Nest] 1 - 02/13/2024, 4:06:39 PM LOG [InstanceLoader] EmailModule dependencies initialized +0ms
2024-02-13 17:06:39 [Nest] 1 - 02/13/2024, 4:06:39 PM LOG [InstanceLoader] AnalyticsModule dependencies initialized +0ms
2024-02-13 17:06:39 [Nest] 1 - 02/13/2024, 4:06:39 PM LOG [InstanceLoader] FileModule dependencies initialized +0ms
2024-02-13 17:06:39 [Nest] 1 - 02/13/2024, 4:06:39 PM ERROR [TypeOrmModule] Unable to connect to the database (core). Retrying (1)...
2024-02-13 17:06:39 error: password authentication failed for user "twenty"
2024-02-13 17:06:39 at Parser.parseErrorMessage (/app/node_modules/pg-protocol/dist/parser.js:287:98)
2024-02-13 17:06:39 at Parser.handlePacket (/app/node_modules/pg-protocol/dist/parser.js:126:29)
2024-02-13 17:06:39 at Parser.parse (/app/node_modules/pg-protocol/dist/parser.js:39:38)
2024-02-13 17:06:39 at Socket.<anonymous> (/app/node_modules/pg-protocol/dist/index.js:11:42)
2024-02-13 17:06:39 at Socket.emit (node:events:513:28)
2024-02-13 17:06:39 at Socket.emit (node:domain:489:12)
2024-02-13 17:06:39 at addChunk (node:internal/streams/readable:324:12)
2024-02-13 17:06:39 at readableAddChunk (node:internal/streams/readable:297:9)
2024-02-13 17:06:39 at Readable.push (node:internal/streams/readable:234:10)
2024-02-13 17:06:39 at TCP.onStreamRead (node:internal/stream_base_commons:190:23)
charles
charles9mo ago
yes, agree! but let's first make sure that your postgres is fine, then we can move to the server psql -U twenty default ==> it should ask you a password, which is "twenty"
greg [iero]
greg [iero]9mo ago
how do I ssh to the container ?
charles
charles9mo ago
if you are using Docker for Mac, click on your container and go to "Terminal" tab if you are not: docker exec -it {containerId} sh
greg [iero]
greg [iero]9mo ago
yes I use docker desktop on mac I'm in:
$ psql -U twenty default
Password for user twenty:
psql (15.5)
Type "help" for help.
$ psql -U twenty default
Password for user twenty:
psql (15.5)
Type "help" for help.
charles
charles9mo ago
No description
charles
charles9mo ago
great so you are fine let's move to the server container PG_DATABASE_URL=postgres://twenty:PWD1@twenty-db:5432/default make sure that PWD1 is actually "twenty"
greg [iero]
greg [iero]9mo ago
OK, I used another custom pwd
charles
charles9mo ago
ok, it might be it If you are hosting for production, you might want to change this password 😉 (actually you must :D)
greg [iero]
greg [iero]9mo ago
you want to update the password in .env file ?
charles
charles9mo ago
yes 🙂 then, docker compose stop, then up then, open a terminal in your twenty-server container and you can type "env" to make sure your env variables are properly set if it looks good, yarn database:reset and I would be interested to see the output
greg [iero]
greg [iero]9mo ago
I have in the .env:
PG_DATABASE_URL=postgres://twenty:twenty@twenty-db:5432/default

POSTGRES_USER=postgres
POSTGRES_PASSWORD=twenty
PG_DATABASE_URL=postgres://twenty:twenty@twenty-db:5432/default

POSTGRES_USER=postgres
POSTGRES_PASSWORD=twenty
charles
charles9mo ago
looks great! (you don't need POSTGRES_USER and POSTGRES_PASSWORD here, the server only cares about PG_DATABASE_URL)
greg [iero]
greg [iero]9mo ago
OK, I remove the lines and I restart no log yet, still running no error in db container, nothing in server and ready in front
charles
charles9mo ago
Let's go with yarn database:reset
greg [iero]
greg [iero]9mo ago
in server ?
charles
charles9mo ago
yes
greg [iero]
greg [iero]9mo ago
/app/packages/twenty-server # env
NODE_VERSION=18.16.0
HOSTNAME=a2c3c271d2f5
YARN_VERSION=1.22.19
SHLVL=1
FRONT_BASE_URL=http://localhost:3001
PORT=3000
HOME=/root
ACCESS_TOKEN_SECRET=PWD2
LOGIN_TOKEN_SECRET=PWD3
PG_DATABASE_URL=postgres://twenty:twenty@twenty-db:5432/default
STORAGE_TYPE=local
TERM=xterm
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
REFRESH_TOKEN_SECRET=PWD4
STORAGE_LOCAL_PATH=.local-storage
SIGN_IN_PREFILLED=false
PWD=/app/packages/twenty-server
/app/packages/twenty-server # env
NODE_VERSION=18.16.0
HOSTNAME=a2c3c271d2f5
YARN_VERSION=1.22.19
SHLVL=1
FRONT_BASE_URL=http://localhost:3001
PORT=3000
HOME=/root
ACCESS_TOKEN_SECRET=PWD2
LOGIN_TOKEN_SECRET=PWD3
PG_DATABASE_URL=postgres://twenty:twenty@twenty-db:5432/default
STORAGE_TYPE=local
TERM=xterm
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
REFRESH_TOKEN_SECRET=PWD4
STORAGE_LOCAL_PATH=.local-storage
SIGN_IN_PREFILLED=false
PWD=/app/packages/twenty-server
Sounds good:
/app/packages/twenty-server # yarn database:reset
Performed 'Dropping all schemas...' successfully
npm notice
npm notice New major version of npm available! 9.5.1 -> 10.4.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v10.4.0
npm notice Run npm install -g [email protected] to update!
npm notice
Performed 'create schema "public"' successfully
Performed 'create schema "metadata"' successfully
Performed 'create schema "core"' successfully
Performed 'create extension pg_graphql' successfully
Performed 'create extension "uuid-ossp"' successfully
Performed 'create extension "postgres_fdw"' successfully
Performed 'create extension "wrappers"' successfully
Performed 'create extension "mysql_fdw"' successfully
Performed 'create airtable "wrappers"' successfully
Performed 'create bigQuery "wrappers"' successfully
Performed 'create clickHouse "wrappers"' successfully
Performed 'create firebase "wrappers"' successfully
Performed 'create logflare "wrappers"' successfully
Performed 'create s3 "wrappers"' successfully
Performed 'create stripe "wrappers"' successfully
Performed 'inflect names for graphql' successfully
Performed 'create function graphql' successfully
query: SELECT * FROM current_schema()
(...)
[Nest] 328 - 02/13/2024, 4:33:11 PM LOG [WorkspaceSyncMetadataService] Syncing standard objects and fields metadata
[Nest] 328 - 02/13/2024, 4:33:11 PM LOG [WorkspaceSyncMetadataService] Syncing standard objects and fields metadata
[Nest] 328 - 02/13/2024, 4:33:11 PM LOG [WorkspaceSyncObjectMetadataService] Comparing standard objects and fields metadata
[Nest] 328 - 02/13/2024, 4:33:11 PM LOG [WorkspaceSyncObjectMetadataService] Updating workspace metadata
[Nest] 328 - 02/13/2024, 4:33:11 PM LOG [WorkspaceSyncObjectMetadataService] Generating migrations
[Nest] 328 - 02/13/2024, 4:33:11 PM LOG [WorkspaceSyncObjectMetadataService] Saving migrations
/app/packages/twenty-server # yarn database:reset
Performed 'Dropping all schemas...' successfully
npm notice
npm notice New major version of npm available! 9.5.1 -> 10.4.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v10.4.0
npm notice Run npm install -g [email protected] to update!
npm notice
Performed 'create schema "public"' successfully
Performed 'create schema "metadata"' successfully
Performed 'create schema "core"' successfully
Performed 'create extension pg_graphql' successfully
Performed 'create extension "uuid-ossp"' successfully
Performed 'create extension "postgres_fdw"' successfully
Performed 'create extension "wrappers"' successfully
Performed 'create extension "mysql_fdw"' successfully
Performed 'create airtable "wrappers"' successfully
Performed 'create bigQuery "wrappers"' successfully
Performed 'create clickHouse "wrappers"' successfully
Performed 'create firebase "wrappers"' successfully
Performed 'create logflare "wrappers"' successfully
Performed 'create s3 "wrappers"' successfully
Performed 'create stripe "wrappers"' successfully
Performed 'inflect names for graphql' successfully
Performed 'create function graphql' successfully
query: SELECT * FROM current_schema()
(...)
[Nest] 328 - 02/13/2024, 4:33:11 PM LOG [WorkspaceSyncMetadataService] Syncing standard objects and fields metadata
[Nest] 328 - 02/13/2024, 4:33:11 PM LOG [WorkspaceSyncMetadataService] Syncing standard objects and fields metadata
[Nest] 328 - 02/13/2024, 4:33:11 PM LOG [WorkspaceSyncObjectMetadataService] Comparing standard objects and fields metadata
[Nest] 328 - 02/13/2024, 4:33:11 PM LOG [WorkspaceSyncObjectMetadataService] Updating workspace metadata
[Nest] 328 - 02/13/2024, 4:33:11 PM LOG [WorkspaceSyncObjectMetadataService] Generating migrations
[Nest] 328 - 02/13/2024, 4:33:11 PM LOG [WorkspaceSyncObjectMetadataService] Saving migrations
charles
charles9mo ago
Looks great!
greg [iero]
greg [iero]9mo ago
I don't see any error
charles
charles9mo ago
All good?
greg [iero]
greg [iero]9mo ago
I try to connect, fingers crossed All good! Merci beaucoup for taking the time to help me on this setup! For the future, how do I update the system? I do docker-compose pull and be sure to backup using psql_dump before? I started to play with the API before the crash and it is not very complex to refill the database with it if I have a good backup. I just have to backup the datamodel somehow
charles
charles9mo ago
Right now we don't have a bullet proof way of updating the database schema, we are likely to write about it on the twenty docs in the upcoming weeks The idea we have is the following: - you can update front and server code by pulling the latest images (so updating version in your docker-compose) - then you need to update database core, metadata schema (regular typeorm migrations) + update your workspace schema (which is ruled by your metadata to model your own busienss). We are preparing a set of commands to do that, we are already trying them in production, they work pretty well but are not ready to use yet I would say upgrading to the latest version is hard right now, should be OK in a few weeks and easy in a few months once we've figured out all the details the good thing is that we design our cloud as if it was self hosted, so the tools we build for the cloud will work for self hosted versions 🙂 If you want to look in the code, the commands are: - yarn typeorm:migrate (to migrate core and metadata) - yarn command workspace:health (check that your workspace schema is healthy) - yarn command workspace:sync-metadata (migrate it to the latest version) Will share a bit more about these later
greg [iero]
greg [iero]9mo ago
Great thanks Charles, I learned a lot today ! I will start to adapt the datamodel, fill the database and do backups. My data is mostly on Obsidian and PSQL db, so the API wil be great to do the transfer. I will check regularly and wait for when you will be ready to be sure I do not break everything too soon 🙂
charles
charles9mo ago
sound good! Happy that you can self host Twenty and play with it!
greg [iero]
greg [iero]8mo ago
Just for the record, if I don't have the two lines here, I get this warning:
% docker-compose up --build -d [21:34:52]
WARN[0000] The "POSTGRES_USER" variable is not set. Defaulting to a blank string.
WARN[0000] The "POSTGRES_PASSWORD" variable is not set. Defaulting to a blank string.
[+] Running 3/5
⠦ Network twenty_default Created 1.6s
⠴ Volume "twenty_twenty-db-data" Created 1.5s
✔ Container twenty-twenty-db-1 Started 1.0s
✔ Container twenty-twenty-back-1 Started 1.1s
✔ Container twenty-twenty-front-1 Started
% docker-compose up --build -d [21:34:52]
WARN[0000] The "POSTGRES_USER" variable is not set. Defaulting to a blank string.
WARN[0000] The "POSTGRES_PASSWORD" variable is not set. Defaulting to a blank string.
[+] Running 3/5
⠦ Network twenty_default Created 1.6s
⠴ Volume "twenty_twenty-db-data" Created 1.5s
✔ Container twenty-twenty-db-1 Started 1.0s
✔ Container twenty-twenty-back-1 Started 1.1s
✔ Container twenty-twenty-front-1 Started
Want results from more Discord servers?
Add your server