I have the following code:
const (
GO = "golang:1.20-alpine3.17"
MONGO = "bitnami/mongodb:4.0"
)
func run(ctx context.Context) error {
mongo := client.Container().From(MONGO).
WithEnvVariable("MONGODB_ADVERTISED_HOSTNAME", "mongo").
WithEnvVariable("MONGODB_REPLICA_SET_MODE", "primary").
WithEnvVariable("MONGODB_ROOT_PASSWORD", "password123").
WithEnvVariable("MONGODB_REPLICA_SET_KEY", "replicasetkey123").
WithEnvVariable("BITNAMI_DEBUG", "true").
WithExposedPort(27017)
golang := client.Container().From(GO).
WithEnvVariable("MONGO_ENDPOINT", "mongo:27017").
WithEnvVariable("MONGO_USERNAME", "root").
WithEnvVariable("MONGO_PASSWORD", "password123").
WithEnvVariable("MONGO_REPLICA_SET", "replicaset").
WithServiceBinding("mongo", mongo)
log.Info().Msg("Running Integration tests")
golang = golang.WithExec([]string{"make", "test-integration"})
stdout, err := golang.Stdout(ctx)
if err != nil {
log.Error().Err(err).Msg("error getting stdout")
return err
}
fmt.Println(stdout)
return nil
}```
When running with
go run dagger/integration/main.go
I get the following:
```bash
...
#3 1.096 Successfully added user: {
#3 1.096 "user" : "root",
#3 1.096 "roles" : [
#3 1.096 {
#3 1.096 "role" : "root",
#3 1.096 "db" : "admin"
#3 1.096 }
#3 1.096 ]
#3 1.096 }
#3 1.097 bye
#3 1.103 mongodb 21:34:42.73 INFO ==> Users created
#3 1.104 mongodb 21:34:42.73 INFO ==> Writing keyfile for replica set authentication...
#3 1.124 mongodb 21:34:42.76 INFO ==> Configuring MongoDB replica set...
#3 1.131 mongodb 21:34:42.76 INFO ==> Stopping MongoDB...
any Idea how I can make mongo run well with dagger? it runs well using docker-compose