Merge pull request #434 from chris-rock/chris-rock/build-script

allow local image building without pushing
This commit is contained in:
Eric Chiang 2016-05-04 08:23:12 -07:00
commit 71e2ae9899
4 changed files with 50 additions and 24 deletions

View file

@ -1,6 +1,6 @@
sudo: required
services:
- docker
- docker
language: go
@ -34,7 +34,7 @@ script:
deploy:
provider: script
script: "./build-docker-push"
script: "./build-docker push"
skip_cleanup: true
on:
branch: master

View file

@ -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.
@ -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 }}

40
build-docker Executable file
View file

@ -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

View file

@ -1,20 +0,0 @@
#!/bin/bash -e
DOCKER_REGISTRY=${DOCKER_REGISTRY:=quay.io}
DOCKER_REPO=${DOCKER_REPO:=coreos/dex}
repo=$DOCKER_REGISTRY/$DOCKER_REPO
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
version=$(./git-version)
docker build -q --rm=true -t $repo:$version .
docker tag -f $repo:$version $repo:latest
docker push $repo:$version
docker push $repo:latest