Skip to content

Go wrapper around Docker Compose, useful for integration testing.

License

Notifications You must be signed in to change notification settings

ibrt/go-compose

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-compose

Build Status Circle CI Coverage Status GoDoc

Go wrapper around Docker Compose, useful for integration testing.

Example:

// Define Compose config.
var composeYML =`
test_mockserver:
  container_name: ms
  image: jamesdbloom/mockserver
  ports:
    - "10000:1080"
    - "${SOME_ENV_VAR}" # This is replaced with the value of SOME_ENV_VAR.
test_postgres:
  container_name: pg
  image: postgres
  ports:
    - "5432"
`

// Start containers.
c, err := compose.Start(composeYML, true, true)
if err != nil {
    panic(err)
}
defer c.Kill()

// Build MockServer public URL.
mockServerURL := fmt.Sprintf(
    "http://%v:%v",
    compose.MustInferDockerHost(),
    c.Containers["ms"].MustGetFirstPublicPort(1080, "tcp"))

// Wait for MockServer to start accepting connections.
MustConnectWithDefaults(func() error {
    _, err := http.Get(mockServerURL)
    return err
})

About

Go wrapper around Docker Compose, useful for integration testing.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages