replacing the shell scripts with a Makefile

pull/6/head
Matthias Luebken 2016-03-15 09:49:50 +01:00
parent 90c89e15b6
commit 771354f14a
6 changed files with 47 additions and 137 deletions

View File

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

View File

@ -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
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->

View File

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

View File

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

View File

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

View File

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