Skip to content

Commit

Permalink
bbb
Browse files Browse the repository at this point in the history
  • Loading branch information
sneko committed Feb 20, 2024
1 parent 776972d commit a6fd719
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/utils/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export async function setupPostgres(): Promise<PostgresContainer> {
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,
Expand Down
1 change: 0 additions & 1 deletion src/utils/testcontainers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit a6fd719

Please sign in to comment.