Skip to content

Commit

Permalink
Merge pull request #434 from chris-rock/chris-rock/build-script
Browse files Browse the repository at this point in the history
allow local image building without pushing
  • Loading branch information
ericchiang committed May 4, 2016
2 parents ba5021a + fd573a3 commit 71e2ae9
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 24 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
sudo: required
services:
- docker
- docker

language: go

Expand Down Expand Up @@ -34,7 +34,7 @@ script:

deploy:
provider: script
script: "./build-docker-push"
script: "./build-docker push"
skip_cleanup: true
on:
branch: master
Expand Down
10 changes: 8 additions & 2 deletions Documentation/dev-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,16 @@ You can also use a copy of `go` hosted inside a Docker container if you prefix y

Once binaries are compiled you can build and push a dex image to quay.io. Before doing this step binaries must be built above using one of the build tools.

```console
./build-docker build
```

If you want to push the build to quay.io, use `./build-docker push`:

```console
export DOCKER_USER=<<your user>>
export DOCKER_PASSWORD=<<your password>>
./build-docker-push
./build-docker push
```

By default the script pushes to `quay.io/coreos/dex`; if you want to push to a different repository, override the `DOCKER_REGISTRY` and `DOCKER_REPO` environment variables.
Expand Down Expand Up @@ -102,7 +108,7 @@ Note that __all of these flags are manditory__. This should add an entry to the

## Updating an existing package

To update an existing package, edit the `glide.yaml` file to the desired verison (most likely a git hash), and run `glide update`.
To update an existing package, edit the `glide.yaml` file to the desired verison (most likely a git hash), and run `glide update`.

```
{{ edit the entry in glide.yaml }}
Expand Down
40 changes: 40 additions & 0 deletions build-docker
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash -e
#
# Build the docker container and push it to quay
# ./build-docker push
#
# Build the docker container locally without pushing to registry
# ./build-docker build

DOCKER_REGISTRY=${DOCKER_REGISTRY:=quay.io}
DOCKER_REPO=${DOCKER_REPO:=coreos/dex}
repo=$DOCKER_REGISTRY/$DOCKER_REPO

version=$(./git-version)

stage() {
echo -e "\033[36m----> $1\033[0m"
}

build() {
stage "build $repo:$version"
docker build -q --rm=true -t $repo:$version .
docker tag $repo:$version $repo:latest
}

push() {
stage "push image $repo:$version"
if [ -v $DOCKER_USER ] || [ -v $DOCKER_PASSWORD ]; then
echo "env variables not set: DOCKER_USER, DOCKER_PASSWORD. skipping login, assuming creds in .dockercfg"
else
echo logging in as $DOCKER_USER
docker login --username="$DOCKER_USER" --password="$DOCKER_PASSWORD" --email="dex@example.com" $DOCKER_REGISTRY
fi

docker push $repo:$version
docker push $repo:latest
}

test -z "$1" && build && push
test "$1" = "push" && build && push
test "$1" = "build" && build
20 changes: 0 additions & 20 deletions build-docker-push

This file was deleted.

0 comments on commit 71e2ae9

Please sign in to comment.