I feel like I'm hitting a bug or missing something obvious. Running the below based on the service example in the cookbook and... no dice.
func (m *Example) Postgres() *dagger.Service {
return dag.Container().
From("postgres").
WithEnvVariable("POSTGRES_USER", "root").
WithEnvVariable("POSTGRES_PASSWORD", "secret").
// WithMountedCache("/var/lib/postgresql/data", dag.CacheVolume("postgres")).
WithExposedPort(5432).
AsService()
}
func (m *Example) Psql() *dagger.Container {
return dag.Container().
From("postgres").
WithServiceBinding("db", m.Postgres()).
WithExec([]string{"sh", "-c", "sleep 15 && psql -h db -U root"})
}
$ dagger call psql
...
โ Container.sync: ContainerID! 16.6s
! process "sh -c sleep 15 && psql -h db -U root" did not complete successfully: exit code: 2
Error: invalid selection for command "psql": response from query: input: container.from.withServiceBinding.withExec.sync resolve: process "sh -c sleep 15 && psql -h db -U root" did not complete successfully: exit code: 2
Stderr:
psql: error: connection to server at "db" (0.0.0.0), port 5432 failed: Connection refused
Is the server running on that host and accepting TCP/IP connections?