An experimental go library providing Compose-like functionality
Go Shell Makefile
Latest commit 01ff892 May 15, 2017 @vdemeester vdemeester committed on GitHub Merge pull request #467 from surajnarwade/fix-network
Fixed error causing due to top level network key
Permalink
Failed to load latest commit information.
cli add 'stop_grace_period' May 4, 2017
config Merge pull request #465 from gitlawr/add_stop_grace_period May 11, 2017
docker add 'stop_grace_period' May 4, 2017
example Fix example Oct 31, 2016
hack Use vndr to vendor stuff Feb 3, 2017
integration Update vendor dependencies… Feb 24, 2017
labels Move Label into their own package May 7, 2016
logger Adding standard LoggerFactory for image building and pulling Jul 8, 2016
lookup Interpolate under volumes and networks Dec 27, 2016
project Fixed error causing due to top level network key May 15, 2017
samples add a simple Go program using the parser Jul 6, 2015
test Update vendor dependencies… Feb 24, 2017
utils add 'stop_grace_period' May 4, 2017
vendor Update vendor dependencies… Feb 24, 2017
version Bump version to 0.4.0… Jan 10, 2017
yaml Fixes issue #454 Environment.ToMap() doesn't support variables with e… Mar 29, 2017
.dockerignore Add **/*.test to .dockerignore Apr 4, 2016
.gitignore Update example #261 May 23, 2016
CHANGELOG.md Rename CHANGES to CHANGELOG Aug 13, 2015
CONTRIBUTING.md Add some info to contributing.md Aug 13, 2015
Dockerfile Merge pull request #432 from vdemeester/use-vndr-to-vendor Feb 4, 2017
Jenkinsfile Add a SHOWNOWARNING constant to hide warning message Jun 21, 2016
LICENSE Initial Commit Jul 19, 2015
MAINTAINERS Add Josh Curl as maintainer May 18, 2016
Makefile Rename script folder to hack Sep 30, 2016
README.md Rename script folder to hack Sep 30, 2016
package.go Initial Commit Jul 19, 2015
vendor.conf Update vendor dependencies… Feb 24, 2017

README.md

libcompose

GoDoc Build Status

A Go library for Docker Compose. It does everything the command-line tool does, but from within Go -- read Compose files, start them, scale them, etc.

Note: This is experimental and not intended to replace the Docker Compose command-line tool. If you're looking to use Compose, head over to the Compose installation instructions to get started with it.

Here is a list of known project that uses libcompose:

Usage

package main

import (
	"log"

	"golang.org/x/net/context"

	"github.com/docker/libcompose/docker"
	"github.com/docker/libcompose/docker/ctx"
	"github.com/docker/libcompose/project"
	"github.com/docker/libcompose/project/options"
)

func main() {
	project, err := docker.NewProject(&ctx.Context{
		Context: project.Context{
			ComposeFiles: []string{"docker-compose.yml"},
			ProjectName:  "my-compose",
		},
	}, nil)

	if err != nil {
		log.Fatal(err)
	}

	err = project.Up(context.Background(), options.Up{})

	if err != nil {
		log.Fatal(err)
	}
}

Building

You need either Docker and make, or go in order to build libcompose.

Building with docker

You need Docker and make and then run the binary target. This will create binary for all platform in the bundles folder.

$ make binary
docker build -t "libcompose-dev:refactor-makefile" .
# […]
---> Making bundle: binary (in .)
Number of parallel builds: 4

-->      darwin/386: github.com/docker/libcompose/cli/main
-->    darwin/amd64: github.com/docker/libcompose/cli/main
-->       linux/386: github.com/docker/libcompose/cli/main
-->     linux/amd64: github.com/docker/libcompose/cli/main
-->       linux/arm: github.com/docker/libcompose/cli/main
-->     windows/386: github.com/docker/libcompose/cli/main
-->   windows/amd64: github.com/docker/libcompose/cli/main

$ ls bundles
libcompose-cli_darwin-386*    libcompose-cli_linux-amd64*      libcompose-cli_windows-amd64.exe*
libcompose-cli_darwin-amd64*  libcompose-cli_linux-arm*
libcompose-cli_linux-386*     libcompose-cli_windows-386.exe*

Building with go

  • You need go v1.5 or greater
  • If you are not using go v1.6, you need to set export GO15VENDOREXPERIMENT=1 environment variable
  • If your working copy is not in your GOPATH, you need to set it accordingly.
$ go generate
# Generate some stuff
$ go build -o libcompose ./cli/main

Running

A partial implementation of the libcompose-cli CLI is also implemented in Go. The primary purpose of this code is so one can easily test the behavior of libcompose.

Run one of these:

libcompose-cli_darwin-386
libcompose-cli_linux-amd64
libcompose-cli_windows-amd64.exe
libcompose-cli_darwin-amd64
libcompose-cli_linux-arm
libcompose-cli_linux-386
libcompose-cli_windows-386.exe

Tests (unit & integration)

You can run unit tests using the test-unit target and the integration test using the test-integration target. If you don't use Docker and make to build libcompose, you can use go test and the following scripts : hack/test-unit and hack/test-integration.

$ make test-unit
docker build -t "libcompose-dev:refactor-makefile" .
#[…]
---> Making bundle: test-unit (in .)
+ go test -cover -coverprofile=cover.out ./docker
ok      github.com/docker/libcompose/docker     0.019s  coverage: 4.6% of statements
+ go test -cover -coverprofile=cover.out ./project
ok      github.com/docker/libcompose/project    0.010s  coverage: 8.4% of statements
+ go test -cover -coverprofile=cover.out ./version
ok      github.com/docker/libcompose/version    0.002s  coverage: 0.0% of statements

Test success

Current status

The project is still being kickstarted... But it does a lot. Please try it out and help us find bugs.

Contributing

Want to hack on libcompose? Docker's contributions guidelines apply.

If you have comments, questions, or want to use your knowledge to help other, come join the conversation on IRC. You can reach us at #libcompose on Freenode.