com.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Failed to initialize pool: The connection attempt failed.
I get the above error when entering sbt run
However, inside my docker containers everything works fine.
Inside the first container I have a postgres database. The second container I have an image built from my project folders. When I run docker-compose up --build
everything works fine.
I suspect the project (actual codebase) can't see the postgres database in docker-compose container.
Do I need another postgres database outside the docker-compose containers to go with my project code outside the containers?
docker-compose.yml file.
version: '3.6'
services:
# App Backend PostgreSQL
postgres:
container_name: sportsAppApiDb
image: postgres:11.7-alpine
environment:
POSTGRES_USER: admin
POSTGRES_PASSWORD: password
POSTGRES_URL: postgres://admin:password@localhost:5432/sportsappapi
POSTGRES_DB: sportsappapi
POSTGRES_HOST: postgres
ports:
- "5432:5432"
# App Backend
sports-app-api:
container_name: sportsAppApi
build: ./
volumes:
- ./:/usr/src/sports-app-api
command: sbt run
working_dir: /usr/src/sports-app-api
ports:
- "8000:8000"
environment:
POSTGRES_URI: postgres://admin:password@postgres:5432/sportsappapi
Entrypoint for scala project
object SportsAppApiStartup extends App {
SportsAppApiDb(SportsAppApiConfig.appDb).init
WebServer(Endpoints.handler, 8000).start()
println(s"Running sports-app-api on port: 8000")
}