I'm creating a docker-compose file to prepare an e2e testing environment, but I'm experiencing some issues when starting up my PostgreSQL server for testing.
docker-compose.my-app.e2e.yml:
version: "3.3"
services:
my-app-e2e-db:
image: postgres
restart: always
environment:
POSTGRES_USER: my-app-e2e-user
POSTGRES_PASSWORD: ${MY_APP_PG_PASS}
POSTGRES_DB: my-app
my-app-e2e-seeder:
build:
context: ..
dockerfile: .deploy/my-app-seeder.Dockerfile
depends_on:
- my-app-e2e-db
The problem is that my seeder script fails to connect to the PostgreSQL server, and when I look into it the PostgreSQL server is not running. The odd thing is that if remove my seeder script from the docker-compose and run it, the PostgreSQL server seems to run smoothly.
version: "3.3"
services:
my-app-e2e-db:
image: postgres
restart: always
environment:
POSTGRES_USER: my-app-e2e-user
POSTGRES_PASSWORD: ${MY_APP_PG_PASS}
POSTGRES_DB: my-app
I'm running the compose file with docker-compose --env-file=.deploy/my-app.e2e.env -f .deploy/docker-compose.my-app.e2e.yml up -d --build
.
Thanks!
UPDATE!
It turned out I was attempting to access the database in a RUN
step inside my Dockerfile. I moved that action to the CMD
step instead.