mujx / hakatime

Wakatime server implementation & analytics dashboard
https://hakatime.mtx-dev.xyz
The Unlicense
631 stars 47 forks source link

When running in docker-compose I cannot register a user #1

Closed stsg closed 4 years ago

stsg commented 4 years ago

When running in docker-compose I cannot register a new user.

haka_server docker log:

haka_srv | 172.18.0.1 - - [05/Jul/2020:08:04:48 +0000] "GET / HTTP/1.1" 304 - "" "Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0" haka_srv | [2020-07-05 08:04:49][hakatime.server][Error][f44f148a32c1][PID 1][ThreadId 18][hakatime-0.1.0-inplace-libhaka:Haka.Authentication src/Haka/Authentication.hs:212:9] MissingRefreshTokenCookie haka_srv | 172.18.0.1 - - [05/Jul/2020:08:04:48 +0000] "GET /css/main.46b5bf35.css HTTP/1.1" 304 - "http://localhost:8080/" "Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0" haka_srv | 172.18.0.1 - - [05/Jul/2020:08:04:48 +0000] "GET /js/js.e53cf039.js HTTP/1.1" 304 - "http://localhost:8080/" "Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0" haka_srv | 172.18.0.1 - - [05/Jul/2020:08:04:48 +0000] "GET /css/js.2554af42.css HTTP/1.1" 304 - "http://localhost:8080/" "Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0" haka_srv | 172.18.0.1 - - [05/Jul/2020:08:04:48 +0000] "POST /auth/refresh_token HTTP/1.1" 400 - "http://localhost:8080/" "Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0" haka_srv | 172.18.0.1 - - [05/Jul/2020:08:04:48 +0000] "GET /nunito-latin-400.3a5373d7.woff2 HTTP/1.1" 304 - "http://localhost:8080/css/js.2554af42.css" "Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0" haka_srv | [2020-07-05 08:04:57][hakatime.server][Error][f44f148a32c1][PID 1][ThreadId 18][hakatime-0.1.0-inplace-libhaka:Haka.Authentication src/Haka/Authentication.hs:212:9] MissingRefreshTokenCookie haka_srv | 172.18.0.1 - - [05/Jul/2020:08:04:57 +0000] "POST /auth/refresh_token HTTP/1.1" 400 - "http://localhost:8080/" "Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0" haka_srv | [2020-07-05 08:05:11][hakatime.server][Error][f44f148a32c1][PID 1][ThreadId 18][hakatime-0.1.0-inplace-libhaka:Haka.Authentication src/Haka/Authentication.hs:191:9] UsernameExists "relation \"users\" does not exist" haka_srv | 172.18.0.1 - - [05/Jul/2020:08:05:11 +0000] "POST /auth/register HTTP/1.1" 409 - "http://localhost:8080/" "Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0" haka_srv | [2020-07-05 08:05:25][hakatime.server][Error][f44f148a32c1][PID 1][ThreadId 18][hakatime-0.1.0-inplace-libhaka:Haka.Authentication src/Haka/Authentication.hs:191:9] UsernameExists "relation \"users\" does not exist" haka_srv | 172.18.0.1 - - [05/Jul/2020:08:05:25 +0000] "POST /auth/register HTTP/1.1" 409 - "http://localhost:8080/" "Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0"

haka_db docker log: haka_db | 2020-07-05 08:05:11.777 UTC [53] ERROR: relation "users" does not exist at character 22 haka_db | 2020-07-05 08:05:11.777 UTC [53] STATEMENT: haka_db | INSERT INTO users haka_db | ( haka_db | username, haka_db | hashed_password, haka_db | salt_used haka_db | ) haka_db | VALUES ( $1, $2, $3 ); haka_db | haka_db | 2020-07-05 08:05:25.912 UTC [55] ERROR: relation "users" does not exist at character 22 haka_db | 2020-07-05 08:05:25.912 UTC [55] STATEMENT: haka_db | INSERT INTO users haka_db | ( haka_db | username, haka_db | hashed_password, haka_db | salt_used haka_db | ) haka_db | VALUES ( $1, $2, $3 ); haka_db | haka_db | 2020-07-05 08:17:13.395 UTC [78] ERROR: relation "users" does not exist at character 22 haka_db | 2020-07-05 08:17:13.395 UTC [78] STATEMENT: haka_db | INSERT INTO users haka_db | ( haka_db | username, haka_db | hashed_password, haka_db | salt_used haka_db | ) haka_db | VALUES ( $1, $2, $3 ); haka_db | haka_db | 2020-07-05 08:19:29.416 UTC [84] ERROR: relation "users" does not exist at character 22 haka_db | 2020-07-05 08:19:29.416 UTC [84] STATEMENT: haka_db | INSERT INTO users haka_db | ( haka_db | username, haka_db | hashed_password, haka_db | salt_used haka_db | ) haka_db | VALUES ( $1, $2, $3 ); haka_db |

Screenshot from 2020-07-05 11-21-42

mujx commented 4 years ago

Did you use the following command to start the services:

docker-compose -f docker-compose-deploy.yml up

It seems like your database doesn't have the necessary tables created.

mujx commented 4 years ago

@stsg Any updates on this?

stsg commented 4 years ago

@mujx The problem is not solved yet, I've started your docker image using docker-compose up -d with attached docker-compose.yml. What am I doing wrong? docker-compose.yml.txt

mujx commented 4 years ago

You have the following:

 haka_db:                                                                                                                                                                                                    
      image: postgres:11-alpine                                                                                                                                                                               
      container_name: haka_db                                                                                                                                                                                 
      environment:                                                                                                                                                                                            
          POSTGRES_DB: test                                                                                                                                                                                   
          POSTGRES_PASSWORD: test                                                                                                                                                                             
          POSTGRES_USER: test                                                                                                                                                                                 
      volumes:                                                                                                                                                                                                
          - ./haka/docker/:/docker-entrypoint-initdb.d/                                                                                                                                                       
          - deploy_db_data:/var/lib/postgresql/data             

Probably the ./haka/docker directory doesn't contain the files (https://github.com/mujx/hakatime/tree/master/docker) found in the repo. So you need to copy the contents to your directory.

Or try the following commands and it should work:

git clone https://github.com/mujx/hakatime
cd hakatime
docker-compose -f docker-compose-deploy.yml up
stsg commented 4 years ago

Thanks! It's okay now. I didn't really initialize the database ;)