Merge pull request #1454 from proppy/guestbook-go

examples/guestbook-go: build from source and remove bin/docker dep
This commit is contained in:
Joe Beda
2014-09-26 09:18:17 -07:00
4 changed files with 11 additions and 30 deletions

View File

@@ -1,9 +1,9 @@
FROM google/golang:latest
RUN mkdir -p /gopath/src/github.com/GoogleCloudPlatform/ && cd /gopath/src/github.com/GoogleCloudPlatform/ && \
git clone http://github.com/GoogleCloudPlatform/kubernetes && \
cd /gopath/src/github.com/GoogleCloudPlatform/kubernetes/examples/guestbook-go/_src/ && \
go get && go build -o ../bin/guestbook && \
cp ./guestbook/Dockerfile /gopath/src/github.com/GoogleCloudPlatform/kubernetes/examples/guestbook-go/
ADD . /gopath/src/github.com/GoogleCloudPlatform/kubernetes/examples/guestbook-go/_src
CMD docker build --rm --force-rm -t kubernetes/guestbook /gopath/src/github.com/GoogleCloudPlatform/kubernetes/examples/guestbook-go/
WORKDIR /gopath/src/github.com/GoogleCloudPlatform/kubernetes/examples/guestbook-go/
RUN cd _src/ && go get && go build -o ../bin/guestbook
RUN cp _src/guestbook/Dockerfile .
CMD tar cvzf - .

View File

@@ -1,6 +1,6 @@
## Building and releasing Guestbook Image
Guestbook build process employs the usage of docker-in-docker to build an image within another. This requires that the build image has access to the `docker` program's binary, which defaults to the docker available on your host machine. In the case of boot2docker, `DOCKER_BIN` must be set to the binary's location in the boot2docker's vm.
This process employs building two docker images, one compiles the source and the other hosts the compiled binaries.
Releasing the image requires that you have access to the docker registry user account which will host the image.
@@ -9,10 +9,6 @@ To build and release the guestbook image:
cd examples/guestbook-go/_src
./script/release.sh
If you're using boot2docker, specify the `DOCKER_BIN` environment variable
DOCKER_BIN="$(boot2docker ssh which docker)" ./script/release.sh
#### Step by step
If you may want to, you can build and push the image step by step.
@@ -27,10 +23,6 @@ Builds a docker image that builds the app and packages it into a minimal docker
./script/build.sh
If you're using boot2docker, specify the `DOCKER_BIN` environment variable
DOCKER_BIN="$(boot2docker ssh which docker)" ./script/build.sh
###### Push
Accepts an optional tag (defaults to "latest")

View File

@@ -20,16 +20,5 @@ set -o errexit
set -o nounset
set -o pipefail
if [[ "${DOCKER_BIN+set}" == "set" ]]; then
echo "Using DOCKER_BIN=\"${DOCKER_BIN}\" from the environment."
elif DOCKER_BIN=$(which docker); then
echo "Setting DOCKER_BIN=\"${DOCKER_BIN}\" from host machine."
else
echo "Could not find a working docker binary and none passed in DOCKER_BIN." >&2
exit 1
fi
docker build --rm --force-rm -t kubernetes/guestbook-build .
docker run --rm -v "${DOCKER_BIN}:/usr/local/bin/docker" \
-v "/var/run/docker.sock:/var/run/docker.sock" \
-ti --name guestbook-build kubernetes/guestbook-build
docker build --rm --force-rm -t kubernetes/guestbook-builder .
docker run --rm kubernetes/guestbook-builder | docker build -t kubernetes/guestbook -

View File

@@ -20,6 +20,6 @@ set -o errexit
set -o nounset
set -o pipefail
docker rm -f guestbook-build 2> /dev/null || true
docker rmi -f kubernetes/guestbook-build || true
docker rm -f guestbook-builder 2> /dev/null || true
docker rmi -f kubernetes/guestbook-builder || true
docker rmi -f kubernetes/guestbook || true