Last built 1 year ago using go version go1.5.1 linux/amd64 and 73 seconds of time
Captain - Convert your Git workflow to Docker containers ready for Continuous Delivery
Define your workflow in the
captain.yaml and use captain to your Continuous Delivery service to create containers for each commit, test them and push them to your registry only when tests passes.
captain buildto build your Dockerfile(s) of your repository. If your repository has local changes the containers will only be tagged as latest, otherwise the containers will be tagged as latest, COMMIT_ID & BRANCH_NAME. Now your Git commit tree is reproduced in your local docker repository.
captain testto run your tests
captain pushto send selected images to the remote repository
From the other side, you can now pull the feature branch you want to test, or create distribution channels (such as ‘alpha’, ‘beta’, ‘stable’) using git tags that are propagated to container tags.
To install Captain, run the following commands:
curl -L https://github.com/harbur/captain/releases/download/v0.7.0/captain-`uname -s`-`uname -m` > /usr/local/bin/captain chmod +x /usr/local/bin/captain
Captain will automatically configure itself with sane values without the need for any pre-configuration, so that it will work in most cases. When it doesn’t, the
captain.yml file can be used to configure it properly. This is a simple YAML file placed on the root directory of your git repository. Captain will look for it and use it to be configured.
Here is a full
hello-world: build: Dockerfile image: harbur/hello-world pre: - echo "Preparing hello-world" post: - echo "Finished hello-world" hello-world-test: build: Dockerfile.test image: harbur/hello-world-test pre: - echo "Preparing hello-world-test" post: - echo "Finished hello-world-test" test: - docker run -e NODE_ENV=TEST harbur/hello-world-test node mochaTest - docker run -e NODE_ENV=TEST harbur/hello-world-test node karmaTest
The location of the Dockerfile to be compiled.
When auto-detecting, the image will be re-constructed by the following rules:
usernameis the host’s username
parent_diris the Dockerfile’s parent directory name
parsed_suffix: is the suffix of the Dockerfile parsed with the following rules:
The relative path of the Dockerfile to be used to compile the image. The Dockerfile’s directory is also the build context that is sent to the Docker daemon.
When auto-detecting it will walk current directory and all subdirectories to locate Dockerfiles of the following format:
The build path will be reconstructed automatically to compile the Dockerfile. The build context will be the directory where the Dockerfile is located.
Note: If more than one Dockerfiles are needed on specific directory, suffix can be used to separate them and share the same build context.
build: Dockerfile build: Dockerfile.custom build: path/to/file/Dockerfile build: path/to/file/Dockerfile.custom
A list of commands that are run as tests after the compilation of the specific image. If any command fail, then captain stops and reports a non-zero exit status.
test: - docker run -e NODE_ENV=TEST harbur/hello-world-test node mochaTest - docker run -e NODE_ENV=TEST harbur/hello-world-test node karmaTest
A list of commands that are run as preparation before the compilation of the specific image. If any command fail, then captain stops and reports a non-zero exit status.
pre: - echo "Preparing compilation"
A list of commands that are run as post-execution after the compilation of the specific image. If any command fail, then captain stops and reports a non-zero exit status.
post: - echo "Reporting after compilation"
Builds the docker image(s) of your repository
It will build the docker image(s) described on captain.yml in order they appear on file
-f, --force=false: Force build even if image is already built
Runs the tests
It will execute the commands described on test section in order they appear on file
Pushes the images to remote registry
It will push the generated images to the remote registry
By default it pushes the ‘latest’ and the ‘branch’ docker tags.
Pulls the images from remote registry
It will pull the images from the remote registry
By default it pulls the ‘latest’ and the ‘branch’ docker tags.
Displays the version of Captain
Help provides help for any command in the application.
captain help [path to command] for full details.
-B, --all-branches=false: Build all branches on specific commit instead of just working branch -D, --debug=false: Enable debug mode -h, --help=false: help for captain -N, --namespace="username": Set default image namespace
The following is the workflow of tagging Docker images according to git state.
tag-name. A maximum of one tag per commit id is supported.
Here are some of the features pending to be implemented:
captain detectthat outputs the generated
captain.ymlwith auto-detected content.
captain ci [travis|circle|etc.]to output configuration wrappers for each CI service