T
Twentyβ€’9mo ago
greg [iero]

I replaced the server url in the test:

I replaced the server url in the test:
test: curl --fail http://${SERVER_URL}/healthz
test: curl --fail http://${SERVER_URL}/healthz
I'm not confortable with the POSTGRES_ADMIN_PASSWORD line without a password. I'm not familiar with this process. When is this password setup? Is it OK to update it after launching the first docker compose? It might be better to setup a password automaticaly. Maybe we could use this command to create a random password here:
LC_ALL=C tr -dc '[:graph:]' </dev/urandom | head -c 18; echo
LC_ALL=C tr -dc '[:graph:]' </dev/urandom | head -c 18; echo
40 Replies
Freebios
Freebiosβ€’9mo ago
Regarding the password, it's indeed a bit of an issue, but it's actually hardcoded for now in the postgres image, we could try to focus on that, or at least create an issue about it @charles The database should be isolated as long as no port is exposed in the docker compose πŸ™
greg [iero]
greg [iero]OPβ€’9mo ago
So this .env line is useless?
Freebios
Freebiosβ€’9mo ago
oh wait, I think i'm mistaking with something else, no you right, this one should be randomized ! it's the twenty:twenty user that is problematic
greg [iero]
greg [iero]OPβ€’9mo ago
πŸ‘ Makes more sense. You could randomize twenty:twenty during the database initiation step, but I don't see any database init in your script ?
Freebios
Freebiosβ€’9mo ago
GitHub
twenty/packages/twenty-postgres/init.sql at main Β· twentyhq/twenty
Building a modern alternative to Salesforce, powered by the community. - twentyhq/twenty
Freebios
Freebiosβ€’9mo ago
It's creating a superuser in order to be able to install pg extensions, it seems that the default root user created by bitnami as insuficient permisions
greg [iero]
greg [iero]OPβ€’9mo ago
Regarding URL, I added FRONT_BASE_URL in .env as I had this error:
server_1 | /app/packages/twenty-server/dist/src/utils/assert.js:12
server_1 | throw new Error(message);
server_1 | ^
server_1 |
server_1 | Error: An instance of EnvironmentVariables has failed the validation:
server_1 | - property FRONT_BASE_URL has failed the following constraints: isUrl
server_1 |
server_1 | at assert (/app/packages/twenty-server/dist/src/utils/assert.js:12:15)
server_1 | at Object.validate (/app/packages/twenty-server/dist/src/engine/integrations/environment/environment-variables.js:336:25)
server_1 | at ConfigModule.forRoot (/app/node_modules/@nestjs/config/dist/config.module.js:67:45)
server_1 | at Object.<anonymous> (/app/packages/twenty-server/dist/src/engine/integrations/environment/environment.module.js:17:35)
server_1 | at Module._compile (node:internal/modules/cjs/loader:1256:14)
server_1 | at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
server_1 | at Module.load (node:internal/modules/cjs/loader:1119:32)
server_1 | at Module._load (node:internal/modules/cjs/loader:960:12)
server_1 | at Module.require (node:internal/modules/cjs/loader:1143:19)
server_1 | at require (node:internal/modules/cjs/helpers:121:18)
server_1 | /app/packages/twenty-server/dist/src/utils/assert.js:12
server_1 | throw new Error(message);
server_1 | ^
server_1 |
server_1 | Error: An instance of EnvironmentVariables has failed the validation:
server_1 | - property FRONT_BASE_URL has failed the following constraints: isUrl
server_1 |
server_1 | at assert (/app/packages/twenty-server/dist/src/utils/assert.js:12:15)
server_1 | at Object.validate (/app/packages/twenty-server/dist/src/engine/integrations/environment/environment-variables.js:336:25)
server_1 | at ConfigModule.forRoot (/app/node_modules/@nestjs/config/dist/config.module.js:67:45)
server_1 | at Object.<anonymous> (/app/packages/twenty-server/dist/src/engine/integrations/environment/environment.module.js:17:35)
server_1 | at Module._compile (node:internal/modules/cjs/loader:1256:14)
server_1 | at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
server_1 | at Module.load (node:internal/modules/cjs/loader:1119:32)
server_1 | at Module._load (node:internal/modules/cjs/loader:960:12)
server_1 | at Module.require (node:internal/modules/cjs/loader:1143:19)
server_1 | at require (node:internal/modules/cjs/helpers:121:18)
Freebios
Freebiosβ€’9mo ago
The subtitution wasn't working ? FRONT_BASE_URL: ${FRONT_BASE_URL:-$SERVER_URL} In most configurations it should be the same as SERVER_URL, the only case where you would want it to differ is when you host the frontend on a bucket or some external service Just to make sure, do you use docker compose or docker-compose, i have a hard time understanding how these behavior occurs on version similar to mine 😳
greg [iero]
greg [iero]OPβ€’9mo ago
Nope it was not working. I have SERVER_URL=http://sgl.local:3000 FRONT_BASE_URL=http://sgl.local:3000 I used docker-compose
Freebios
Freebiosβ€’9mo ago
oh, can you run docker-compose version ?
greg [iero]
greg [iero]OPβ€’9mo ago
iero@sgl:~/twenty$ docker compose version Docker Compose version v2.25.0
Freebios
Freebiosβ€’9mo ago
and with docker-compose it's actually two different things
greg [iero]
greg [iero]OPβ€’9mo ago
Sorry iero@sgl:~/twenty$ docker-compose version docker-compose version 1.29.2, build unknown docker-py version: 5.0.3 CPython version: 3.10.12 OpenSSL version: OpenSSL 3.0.2 15 Mar 2022
Freebios
Freebiosβ€’9mo ago
I see now πŸ˜„ This one is one major behind 😡
greg [iero]
greg [iero]OPβ€’9mo ago
Ok I try to update it
Freebios
Freebiosβ€’9mo ago
The new standard would be to use docker compose plugin instead of the standalone docker-compose (i know it's twisted..), you could try to update the docker-compose https://docs.docker.com/compose/install/standalone/
Docker Documentation
Install Compose standalone
How to install Docker Compose - Other Scenarios
Freebios
Freebiosβ€’9mo ago
I bet most of the formating issues will be gone πŸ˜… In the one-liner we actually use docker compose that's why it might have failed on reboot, I suppose we could print a warning message if both are installed on the system and that the major is not >=2
greg [iero]
greg [iero]OPβ€’9mo ago
OK iero@sgl:~/twenty$ /usr/bin/docker-compose version Docker Compose version v2.26.0
Freebios
Freebiosβ€’9mo ago
It should be a smoother experience πŸ™‚
greg [iero]
greg [iero]OPβ€’9mo ago
It's strange, I have this error now..
greg [iero]
greg [iero]OPβ€’9mo ago
I restart the script from scratch
Freebios
Freebiosβ€’9mo ago
The migration script is using a flag in the /app/${STORAGE_LOCAL_PATH:-.local-storage} path to know if it has seeded the database already, if it got interrupted before writting the flag on the disk you might get a few errors, I don't know if it's breaking anything though
greg [iero]
greg [iero]OPβ€’9mo ago
OK @Freebios I removed everything and started fro scratch. It works smoothly now. So, maybe : - check docker compose version before launching the steps - Add a random password in .env POSTGRES_ADMIN_PASSWORD - Ask for server name and propose localhost per default - Use ${SERVER_URL} in healthcheck To expose the server, I just have to expose the 3000 port? No 3001 port anymore?
Freebios
Freebiosβ€’9mo ago
Yes the frontend is served by the backend now πŸ™‚
greg [iero]
greg [iero]OPβ€’9mo ago
Nice!
Freebios
Freebiosβ€’9mo ago
Use ${SERVER_URL} in healthcheck
Was it testing your physical server localhost instead of container one ? It should be a local healthcheck to make sure the container is started, if i put ${SERVER_URL} and that the reverse proxy is not well configured, the healthcheck could fail for no apparent reason I could use the container dns http://server:3000/healthz if localhost was an issue
greg [iero]
greg [iero]OPβ€’9mo ago
In fact it works, it just took time
Freebios
Freebiosβ€’9mo ago
Yeah the seeding might take time depending on your hardware, I could try to print server logs until it's ready so user sees that something is going on, or change the text for something like "Database initialization in progress, please be patient it can take a few minutes"
greg [iero]
greg [iero]OPβ€’9mo ago
Yes it's a good idea I will try to migrate my database and setup nginx with ssl to reach this server and I'm all good. Maybe the second part could be added in the script as well
Freebios
Freebiosβ€’9mo ago
@FΓ©lix What do you think? I would say that we could keep migration instructions in the documentation, like explaining how to load a database dump, but it could actually be usefull for people migrating their stack from one place to another to simply be able to inject an sql file without having to deal with docker volumes
greg [iero]
greg [iero]OPβ€’9mo ago
there is an actual documentation page for that? I don't see anything in the twenty documentation website
Freebios
Freebiosβ€’9mo ago
I don't think it exists yet, but if you are looking for some leads to do it in your case in the mean time, i would say you would need to docker compose exec -it db /bin/bash do a pg_dump and then docker compose cp ... ...
greg [iero]
greg [iero]OPβ€’9mo ago
OK, I planned to expose the database and do a pg_dump -U twenty -h server -p 5432 -F c default > db.tar but I never tried yet to restore it afterwards. I will do soon But good idea with exec. I have to expose the database as sometimes I have to manualy remove an action that broke the datamodel
Freebios
Freebiosβ€’9mo ago
to restore, either expose it, or cp the dump into the container and then connect using postgres and redirect the dump file into the session postgres -U twenty -h server -p 5432 < my_dump.sql (something like that)
greg [iero]
greg [iero]OPβ€’9mo ago
not pg_restore? I'll try it and confirm
Freebios
Freebiosβ€’9mo ago
oh, try pg_restore first πŸ˜… i got used to redirect by hand
greg [iero]
greg [iero]OPβ€’9mo ago
Erk my actual database is in 0.3.2. I do need to launch some migrate commands, afterwards right?
Freebios
Freebiosβ€’9mo ago
I would say so yes But I don't know twenty enough yet to tell you how πŸ˜„
Unknown User
Unknown Userβ€’9mo ago
Message Not Public
Sign In & Join Server To View
greg [iero]
greg [iero]OPβ€’9mo ago
OK I've tested the process and described the steps here: https://discord.com/channels/1130383047699738754/1222855378224676894/1222855378224676894 If you have corrections/improvements, I will be happy to test When in prod, I will do daily dump and regular restore to be sure I will not lose data. Another use case is to work on local setup when I'm in a plane or in a remote area without internet connection.
Want results from more Discord servers?
Add your server