diff --git a/docker-compose.yaml b/docker-compose.yaml index 53cf443..375b9f7 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -17,7 +17,7 @@ services: volumes: - postgres:/data/postgres ports: - - '${DOCKER_COMPOSE_HOST_PORTS:-5432:}5432' + - '${DOCKER_COMPOSE_POSTGRES_PORT_BINDING:-5432:5432}' networks: - postgres restart: unless-stopped diff --git a/src/utils/database.ts b/src/utils/database.ts index f11d00c..5b65d3e 100644 --- a/src/utils/database.ts +++ b/src/utils/database.ts @@ -30,6 +30,7 @@ export async function setupPostgres(): Promise { const environment = await new DockerComposeEnvironment(composeFilePath, composeFile) .withEnvironment({ ...defaultEnvironment, + DOCKER_COMPOSE_POSTGRES_PORT_BINDING: '5432', // To use a random port from the host POSTGRES_USER: dummyUser, POSTGRES_PASSWORD: dummyPassword, POSTGRES_DB: dummyDatabase, diff --git a/src/utils/testcontainers.ts b/src/utils/testcontainers.ts index be736e4..ba768da 100644 --- a/src/utils/testcontainers.ts +++ b/src/utils/testcontainers.ts @@ -20,7 +20,6 @@ export function getContainerNameSuffix(): string { export const defaultEnvironment = { DOCKER_COMPOSE_CONTAINER_NAME_SUFFIX: getContainerNameSuffix(), - DOCKER_COMPOSE_HOST_PORTS: ':', // Using `:` tells to use any port available (we wanted to specify an empty string but when doing so `docker-compose` considers the environment variable as null and takes the default value instead) }; export function formatContainerNameWithSuffix(containerNameBase: string) {