Skip to content
This repository was archived by the owner on Jun 12, 2018. It is now read-only.

Commit 387e323

Browse files
author
Nicolas Huray
committed
Initiate project
0 parents  commit 387e323

File tree

4 files changed

+98
-0
lines changed

4 files changed

+98
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.DS_Store

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# wercker-docker-build
2+
3+
This wercker step just build your package as a [Docker](https://docs.docker.com/reference/commandline/cli/#build) image.
4+
5+
This step must be used with a wercker box build with [Docker Support](http://devcenter.wercker.com/articles/docker)
6+
7+
8+
## Versions
9+
10+
| Release date | Step version | Docker version |
11+
| -------------| -------------| ---------------|
12+
| 2014-11-28 | 1.0.0 | 1.3.1 |
13+
| -------------| -------------| ---------------|
14+
15+
16+
## Options
17+
18+
* `force-rm` (optional, default: `false`) Always remove intermediate containers, even after unsuccessful builds
19+
* `no-cache` (optional, default: `false`) Do not use cache when building the image
20+
* `quiet` (optional, default: `false`) Suppress the verbose output generated by the containers
21+
* `rm` (optional, default: `true`) Remove intermediate containers after a successful build
22+
* `tag` (optional but advised) Repository name (and optionally a tag) to be applied to the resulting
23+
24+
## Example
25+
26+
27+
The following example build a package as a Docker image with the sha1 of the commit :
28+
29+
```
30+
build:
31+
steps:
32+
...
33+
- nhuray/docker-build:
34+
tag: ${WERCKER_GIT_COMMIT:0:7}
35+
```

run.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/sh
2+
set -e
3+
4+
if [ -n "$WERCKER_DOCKER_BUILD_FORCE_RM" ]; then
5+
FORCE_RM="--force-rm $WERCKER_DOCKER_BUILD_FORCE_RM"
6+
fi
7+
8+
if [ -n "$WERCKER_DOCKER_BUILD_NO_CACHE" ]; then
9+
NO_CACHE="--no-cache $WERCKER_DOCKER_BUILD_NO_CACHE"
10+
fi
11+
12+
if [ -n "$WERCKER_DOCKER_BUILD_QUIET" ]; then
13+
QUIET="--quiet $WERCKER_DOCKER_BUILD_QUIET"
14+
fi
15+
16+
if [ -n "$WERCKER_DOCKER_BUILD_RM" ]; then
17+
RM="--rm $WERCKER_DOCKER_BUILD_RM"
18+
fi
19+
20+
if [ -n "$WERCKER_DOCKER_BUILD_TAG" ]; then
21+
TAG="--tag $WERCKER_DOCKER_BUILD_TAG"
22+
fi
23+
24+
type_exists() {
25+
if [ $(type -P $1) ]; then
26+
return 0
27+
fi
28+
return 1
29+
}
30+
31+
# Check for Docker
32+
if ! type_exists 'docker'; then
33+
fail 'Docker is not installed on this box.'
34+
info 'Please use a box with docker installed : http://devcenter.wercker.com/articles/docker'
35+
exit 1
36+
fi
37+
38+
# Check a Dockerfile is present
39+
if [ -f 'Dockerfile' ]; then
40+
fail 'A Dockerfile is required.'
41+
info 'Please create a Dockerfile : https://docs.docker.com/reference/builder/'
42+
exit 1
43+
fi
44+
45+
# Build the docker image
46+
info 'building docker image'
47+
48+
set +e
49+
DOCKER_BUILD="docker build $FORCE_RM $NO_CACHE $QUIET $RM $TAG ."
50+
debug "$DOCKER_BUILD"
51+
DOCKER_BUILD_OUTPUT=$($DOCKER_BUILD)
52+
53+
if [[ $? -ne 0 ]];then
54+
warn $DOCKER_BUILD_OUTPUT
55+
fail 'docker build failed';
56+
else
57+
success 'docker build succeed';
58+
fi
59+
set -e

wercker-step.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name: docker-build
2+
version: 1.0.0
3+
description: build docker image

0 commit comments

Comments
 (0)