for some reason, this is getting cached, which means the schema doesn't get created:
func (m *CassandraProxy) PostgresService(directoryArg *dagger.Directory) *dagger.Service {
c := dag.Container().
From("postgres:15").
WithEnvVariable("POSTGRES_USER", "postgres").
WithEnvVariable("POSTGRES_PASSWORD", "postgres").
WithEnvVariable("POSTGRES_DB", "postgres").
WithEnvVariable("POSTGRES_HOST", "db-postgres")
svc := c.WithExec([]string{"docker-entrypoint.sh", "postgres"}).
WithExposedPort(5432).AsService()
initCmd := `until psql -e \
-h postgres -U postgres -d postgres \
-c 'CREATE SCHEMA "test"'; do
echo 'retrying schema creation';
done;`
_, err := c.
WithServiceBinding("postgres", svc).
WithEnvVariable("PGPASSWORD", "postgres").
WithExec([]string{"sh", "-xc",
initCmd,
}).Sync(context.Background())
if err != nil {
panic(fmt.Errorf("could not init postgres db: %s", err))
}
return svc
}