From fd573a3b8fe16a85641ca3ae321ceeddb80f8aff Mon Sep 17 00:00:00 2001 From: Christoph Hartmann Date: Wed, 4 May 2016 14:17:03 +0200 Subject: [PATCH] allow local image building without pushing --- .travis.yml | 4 ++-- Documentation/dev-guide.md | 10 ++++++++-- build-docker | 40 ++++++++++++++++++++++++++++++++++++++ build-docker-push | 20 ------------------- 4 files changed, 50 insertions(+), 24 deletions(-) create mode 100755 build-docker delete mode 100755 build-docker-push diff --git a/.travis.yml b/.travis.yml index 0b00b022..f553603d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/Documentation/dev-guide.md b/Documentation/dev-guide.md index 611fd446..e9dcdf9a 100644 --- a/Documentation/dev-guide.md +++ b/Documentation/dev-guide.md @@ -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=<> export DOCKER_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 }} diff --git a/build-docker b/build-docker new file mode 100755 index 00000000..47de7278 --- /dev/null +++ b/build-docker @@ -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 diff --git a/build-docker-push b/build-docker-push deleted file mode 100755 index cd9e9662..00000000 --- a/build-docker-push +++ /dev/null @@ -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