Coder Social home page Coder Social logo

ldez / libcompose Goto Github PK

View Code? Open in Web Editor NEW

This project forked from docker/libcompose

0.0 1.0 0.0 5.25 MB

*Unmaintained/Deprecated* An experimental go library providing Compose-like functionality

Home Page: https://godoc.org/github.com/docker/libcompose

License: Apache License 2.0

Dockerfile 0.59% Makefile 0.54% Go 95.23% Shell 3.63%

libcompose's Introduction

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 not really maintained anymore โ€” the reason are diverse but mainly lack of time from the maintainers

The current state is the following :

  • The libcompose CLI should considered abandonned. The v2 parsing is incomplete and v3 parsing is missing.
  • The official compose Go parser implementation is on docker/cli but only support v3 version of the compose format.

What is the work that is needed:

  • Remove the cli code (thus removing dependencies to docker/cli )
  • Clearer separation of packages : parsing, conversion (to docker api or swarm api), execution (Up, Down, โ€ฆ behaviors)
  • Add support for all compose format version (v1, v2.x, v3.x)
  • Switch to either golang/dep or go mod for dependencies (removing the vendor folder)
  • (bonus) extract the docker/cli code here and vendor this library into docker/cli.

If you are interested to work on libcompose, feel free to ping me (over twitter @vdemeest), I'll definitely do code reviews and help as much as I can ๐Ÿ˜‰.

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.11 or greater
  • you need to set export GO111MODULE=on 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.

libcompose's People

Contributors

a-bouts avatar aanand avatar beornf avatar bfirsh avatar bfosberry avatar cpuid avatar dansteen avatar deviantony avatar dnephin avatar dtan4 avatar dustinrc avatar exekias avatar gdevillele avatar gitlawr avatar ibuildthecloud avatar imikushin avatar joshwget avatar jritsema avatar kunalkushwaha avatar ldez avatar lox avatar mikedougherty avatar rheinwein avatar shin- avatar surajnarwade avatar thajeztah avatar vdemeester avatar vito-c avatar xihan88 avatar yudai avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.