diff --git a/examples/guestbook-go/_src/Makefile b/examples/guestbook-go/_src/Makefile new file mode 100644 index 00000000000..9c89fbcd95f --- /dev/null +++ b/examples/guestbook-go/_src/Makefile @@ -0,0 +1,39 @@ +# Copyright 2016 The Kubernetes Authors All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Build the guestbook-go example + +# Usage: +# [VERSION=v3] [REGISTRY="gcr.io/google_containers"] make build +VERSION?=v3 +REGISTRY?=gcr.io/google_containers + +release: clean build push clean + +# builds a docker image that builds the app and packages it into a minimal docker image +build: + docker build --rm --force-rm -t ${REGISTRY}/guestbook-builder . + docker run --rm ${REGISTRY}/guestbook-builder | docker build -t "${REGISTRY}/guestbook:${VERSION}" - + +# push the image to an registry +push: + gcloud docker push ${REGISTRY}/guestbook:${VERSION} + +# remove previous images and containers +clean: + docker rm -f ${REGISTRY}/guestbook-builder 2> /dev/null || true + docker rmi -f ${REGISTRY}/guestbook-builder || true + docker rmi -f "${REGISTRY}/guestbook:${VERSION}" || true + +.PHONY: release clean build push diff --git a/examples/guestbook-go/_src/README.md b/examples/guestbook-go/_src/README.md index bba1f0dcfa4..fd3d68ad35c 100644 --- a/examples/guestbook-go/_src/README.md +++ b/examples/guestbook-go/_src/README.md @@ -36,36 +36,22 @@ Documentation for other releases can be found at 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. +Releasing the image requires that you have access to the docker registry user account which will host the image. You can specify the registry including the user account by setting the environment variable `REGISTRY`. To build and release the guestbook image: cd examples/guestbook-go/_src - ./script/release.sh + make release -#### Step by step +To build and release the guestbook image with a different registry and version: -If you may want to, you can build and push the image step by step. + VERSION=v4 REGISTRY="docker.io/luebken" make build -###### Start fresh before building +If you want to, you can build and push the image step by step: - ./script/clean.sh 2> /dev/null - -###### Build - -Builds a docker image that builds the app and packages it into a minimal docker image - - ./script/build.sh - -###### Push - -Accepts an optional tag (defaults to "latest") - - ./script/push.sh [TAG] - -###### Clean up - - ./script/clean.sh + make clean + make build + make push diff --git a/examples/guestbook-go/_src/script/build.sh b/examples/guestbook-go/_src/script/build.sh deleted file mode 100755 index 9aee8a1a8ea..00000000000 --- a/examples/guestbook-go/_src/script/build.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -# Copyright 2014 The Kubernetes Authors All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Usage: ./script/build.sh - -set -o errexit -set -o nounset -set -o pipefail - -guestbook_version=${1:-latest} -docker build --rm --force-rm -t kubernetes/guestbook-builder . -docker run --rm kubernetes/guestbook-builder | docker build -t "kubernetes/guestbook:${guestbook_version}" - diff --git a/examples/guestbook-go/_src/script/clean.sh b/examples/guestbook-go/_src/script/clean.sh deleted file mode 100755 index 026b8ad9ec9..00000000000 --- a/examples/guestbook-go/_src/script/clean.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -# Copyright 2014 The Kubernetes Authors All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Usage: ./script/clean.sh - -set -o errexit -set -o nounset -set -o pipefail - -guestbook_version=${1:-latest} -docker rm -f guestbook-builder 2> /dev/null || true -docker rmi -f kubernetes/guestbook-builder || true -docker rmi -f "kubernetes/guestbook:${guestbook_version}" || true diff --git a/examples/guestbook-go/_src/script/push.sh b/examples/guestbook-go/_src/script/push.sh deleted file mode 100755 index 2d359ccc0bf..00000000000 --- a/examples/guestbook-go/_src/script/push.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -# Copyright 2014 The Kubernetes Authors All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Usage: ./script/push.sh [TAG] - -set -o errexit -set -o nounset -set -o pipefail - -guestbook_version=${1:-latest} -docker push "kubernetes/guestbook:${guestbook_version}" diff --git a/examples/guestbook-go/_src/script/release.sh b/examples/guestbook-go/_src/script/release.sh deleted file mode 100755 index 34af8fb414f..00000000000 --- a/examples/guestbook-go/_src/script/release.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash - -# Copyright 2014 The Kubernetes Authors All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Usage: ./script/release.sh [TAG] - -set -o errexit -set -o nounset -set -o pipefail - -base_dir=$(dirname "$0") -base_dir=$(cd "${base_dir}" && pwd) - -guestbook_version=${1:-latest} - -echo " ---> Cleaning up before building..." -"${base_dir}/clean.sh" "${guestbook_version}" 2> /dev/null - -echo " ---> Building..." -"${base_dir}/build.sh" "${guestbook_version}" - -echo " ---> Pushing kubernetes/guestbook:${guestbook_version}..." -"${base_dir}/push.sh" "${guestbook_version}" - -echo " ---> Cleaning up..." -"${base_dir}/clean.sh" "${guestbook_version}" - -echo " ---> Done."