diogomatoschaves / MyCryptoBot

Open source crypto trading platform to automate trading strategies.
120 stars 25 forks source link

Database does not exist with docker #175

Closed weilinear closed 8 months ago

weilinear commented 8 months ago

Thanks for the great project. I'm running it on my windows machine and followed INSTALLATION.md. I'm having issues with the db container.

I'm trying the following on

psql -U $POSTGRES_USER
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL:  database "testuser" does not exist

I cannot login to the dashboard either.

Here is my .env file

POSTGRES_DB=test
POSTGRES_USER=testuser
POSTGRES_PASSWORD=testpwd
SECRET_KEY=testsecret
BINANCE_API_KEY=
BINANCE_API_SECRET=
BINANCE_API_KEY_TEST=blabla
BINANCE_API_SECRET_TEST=blabla
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_BUCKET=
USE_CLOUD_STORAGE=false

I'm running with current head version: 15beceab1a439b709be7e19d9fc237e35813bd81. The only change I made is in the docker compose as I'm always getting an error on postgresql as it complains /var/lib/postgresql/data is not empty because of postgresql.conf file.

-      - ./database/local_db:/var/lib/postgresql/data
-      - ./database/local_db/custom_postgresql.conf:/var/lib/postgresql/data/postgresql.conf
+      - ./local_db:/var/lib/postgresql/data
+      - ./database/local_db/custom_postgresql.conf:/etc/postgresql.conf
diogomatoschaves commented 8 months ago

Hey @weilinear, thanks for the feedback 🙌. You're right, as it was now it was generating conflicts as some files were already in the local_db folder. Also, I've changed the default POSTGRES_USER and POSTGRES_PASSWORD to postgres, as that avoids conflicts within the container. Let me know if it works now ✌️

weilinear commented 8 months ago

Thanks for the quick action. Another point, the DB works but dashboard still doesn't seem to work for me. It gave me as error that

Something went wrong... Check server logs.

I researched a bit and it might be related to the creattesuperuser is assuming "default" as the postgres datadb name. This seems to solve the issue.

diogomatoschaves commented 8 months ago

@weilinear where exactly is that error showing up? When the dashboard app is compiling?

weilinear commented 8 months ago

When I tried to login to the dashboard (after input username/password)

diogomatoschaves commented 8 months ago

I was not able to reproduce that issue, but glad to know you were able to solve it 👌