harbur / captain Goto Github PK
View Code? Open in Web Editor NEWCaptain - Convert your Git workflow to Docker :whale: containers
License: MIT License
Captain - Convert your Git workflow to Docker :whale: containers
License: MIT License
We don't want to pollute the docker tags with git-specific info so let's strip the prefix 'heads/origin' from docker tags.
Currently when 'captain push' is issued in detached mode of a commit with a branch name, captain issues the following error:
[CAPTAIN] Skipping push of app in detached mode
How to reproduce:
git checkout 2225ad4
Git tree example:
* 2225ad4 (HEAD, origin/example, example) Commit example 2
* ef14e6a Commit example 1
Rational:
This is basically the way most CI servers work, they checkout in detached mode, so in order to tag docker image with the branch name we need captain to be able to identify the branches in detached mode and use them.
Can i assign custom tag while build and push it to same private repository ?
In order to wrap non-docker build commands on the build life-cycle of containers preparation the following will be added on the captain.yml format:
captain-example:
build: Dockerfile
image: harbur/captain-example
pre:
- echo "Preparing build"
post:
- echo "Cleaning up build"
If I tag the code with something like RELEASE_1_0 in Git, it would be great to have a regex that detects it in captain and tags the container with version 1.0
When running e.g. captain build bogus
without bogus
defined in captain.yml, captain exits with status 0
and without any error message. This breaks CI or anything else relying on an correct exit status.
If I build push from a develop branch, my latest tag will map to that build, but when I build from my master branch (stable) my latest tag will map to that build.
This could cause confusion when you are working with something like gitflow, where latest would jump between develop and master depending on whichever branch your CI server built and pushed last.
Possible solutions would be a disable latest tag cli argument, which could in turn be set as part of a build running on a CI server, or a YAML element that mapped latest to a specific branch.
Example of problem:
charlie:foo (master)$ cat Dockerfile
FROM alpine:latest
ENTRYPOINT ["/bin/echo"]
CMD ["Hello, World"]
charlie:foo (master)$ captain build
[CAPTAIN] Skipping build of foo:c69a2b5 - image is already built
[CAPTAIN] Tagging image foo:c69a2b5 as foo:latest
[CAPTAIN] Tagging image foo:c69a2b5 as foo:master
charlie:foo (master)$ docker run --rm foo
Hello, World
charlie:foo (master)$ git checkout develop
Switched to branch 'develop'
charlie:foo (develop)$ cat Dockerfile
FROM alpine:latest
ENTRYPOINT ["/bin/echo"]
CMD ["Bye Bye, Cruel World"]
charlie:foo (develop)$ captain build
[CAPTAIN] Building image foo:latest
Step 1 : FROM alpine:latest
---> 4e38e38c8ce0
Step 2 : ENTRYPOINT /bin/echo
---> Using cache
---> c7525f863b54
Step 3 : CMD Bye Bye, Cruel World
---> Using cache
---> 4f246db51200
Successfully built 4f246db51200
[CAPTAIN] Tagging image foo:latest as foo:79e6028
[CAPTAIN] Tagging image foo:latest as foo:develop
charlie:foo (develop)$ docker run --rm foo
Bye Bye, Cruel World
charlie:foo (develop)$
There can be git tags that are illegal docker tags. A mapping should be made for "/" characters to "." characters.
This is quite useful for Continuous Delivery use-cases.
In order for CI systems to propagate the BUILD_NUMBER to captain they can now use '-t BUILD_NUMBER' as parameter.
This will create a docker image with the specific version and push it to registry with 'captain push'
CAPTAIN] Building image indigobio/rules:latest
Step 0 : FROM indigobio/deps:latest
Pulling repository docker.io/indigobio/deps
Error: image indigobio/deps:latest not found
docker build -t indigobio/rules .
Sending build context to Docker daemon 8.008 MB
Step 0 : FROM indigobio/deps:latest
latest: Pulling from indigobio/deps
2fad5d366fbd: Already exists
If the image is already pulled then captain build will work fine. I can also push my private images through captain push no problem. Any thoughts?
Currently captain by default builds the current working branch, but in case of CI you might want to delegate all branch names of specific commit to the registry.
Take the following example of git commit:
where branchA is the current working branch. By default it will build and push only branchA. But in case of CI it might be desired to build and push all branchnames.
This is what all_branches (-B) flag does.
-B, --all-branches=false: Build all branches on specific commit instead of just working branch
Current format of captain.yml is limited, configuration cannot be added per image. Opting for a docker-compose.yml style format where each image gets it's own space on yml.
Example of new format:
captain:
build: Dockerfile
image: harbur/captain
captain-test:
build: Dockerfile.test
image: harbur/captain-test
test:
- docker run harbur/captain-test go test github.com/harbur/captain/captain
We're currently exposing our AWS account number through the YAML file. It would be helpful to inject this via env variables:
Actual:
apache:
build: Dockerfile
image: 123456789.dkr.ecr.ap-southeast-2.amazonaws.com/foobar/apache
Expected:
apache:
build: Dockerfile
image: $DOCKER_HUB_DOMAIN/foobar/apache
I've run into a lot of sporadic errors pushing to docker hub, retrying always fixes it. it would be great to have an option to retry pushing images up to 3 times.
It would be nice to be able to breakout tests on a container into sub-commands, this would be useful for CI/CD integration v. Developer workflow.
Example, a python app that might need coverage reports generated in junit, but developers want console tests:
app:
image: myorg/app
build: Dockerfile
test:
default: nosetests --with-coverage --with-timer
ci: nosetests --with-xunit --with-coverage
Thus, development workflow for testing would be done with captain test
running the default target, and a CI server could call captain test ci
to run a custom test command.
With 'captain pull' it will be possible on CI servers to pull the previous images from registry in order to take advantage of cached steps and avoid pushing new layers of same steps.
captain pull will by default pull 'latest' and 'branch'.
captain push will by default push 'branch' and 'latest'.
Docker supports now build time variables, it would be great if captain adds support for them too.
For example,
hello-world-test:
build: Dockerfile.test
image: harbur/hello-world-test
build_variables:
NODE_ENV: test
> docker build --help
Usage: docker build [OPTIONS] PATH | URL | -
Build an image from a Dockerfile
--build-arg=[] Set build-time variables
[...]
Add Coveralls integration and badge.
Currently captain doesn't do proper error handling. e.g. In case a docker registry fails it will continue without failing and the exit code will be 0
instead of propagating the exit code of the executed command.
During tagging after a build
xxxxxxxxxxxxx.dkr.ecr.us-west-2.amazonaws.com/ss:tags.1.0.1^0 <- no idea how this got there
API error (500): {"message":"invalid tag format"}
It could be useful to build/push/purge multiple modules, same as the single module option.
Actually if we pass a lists of modules, the filter is ignored and captain makes actions on all of them like when we don't pass any
Currently it pushes the image with the tags :latest
, :master
and :<branch>
, can you add :<git commit>
?
When the directory where Dockerfile resides contains upper-case characters and they are transformed to image name it is an invalid repository name.
To avoid this when inferring settings the directory name should be downcased to map it to a valid repository name.
Example below:
➜ git clone https://github.com/Runnable/dockerfiles
Cloning into 'dockerfiles'...
remote: Counting objects: 1092, done.
remote: Total 1092 (delta 0), reused 0 (delta 0), pack-reused 1092
Receiving objects: 100% (1092/1092), 9.33 MiB | 1.28 MiB/s, done.
Resolving deltas: 100% (296/296), done.
Checking connectivity... done.
➜ cd dockerfiles
➜ captain build
[CAPTAIN] No configuration found [captain.json captain.yaml captain.yml] - inferring values
[CAPTAIN] Building image spiddy/UTlPL1-f2W1TAAAW:latest
API error (500): Invalid repository name (UTlPL1-f2W1TAAAW), only [a-z0-9-_.] are allowed
It could be a simple entry on README.md.
Configure which images are to be pushed, e.g. to exclude test images.
I need this functionality soon... I think that it would be simpler if by default test images are never pushed.
Godep
serve it's purpose for some time, but let's move now to glide as our go package management.
The test we have now only test a few simple cases. We should improve test coverage.
Also, we could add in the main page a badge with the coverage.
If captain is executed in a project without Dockerfile(s) and neither captain.yml it should exit with non-zero status to indicate to CI servers that nothing was created.
Right now the default is to use --short
and there is no way to configure this.
In order to have a cleaner code it will be nice to have all the files linted.
When pushing images to the GCR the commands need to be executed using gcloud
as prefix of the command instead of using directly docker.
e.g. instead of:
docker pull gcr.io/your-project-id/example-image
it should be
gcloud docker pull gcr.io/your-project-id/example-image
.
Captain should identify these registries automatically and support using locally installed gcloud
to pull and push images.
During captain build, in order to check if image already exists a call to 'docker image' is made. To improve response time the call should ask to filter by image name.
Currently only one tag per commit-id is supported. Add support to create all git tag names in docker images.
How do I push my images to a private registry when calling captain push
?
Can I configure this?
Microbadger uses some build-time arguments to document a Docker image.
Those are BUILD_DATE and VCS_REF. As they are defined from the environment, it's currently not possible to include them in the build args. Could those values be defined by default in captain?
See https://microbadger.com/#/labels for reference.
Thanks.
Purge command will remove stale images.
As definition of stale image:
"Stale image is an image that is not the latest of at least one branch."
Currently we have no way to update captain
using captain itself so if we want to have the last version we have to check Github and install the last version manually.
I'd like to propose a new command captain self-update
that download the last version (if any) and update the binary in the computer.
In order to have captain self-update
we should:
$HOMEDIR/.captain/binaries/captain-{captain version}
$HOMEDIR/.captain/bin/captain
that points to the last binary (this dir should be in the users's $PATH
)captain
. E.g. https://raw.githubusercontent.com/harbur/captain/master/VERSION
captain self-update
captain
check the last version in https://raw.githubusercontent.com/harbur/captain/master/VERSION
$HOMEDIR/.captain/binaries/captain-{version}
captain
symlink in $HOMEDIR/.captain/bin/
What do you think? Have I missed something?
Add .travis.yml
to compile test and get coverage captain project using travis.
This will give us badges that we can add to the project and facilitate work with the tests.
In some situations it may be useful to run pre or post operations on test phase. I am thinking in next scenario.
Project A has a Project A-AT which contains the acceptance tests for project A. So before releasing a container you may want to get Project A-AT source code, run its own captain file to generate Project A-AT container (which may contain for example phantomjs) and then in test phase itself running both containers to execute the tests.
Now that captain self-update
command is implemented (see #37) we need an installation script that downloads and installs the captain binary in the same way that captain self-update
does.
It would be great if Captain
could support cache-from
, network
and squash
build options in addition to build_arg
.
It is not necessary to run pre commands when the image is already built. It should be skipped in such case.
for example, if pre command is used to build a WAR file before packaging it in an image, that step is no longer necessary if the image is already built and should be skipped.
If when pushing an image push fails it should stop and exit with non-zero code.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.