Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to start the docker containers #31

Closed
Elamurugan-Nallathambi opened this issue Dec 15, 2021 · 4 comments
Closed

Unable to start the docker containers #31

Elamurugan-Nallathambi opened this issue Dec 15, 2021 · 4 comments
Labels
bug Something isn't working

Comments

@Elamurugan-Nallathambi
Copy link

Hello Yasser,

Thanks for this python API package, it looks really promising.

I was running through the following commands after cloning

        make pull
	make build
	make start 

Seeing this log on the app frdp container start

psycopg2.OperationalError: could not connect to server: Connection refused
        Is the server running on host "127.0.0.1" and accepting
        TCP/IP connections on port 5432?

The other services are running and here is the SS of services vs .env file setup.

Screen Shot 2021-12-15 at 3 37 11 AM

Screen Shot 2021-12-15 at 3 36 34 AM

Screen Shot 2021-12-15 at 3 36 07 AM

psql shows the DB list in this way, for the lack of understanding on how to get postgres to work properly am merely looking for some insight. Any help is really appreciate-able.

@yezz123 yezz123 added the bug Something isn't working label Dec 15, 2021
@yezz123
Copy link
Owner

yezz123 commented Dec 15, 2021

Let me share my default configuration with you

# Backend API
PROJECT_NAME= FRDP
DOMAIN= http://localhost:8080

# openssl rand -hex 32 - Generate secret key
SECRET_KEY= SecretKey
USERS_OPEN_REGISTRATION= true
EMAIL_RESET_TOKEN_EXPIRE_HOURS= 48

# Server Settings
SERVER_NAME= localhost
SERVER_HOST= http://localhost:8080

# Postgres default username and password
POSTGRES_USER= postgres
POSTGRES_PASSWORD= postgres
POSTGRES_DB= frdp
POSTGRES_PORT= 5432
POSTGRES_SERVER= pgdb

# PGADMIN_LISTEN_PORT
PGADMIN_DEFAULT_EMAIL= yezz@localhost.com
PGADMIN_DEFAULT_PASSWORD= postgres

I guess the issue is related to the database here or the server of the database we use mostly the name of the Docker container as you see:

  pgdb:
    image: postgres:12
    container_name: postgres_db
    restart: always
    volumes:
      - postgres-data:/var/lib/postgresql/data/
    env_file:
      - ./.env
    ports:
      - "5432:5432"

we have the pgdb that's why it's would not run for you

@Elamurugan-Nallathambi
Copy link
Author

Elamurugan-Nallathambi commented Dec 15, 2021

Thank you so much for checking my question and sharing this resolution. The following works ok

.env

# Backend API
PROJECT_NAME=FRDP
DOMAIN=http://localhost:8080

# openssl rand -hex 32 - Generate secret key
SECRET_KEY=SecretKey
USERS_OPEN_REGISTRATION=true
EMAIL_RESET_TOKEN_EXPIRE_HOURS=48

# Server Settings
SERVER_NAME=localhost
SERVER_HOST=http://localhost:8080

# Postgres default username and password
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_DB=frdp
POSTGRES_PORT=5432
POSTGRES_SERVER=pgdb

# PGADMIN_LISTEN_PORT
PGADMIN_DEFAULT_EMAIL=ela@localhost.local
PGADMIN_DEFAULT_PASSWORD=postgres

docker-compose

  pgdb:
    image: postgres:12.9
    container_name: postgres_db
    restart: always
    volumes:
      - postgres-data:/var/lib/postgresql/data/
    env_file:
      - ./.env
    ports:
      - "5432:5432"

After this update and clearing the previous docker volumes worked ok., still I manually assigned the user to the frdp Db

GRANT ALL PRIVILEGES ON DATABASE frdp TO postgres; then DB access also worked ok.

Only one more question is, users table doesn't have entries. If I create a user from postman, that user will became super_user?

@yezz123
Copy link
Owner

yezz123 commented Dec 15, 2021

Thank you so much for checking my question and sharing this resolution. The following works ok

.env

# Backend API
PROJECT_NAME=FRDP
DOMAIN=http://localhost:8080

# openssl rand -hex 32 - Generate secret key
SECRET_KEY=SecretKey
USERS_OPEN_REGISTRATION=true
EMAIL_RESET_TOKEN_EXPIRE_HOURS=48

# Server Settings
SERVER_NAME=localhost
SERVER_HOST=http://localhost:8080

# Postgres default username and password
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_DB=frdp
POSTGRES_PORT=5432
POSTGRES_SERVER=pgdb

# PGADMIN_LISTEN_PORT
PGADMIN_DEFAULT_EMAIL=ela@localhost.local
PGADMIN_DEFAULT_PASSWORD=postgres

docker-compose

  pgdb:
    image: postgres:12.9
    container_name: postgres_db
    restart: always
    volumes:
      - postgres-data:/var/lib/postgresql/data/
    env_file:
      - ./.env
    ports:
      - "5432:5432"

After this update and clearing the previous docker volumes worked ok.

Only one more question is, users table doesn't have entries. If I create a user from the postman, that user will become super_user?

You can create it using the curl command or also inject it directly to the database u have the UI part in this link: http://localhost:5050/

@Elamurugan-Nallathambi
Copy link
Author

Hello Yasser,

Thank you for addressing this queries so quickly, I ended up inserting bcrypt hashed password based super_user row into users table manually since to use the API I require to have atleast one user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants