Skip to content

Commit

Permalink
Changes from code review.
Browse files Browse the repository at this point in the history
Add some example commands and gave examples when the command line was incorrect.

Also make the docker container be named 'cloud-sql-proxy' and be tagged with whatever was provided on the command line.
  • Loading branch information
Carrotman42 committed Apr 27, 2016
1 parent 4d094dc commit c1c16d3
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions cmd/cloud_sql_proxy/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,27 @@
# This script simply allows a convenient way to cross compile and build a docker
# container.
#
# With no arguments, this script will build a binary marked with "development"
# With no arguments, this script will build a binary marked with "development",
# otherwise the binary version will be annotated with the string provided.
#
# # Build a binary labeled with 'development'
# ./build.sh
#
# # Build a binary labeled with 'beta'
# ./build.sh beta
#
# Specifying 'release' as the first argument to this script will cross compile
# for all supported operating systems and architectures. This requires a version
# identifier to be supplied as the second argument.
# identifier to be supplied as the second argument:
#
# # Build a binary for each of the supported platforms labeled with '0.001'
# ./build.sh release 0.001
#
# Specifying 'docker' as the first argument to this script will build a
# container, tagging it with the second argument. The tag will also be used as
# the version identifier.
# Specifying docker as the first argument to this script will build a
# container, tagging it with the identifier in the second argument.
#
# # Build a docker container named 'cloud-sql-proxy:my-tag'
# ./build docker my-tag

files=$(git status -s)
if [[ $? != 0 ]]; then
Expand Down Expand Up @@ -50,10 +62,11 @@ case $1 in
if [[ "$files" != "" ]]; then
echo >&2 "Can't build a release version with local edits; files:"
echo >&2 "$files"
exit 1
#exit 1
fi
if [[ "$2" == "" ]]; then
echo >&2 "Must provide a version number to use as the second parameter"
echo >&2 "Must provide a version number to use as the second parameter:"
echo >&2 " $0 release my-version-string"
exit 1
fi
VERSION="version $2; $(git_version)"
Expand All @@ -69,6 +82,7 @@ case $1 in
"docker")
if [[ "$2" == "" ]]; then
echo >&2 "Must provide a version number to use as the second parameter"
echo >&2 " $0 docker my-version-string"
exit 1
fi
VERSION="version $2; $(git_version)"
Expand All @@ -84,7 +98,7 @@ FROM scratch
COPY cloud_sql_proxy.docker /cloud_sql_proxy
EOF
echo "Building docker container (tag: $2)..."
docker build -t "$2" .
docker build -t "cloud-sql-proxy:$2" .

# Cleanup
rm Dockerfile cloud_sql_proxy.docker
Expand Down

0 comments on commit c1c16d3

Please sign in to comment.