Skip to content

Commit

Permalink
fix(psqldocker): fix port bug
Browse files Browse the repository at this point in the history
  • Loading branch information
bradub committed Aug 21, 2024
1 parent 247f3a6 commit ec5dce8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion psqldocker/psql_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
_ "github.com/lib/pq"
"github.com/ory/dockertest/v3"
"github.com/ory/dockertest/v3/docker"
"strings"
)

// ensure Container implements the io.Closer interface.
Expand Down Expand Up @@ -102,6 +103,12 @@ func NewContainer(
opts[i].apply(&options)
}

exposedPSQLPort := options.dbPort

if !strings.Contains(exposedPSQLPort, "/tcp") {
exposedPSQLPort = exposedPSQLPort + "/tcp"
}

return &Container{
user: user,
password: password,
Expand All @@ -113,7 +120,7 @@ func NewContainer(
Cmd: []string{"-p " + options.dbPort},
Repository: "postgres",
Tag: options.imageTag,
ExposedPorts: []string{options.dbPort},
ExposedPorts: []string{exposedPSQLPort},
Env: envVars(user, password, dbName),
},
expiration: options.expirationSeconds,
Expand Down

0 comments on commit ec5dce8

Please sign in to comment.