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

Issue: Inconsistent Postgres Configuration in Docker Setup and .env.example File #144

Open
Hritul2 opened this issue Oct 23, 2024 · 0 comments · May be fixed by #145
Open

Issue: Inconsistent Postgres Configuration in Docker Setup and .env.example File #144

Hritul2 opened this issue Oct 23, 2024 · 0 comments · May be fixed by #145

Comments

@Hritul2
Copy link
Contributor

Hritul2 commented Oct 23, 2024

Description:

There is an inconsistency in the DATABASE_URL configuration between the Docker setup instructions and the .env.example files in the repository, which may cause issues when booting up the application.

Steps to Reproduce:

  1. Follow the Docker setup instructions in the README.md:

    docker run -d \
    --name muzer-db \
    -e POSTGRES_USER=myuser \
    -e POSTGRES_PASSWORD=mypassword \
    -e POSTGRES_DB=mydatabase \
    -p 5432:5432 \
    postgres

    In this setup, the POSTGRES_USER is set to myuser and POSTGRES_PASSWORD is set to mypassword.

  2. Compare the DATABASE_URL in the .env.example files for both next-app and ws folders:

    DATABASE_URL=postgresql://postgres:postgres@postgres:5432/postgres

Problems:

  1. Inconsistent Credentials:
    The Docker setup uses myuser and mypassword, whereas the .env.example file uses postgres for both the username and password. This inconsistency can lead to authentication errors when starting the application, as the DATABASE_URL won't match the credentials defined in the Docker container.

  2. Hostname Mismatch:
    The .env.example files use postgres as the host (@postgres:5432), assuming the application is being run inside a Docker network. However, when not using Docker, the hostname should be localhost:

    DATABASE_URL=postgresql://postgres:postgres@localhost:5432/postgres

    This causes a problem for users who are not using Docker, as the application tries to connect to postgres instead of localhost.

Proposed Solutions:

  1. Update the Docker instructions in the README.md to match the .env.example file, using:

    docker run -d \
    --name muzer-db \
    -e POSTGRES_USER=postgres \
    -e POSTGRES_PASSWORD=postgres \
    -e POSTGRES_DB=postgres \
    -p 5432:5432 \
    postgres
  2. Modify the .env.example file to include a note or conditional configuration for users who are not using Docker, ensuring they switch the host to localhost:

    # When using Docker, use the 'postgres' hostname
    # DATABASE_URL=postgresql://postgres:postgres@postgres:5432/postgres
    
    # For non-Docker setups, use 'localhost'
    DATABASE_URL=postgresql://postgres:postgres@localhost:5432/postgres

Additional Information:

  • The mismatch between localhost and postgres creates boot-up errors for users who are not running the database in a Docker network.
  • Providing clear instructions for both Docker and non-Docker setups would improve the developer experience and reduce confusion.

Please let me know if any further clarification is needed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant