I'm trying to setup some integrations tests with docker compose. I'm using docker compose to spin up a postgres database and a nodejs server. I'm then using jest to run http requests against the server.
For some reasons that I can't explain all SQL queries (even the simplest one) are extremely slow (+ 1s).
It sounds like a communication problem between the two containers, but I can't spot it. Am I doing something wrong?
Here's my docker-compose.yml
file. The server is just a simple express app
version: "3.9"
services:
database:
image: postgres:12
env_file: .env
volumes:
- ./db-data:/var/lib/postgresql/data
healthcheck:
test: pg_isready -U test_user -d test_database
interval: 1s
timeout: 10s
retries: 3
start_period: 0s
server:
build: .
ports:
- "8080:8080"
depends_on:
database:
condition: service_healthy
env_file: .env
environment:
POSTGRES_HOST: database
NODE_ENV: test
init: true
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/healthcheck"]
interval: 1s
timeout: 10s
retries: 3
start_period: 0s
EDIT I'm using
Docker version 20.10.2, build 2291f61
macOs BigSur 11.1 (20C69)