From 8c14f3206cc3c9a5d24c190520da9d2ccc005873 Mon Sep 17 00:00:00 2001 From: Miguel Merlin <106508795+miguel-merlin@users.noreply.github.com> Date: Wed, 12 Feb 2025 00:28:16 -0500 Subject: [PATCH] Postgres refused connection fix (#48) * feat: added postgres as user * docs: added troubleshooting section --- .env.example | 4 ++-- README.md | 8 +++++++- docker-compose.yaml | 2 +- src/main/resources/application.properties | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.env.example b/.env.example index f6ad863..dd2b0c9 100644 --- a/.env.example +++ b/.env.example @@ -1,7 +1,7 @@ -POSTGRES_USER=blueprint_admin_backend +POSTGRES_USER=postgres POSTGRES_PASSWORD=postgres POSTGRES_DB=postgres SPRING_DATASOURCE_URL=jdbc:postgresql://postgres:5432/postgres -SPRING_DATASOURCE_USERNAME=blueprint_admin_backend +SPRING_DATASOURCE_USERNAME=postgres SPRING_DATASOURCE_PASSWORD=postgres SPRING_PROFILES_ACTIVE=dev diff --git a/README.md b/README.md index 5973363..5e7c5b6 100644 --- a/README.md +++ b/README.md @@ -19,11 +19,17 @@ You should see the following output in your terminal ``` o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port 8080 (http) with context path '' com.sitblueprint.admin.BlueprintAdmin : Started BlueprintAdmin in 2.255 seconds (process running for 2.392) - ``` You can also run the server directly from the terminal +## Troubleshooting +If you are having issues running the postgres db with Docker try the following +```bash +docker-compose down -v +rm -rf postgres-data +docker-compose up --build +``` ## How to connect to database in Docker Container? Start the docker container diff --git a/docker-compose.yaml b/docker-compose.yaml index 7ceb8b1..bd675e0 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,6 +1,6 @@ services: postgres: - image: postgres:latest + image: postgres:10-alpine restart: always environment: - POSTGRES_USER=${POSTGRES_USER} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 037d66c..cd95ae4 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -5,7 +5,7 @@ spring.jpa.hibernate.ddl-auto=update spring.jpa.properties.hibernate.format_sql=true spring.datasource.url=${SPRING_DATASOURCE_URL:jdbc:postgresql://localhost:5432/postgres} -spring.datasource.username=${SPRING_DATASOURCE_USERNAME:blueprint_admin_backend} +spring.datasource.username=${SPRING_DATASOURCE_USERNAME:postgres} spring.datasource.password=${SPRING_DATASOURCE_PASSWORD:postgres} spring.profiles.active=${SPRING_PROFILES_ACTIVE:dev}