github.com/skippbox/kompose-origin@v0.0.0-20160524133224-16a9dca7bac2/README.md (about)

     1  # libcompose
     2  
     3  [![GoDoc](https://godoc.org/github.com/docker/libcompose?status.png)](https://godoc.org/github.com/docker/libcompose)
     4  [![Build Status](https://jenkins.dockerproject.org/job/docker/job/libcompose/branch/master/badge/icon)](https://jenkins.dockerproject.org/job/docker/job/libcompose/branch/master/)
     5  
     6  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.
     7  
     8  **Note: This is experimental and not intended to replace the [Docker Compose](https://github.com/docker/compose) command-line tool. If you're looking to use Compose, head over to the [Compose installation instructions](http://docs.docker.com/compose/install/) to get started with it.**
     9  
    10  ```go
    11  package main
    12  
    13  import (
    14  	"log"
    15  
    16  	"golang.org/x/net/context"
    17  
    18  	"github.com/docker/libcompose/docker"
    19  	"github.com/docker/libcompose/project"
    20  	"github.com/docker/libcompose/project/options"
    21  )
    22  
    23  func main() {
    24  	project, err := docker.NewProject(&docker.Context{
    25  		Context: project.Context{
    26  			ComposeFiles: []string{"docker-compose.yml"},
    27  			ProjectName:  "my-compose",
    28  		},
    29  	}, nil)
    30  
    31  	if err != nil {
    32  		log.Fatal(err)
    33  	}
    34  
    35  	err = project.Up(context.Background(), options.Up{})
    36  
    37  	if err != nil {
    38  		log.Fatal(err)
    39  	}
    40  }
    41  ```
    42  
    43  ## Building
    44  
    45  You need either [Docker](http://github.com/docker/docker) and `make`,
    46  or `go` in order to build libcompose.
    47  
    48  ### Building with `docker`
    49  
    50  You need Docker and ``make`` and then run the ``binary`` target. This
    51  will create binary for all platform in the `bundles` folder. 
    52  
    53  ```bash
    54  $ make binary
    55  docker build -t "libcompose-dev:refactor-makefile" .
    56  # […]
    57  ---> Making bundle: binary (in .)
    58  Number of parallel builds: 4
    59  
    60  -->      darwin/386: github.com/docker/libcompose/cli/main
    61  -->    darwin/amd64: github.com/docker/libcompose/cli/main
    62  -->       linux/386: github.com/docker/libcompose/cli/main
    63  -->     linux/amd64: github.com/docker/libcompose/cli/main
    64  -->       linux/arm: github.com/docker/libcompose/cli/main
    65  -->     windows/386: github.com/docker/libcompose/cli/main
    66  -->   windows/amd64: github.com/docker/libcompose/cli/main
    67  
    68  $ ls bundles
    69  libcompose-cli_darwin-386*    libcompose-cli_linux-amd64*      libcompose-cli_windows-amd64.exe*
    70  libcompose-cli_darwin-amd64*  libcompose-cli_linux-arm*
    71  libcompose-cli_linux-386*     libcompose-cli_windows-386.exe*
    72  ```
    73  
    74  
    75  ### Building with `go`
    76  
    77  - You need `go` v1.5 or greater
    78  - If you are not using `go` v1.6, you need to set export `GO15VENDOREXPERIMENT=1` environment variable
    79  - If your working copy is not in your `GOPATH`, you need to set it
    80  accordingly.
    81  
    82  ```bash
    83  $ go generate
    84  # Generate some stuff
    85  $ go build -o libcompose ./cli/main
    86  ```
    87  
    88  
    89  ## Running
    90  
    91  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.
    92  
    93  Run one of these:
    94  
    95  ```
    96  libcompose-cli_darwin-386
    97  libcompose-cli_linux-amd64
    98  libcompose-cli_windows-amd64.exe
    99  libcompose-cli_darwin-amd64
   100  libcompose-cli_linux-arm
   101  libcompose-cli_linux-386
   102  libcompose-cli_windows-386.exe
   103  ```
   104  
   105  ## Tests (unit & integration)
   106  
   107  
   108  You can run unit tests using the `test-unit` target and the
   109  integration test using the `test-integration` target. If you don't use
   110  Docker and `make` to build `libcompose`, you can use `go test` and the
   111  following scripts : `script/test-unit` and `script/test-integration`.
   112  
   113  ```bash
   114  $ make test-unit
   115  docker build -t "libcompose-dev:refactor-makefile" .
   116  #[…]
   117  ---> Making bundle: test-unit (in .)
   118  + go test -cover -coverprofile=cover.out ./docker
   119  ok      github.com/docker/libcompose/docker     0.019s  coverage: 4.6% of statements
   120  + go test -cover -coverprofile=cover.out ./project
   121  ok      github.com/docker/libcompose/project    0.010s  coverage: 8.4% of statements
   122  + go test -cover -coverprofile=cover.out ./version
   123  ok      github.com/docker/libcompose/version    0.002s  coverage: 0.0% of statements
   124  
   125  Test success
   126  ```
   127  
   128  
   129  ## Current status
   130  
   131  The project is still being kickstarted... But it does a lot.  Please try it out and help us find bugs.
   132  
   133  ## Contributing
   134  
   135  Want to hack on libcompose? [Docker's contributions guidelines](https://github.com/docker/docker/blob/master/CONTRIBUTING.md) apply.