mirror of https://github.com/hashicorp/consul
Matt Keeler
7 years ago
14 changed files with 859 additions and 64 deletions
@ -0,0 +1,13 @@
|
||||
FROM golang:latest as builder |
||||
ARG GIT_COMMIT |
||||
ARG GIT_DIRTY |
||||
ARG GIT_DESCRIBE |
||||
WORKDIR /go/src/github.com/hashicorp/consul |
||||
ENV CONSUL_DEV=1 |
||||
ENV COLORIZE=0 |
||||
Add . /go/src/github.com/hashicorp/consul/ |
||||
RUN make |
||||
|
||||
FROM consul:latest |
||||
|
||||
COPY --from=builder /go/src/github.com/hashicorp/consul/bin/consul /bin |
@ -1,28 +0,0 @@
|
||||
ifeq ($(FORCE_REBUILD),1) |
||||
NOCACHE=--no-cache
|
||||
else |
||||
NOCACHE=
|
||||
endif |
||||
GO_BUILD_TAG?=consul-build-go
|
||||
UI_BUILD_TAG?=consul-build-ui
|
||||
UI_LEGACY_BUILD_TAG?=consul-build-ui-legacy
|
||||
|
||||
DOCKER_BUILD_QUIET?=1
|
||||
ifeq (${DOCKER_BUILD_QUIET},1) |
||||
QUIET=-q
|
||||
else |
||||
QUIET=
|
||||
endif |
||||
|
||||
images: go-build-image ui-build-image ui-legacy-build-image |
||||
|
||||
go-build-image: |
||||
docker build $(NOCACHE) $(QUIET) -t $(GO_BUILD_TAG) -f Build-Go.dockerfile .
|
||||
|
||||
ui-build-image: |
||||
docker build $(NOCACHE) $(QUIET) -t $(UI_BUILD_TAG) -f Build-UI.dockerfile .
|
||||
|
||||
ui-legacy-build-image: |
||||
docker build $(NOCACHE) $(QUIET) -t $(UI_LEGACY_BUILD_TAG) -f Build-UI-Legacy.dockerfile .
|
||||
|
||||
.PHONY: images go-build-image ui-build-image ui-legacy-build-image |
@ -0,0 +1,141 @@
|
||||
#!/bin/bash |
||||
SCRIPT_NAME="$(basename ${BASH_SOURCE[0]})" |
||||
pushd $(dirname ${BASH_SOURCE[0]}) > /dev/null |
||||
SCRIPT_DIR=$(pwd) |
||||
pushd ../.. > /dev/null |
||||
SOURCE_DIR=$(pwd) |
||||
popd > /dev/null |
||||
pushd ../functions > /dev/null |
||||
FN_DIR=$(pwd) |
||||
popd > /dev/null |
||||
popd > /dev/null |
||||
|
||||
source "${SCRIPT_DIR}/functions.sh" |
||||
|
||||
function usage { |
||||
cat <<-EOF |
||||
Usage: ${SCRIPT_NAME} (consul|ui|ui-legacy|static-assets) [<options ...>] |
||||
|
||||
Options: |
||||
-i | --image IMAGE Alternative Docker image to run the build within. |
||||
|
||||
-s | --source DIR Path to source to build. |
||||
Defaults to "${SOURCE_DIR}" |
||||
|
||||
-r | --refresh Enables refreshing the docker image prior to building. |
||||
|
||||
-h | --help Print this help text. |
||||
EOF |
||||
} |
||||
|
||||
function err_usage { |
||||
err "$1" |
||||
err "" |
||||
err "$(usage)" |
||||
} |
||||
|
||||
function main { |
||||
declare image= |
||||
declare sdir="${SOURCE_DIR}" |
||||
declare -i refresh=0 |
||||
declare command="$1" |
||||
|
||||
# get rid of the subcommand |
||||
shift |
||||
|
||||
while test $# -gt 0 |
||||
do |
||||
case "$1" in |
||||
-h | --help ) |
||||
usage |
||||
return 0 |
||||
;; |
||||
-i | --image ) |
||||
if test -z "$2" |
||||
then |
||||
err_usage "ERROR: option -i/--image requires an argument" |
||||
return 1 |
||||
fi |
||||
|
||||
image="$2" |
||||
shift 2 |
||||
;; |
||||
-s | --source ) |
||||
if test -z "$2" |
||||
then |
||||
err_usage "ERROR: option -s/--source requires an argument" |
||||
return 1 |
||||
fi |
||||
|
||||
if ! test -d "$2" |
||||
then |
||||
err_usage "ERROR: '$2' is not a directory and not suitable for the value of -s/--source" |
||||
return 1 |
||||
fi |
||||
|
||||
sdir="$2" |
||||
shift 2 |
||||
;; |
||||
-r | --refresh ) |
||||
refresh=1 |
||||
shift |
||||
;; |
||||
* ) |
||||
err_usage "ERROR: Unknown argument '$1'" |
||||
return 1 |
||||
;; |
||||
esac |
||||
done |
||||
|
||||
case "${command}" in |
||||
consul ) |
||||
if is_set "${refresh}" |
||||
then |
||||
status_stage "==> Refreshing Consul build container image" |
||||
export GO_BUILD_TAG="${image:-${GO_BUILD_CONTAINER_DEFAULT}}" |
||||
refresh_docker_images "${sdir}" go-build-image || return 1 |
||||
fi |
||||
status_stage "==> Building Consul" |
||||
build_consul "${sdir}" "" "${image}" || return 1 |
||||
;; |
||||
static-assets ) |
||||
if is_set "${refresh}" |
||||
then |
||||
status_stage "==> Refreshing Consul build container image" |
||||
export GO_BUILD_TAG="${image:-${GO_BUILD_CONTAINER_DEFAULT}}" |
||||
refresh_docker_images "${sdir}" go-build-image || return 1 |
||||
fi |
||||
status_stage "==> Building Static Assets" |
||||
build_assetfs "${sdir}" "${image}" || return 1 |
||||
;; |
||||
ui ) |
||||
if is_set "${refresh}" |
||||
then |
||||
status_stage "==> Refreshing UI build container image" |
||||
export UI_BUILD_TAG="${image:-${UI_BUILD_CONTAINER_DEFAULT}}" |
||||
refresh_docker_images "${sdir}" ui-build-image || return 1 |
||||
fi |
||||
status_stage "==> Building UI" |
||||
build_ui "${sdir}" "${image}" || return 1 |
||||
;; |
||||
ui-legacy ) |
||||
if is_set "${refresh}" |
||||
then |
||||
status_stage "==> Refreshing Legacy UI build container image" |
||||
export UI_LEAGCY_BUILD_TAG="${image:-${UI_LEGACY_BUILD_CONTAINER_DEFAULT}}" |
||||
refresh_docker_images "${sdir}" ui-legacy-build-image || return 1 |
||||
fi |
||||
status_stage "==> Building UI" |
||||
build_ui_legacy "${sdir}" "${image}" || return 1 |
||||
;; |
||||
* ) |
||||
err_usage "ERROR: Unknown command: '${command}'" |
||||
return 1 |
||||
;; |
||||
esac |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
main $@ |
||||
exit $? |
@ -0,0 +1,102 @@
|
||||
#!/bin/bash |
||||
SCRIPT_NAME="$(basename ${BASH_SOURCE[0]})" |
||||
pushd $(dirname ${BASH_SOURCE[0]}) > /dev/null |
||||
SCRIPT_DIR=$(pwd) |
||||
pushd ../.. > /dev/null |
||||
SOURCE_DIR=$(pwd) |
||||
popd > /dev/null |
||||
pushd ../functions > /dev/null |
||||
FN_DIR=$(pwd) |
||||
popd > /dev/null |
||||
popd > /dev/null |
||||
|
||||
source "${SCRIPT_DIR}/functions.sh" |
||||
|
||||
function usage { |
||||
cat <<-EOF |
||||
Usage: ${SCRIPT_NAME} (consul|ui|ui-legacy|static-assets) [<options ...>] |
||||
|
||||
Options: |
||||
|
||||
-s | --source DIR Path to source to build. |
||||
Defaults to "${SOURCE_DIR}" |
||||
|
||||
-o | --os OSES Space separated string of OS |
||||
platforms to build. |
||||
|
||||
-a | --arch ARCH Space separated string of |
||||
architectures to build. |
||||
|
||||
-h | --help Print this help text. |
||||
EOF |
||||
} |
||||
|
||||
function err_usage { |
||||
err "$1" |
||||
err "" |
||||
err "$(usage)" |
||||
} |
||||
|
||||
function main { |
||||
declare sdir="${SOURCE_DIR}" |
||||
declare build_os="" |
||||
declare build_arch="" |
||||
|
||||
|
||||
while test $# -gt 0 |
||||
do |
||||
case "$1" in |
||||
-h | --help ) |
||||
usage |
||||
return 0 |
||||
;; |
||||
-s | --source ) |
||||
if test -z "$2" |
||||
then |
||||
err_usage "ERROR: option -s/--source requires an argument" |
||||
return 1 |
||||
fi |
||||
|
||||
if ! test -d "$2" |
||||
then |
||||
err_usage "ERROR: '$2' is not a directory and not suitable for the value of -s/--source" |
||||
return 1 |
||||
fi |
||||
|
||||
sdir="$2" |
||||
shift 2 |
||||
;; |
||||
-o | --os ) |
||||
if test -z "$2" |
||||
then |
||||
err_usage "ERROR: option -o/--os requires an argument" |
||||
return 1 |
||||
fi |
||||
|
||||
build_os="$2" |
||||
shift 2 |
||||
;; |
||||
-a | --arch ) |
||||
if test -z "$2" |
||||
then |
||||
err_usage "ERROR: option -a/--arch requires an argument" |
||||
return 1 |
||||
fi |
||||
|
||||
build_arch="$2" |
||||
shift 2 |
||||
;; |
||||
* ) |
||||
err_usage "ERROR: Unknown argument: '$1'" |
||||
return 1 |
||||
;; |
||||
esac |
||||
done |
||||
|
||||
build_consul_local "${sdir}" "${build_os}" "${build_arch}" || return 1 |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
main $@ |
||||
exit $? |
@ -0,0 +1,87 @@
|
||||
#!/bin/bash |
||||
SCRIPT_NAME="$(basename ${BASH_SOURCE[0]})" |
||||
pushd $(dirname ${BASH_SOURCE[0]}) > /dev/null |
||||
SCRIPT_DIR=$(pwd) |
||||
pushd ../.. > /dev/null |
||||
SOURCE_DIR=$(pwd) |
||||
popd > /dev/null |
||||
pushd ../functions > /dev/null |
||||
FN_DIR=$(pwd) |
||||
popd > /dev/null |
||||
popd > /dev/null |
||||
|
||||
source "${SCRIPT_DIR}/functions.sh" |
||||
|
||||
function usage { |
||||
cat <<-EOF |
||||
Usage: ${SCRIPT_NAME} [<options ...>] |
||||
|
||||
Options: |
||||
-s | --source DIR Path to source to build. |
||||
Defaults to "${SOURCE_DIR}" |
||||
|
||||
-w | --website Publish to releases.hashicorp.com |
||||
|
||||
-g | --git Push release commit and tag to Git |
||||
|
||||
-h | --help Print this help text. |
||||
EOF |
||||
} |
||||
|
||||
function err_usage { |
||||
err "$1" |
||||
err "" |
||||
err "$(usage)" |
||||
} |
||||
|
||||
function main { |
||||
declare sdir="${SOURCE_DIR}" |
||||
declare -i website=0 |
||||
declare -i git_push=0 |
||||
|
||||
while test $# -gt 0 |
||||
do |
||||
case "$1" in |
||||
-h | --help ) |
||||
usage |
||||
return 0 |
||||
;; |
||||
-s | --source ) |
||||
if test -z "$2" |
||||
then |
||||
err_usage "ERROR: option -s/--source requires an argument" |
||||
return 1 |
||||
fi |
||||
|
||||
if ! test -d "$2" |
||||
then |
||||
err_usage "ERROR: '$2' is not a directory and not suitable for the value of -s/--source" |
||||
return 1 |
||||
fi |
||||
|
||||
sdir="$2" |
||||
shift 2 |
||||
;; |
||||
-w | --website ) |
||||
website=1 |
||||
shift |
||||
;; |
||||
-g | --git ) |
||||
git_push=1 |
||||
shift |
||||
;; |
||||
*) |
||||
err_usage "ERROR: Unknown argument: '$1'" |
||||
return 1 |
||||
;; |
||||
esac |
||||
done |
||||
|
||||
publish_release "${sdir}" "${git_push}" "${website}" || return 1 |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
main $@ |
||||
exit $? |
||||
|
@ -0,0 +1,131 @@
|
||||
#!/bin/bash |
||||
SCRIPT_NAME="$(basename ${BASH_SOURCE[0]})" |
||||
pushd $(dirname ${BASH_SOURCE[0]}) > /dev/null |
||||
SCRIPT_DIR=$(pwd) |
||||
pushd ../.. > /dev/null |
||||
SOURCE_DIR=$(pwd) |
||||
popd > /dev/null |
||||
pushd ../functions > /dev/null |
||||
FN_DIR=$(pwd) |
||||
popd > /dev/null |
||||
popd > /dev/null |
||||
|
||||
source "${SCRIPT_DIR}/functions.sh" |
||||
|
||||
function usage { |
||||
cat <<-EOF |
||||
Usage: ${SCRIPT_NAME} [<options ...>] |
||||
|
||||
Options: |
||||
-s | --source DIR Path to source to build. |
||||
Defaults to "${SOURCE_DIR}" |
||||
|
||||
-t | --tag BOOL Whether to add a release commit and tag the build |
||||
Defaults to 1. |
||||
|
||||
-b | --build BOOL Whether to perform the build of the ui's, assetfs and |
||||
binaries. Defaults to 1. |
||||
|
||||
-S | --sign BOOL Whether to sign the generated SHA256SUMS file. |
||||
Defaults to 1. |
||||
|
||||
-g | --gpg-key KEY Alternative GPG key to use for signing operations. |
||||
Defaults to ${HASHICORP_GPG_KEY} |
||||
|
||||
-v | --version VERSION The version of Consul to be built. If not specified |
||||
the version will be parsed from the source. |
||||
|
||||
-d | --date DATE The release date. Defaults to today. |
||||
|
||||
-h | --help Print this help text. |
||||
EOF |
||||
} |
||||
|
||||
function err_usage { |
||||
err "$1" |
||||
err "" |
||||
err "$(usage)" |
||||
} |
||||
|
||||
function ensure_arg { |
||||
if test -z "$2" |
||||
then |
||||
err_usage "ERROR: option $1 requires an argument" |
||||
return 1 |
||||
fi |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
function main { |
||||
declare sdir="${SOURCE_DIR}" |
||||
declare -i do_tag=1 |
||||
declare -i do_build=1 |
||||
declare -i do_sign=1 |
||||
declare gpg_key="${HASHICORP_GPG_KEY}" |
||||
declare version="" |
||||
declare release_date=$(date +"%B %d, %Y") |
||||
|
||||
while test $# -gt 0 |
||||
do |
||||
case "$1" in |
||||
-h | --help ) |
||||
usage |
||||
return 0 |
||||
;; |
||||
-s | --source ) |
||||
ensure_arg "-s/--source" "$2" || return 1 |
||||
|
||||
if ! test -d "$2" |
||||
then |
||||
err_usage "ERROR: '$2' is not a directory and not suitable for the value of -s/--source" |
||||
return 1 |
||||
fi |
||||
|
||||
sdir="$2" |
||||
shift 2 |
||||
;; |
||||
-t | --tag ) |
||||
ensure_arg "-t/--tag" "$2" || return 1 |
||||
do_tag="$2" |
||||
shift 2 |
||||
;; |
||||
-b | --build ) |
||||
ensure_arg "-b/--build" "$2" || return 1 |
||||
do_build="$2" |
||||
shift 2 |
||||
;; |
||||
-S | --sign ) |
||||
ensure_arg "-s/--sign" "$2" || return 1 |
||||
do_sign="$2" |
||||
shift 2 |
||||
;; |
||||
-g | --gpg-key ) |
||||
ensure_arg "-g/--gpg-key" "$2" || return 1 |
||||
gpg_key="$2" |
||||
shift 2 |
||||
;; |
||||
-v | --version ) |
||||
ensure_arg "-v/--version" "$2" || return 1 |
||||
version="$2" |
||||
shift 2 |
||||
;; |
||||
-d | --date) |
||||
ensure_arg "-d/--date" "$2" || return 1 |
||||
release_date="$2" |
||||
shift 2 |
||||
;; |
||||
*) |
||||
err_usage "ERROR: Unknown argument: '$1'" |
||||
return 1 |
||||
;; |
||||
esac |
||||
done |
||||
|
||||
build_release "${sdir}" "${do_tag}" "${do_build}" "${do_sign}" "${version}" "${release_date}" "${gpg_key}" |
||||
return $? |
||||
} |
||||
|
||||
main $@ |
||||
exit $? |
||||
|
@ -0,0 +1,87 @@
|
||||
#!/bin/bash |
||||
SCRIPT_NAME="$(basename ${BASH_SOURCE[0]})" |
||||
pushd $(dirname ${BASH_SOURCE[0]}) > /dev/null |
||||
SCRIPT_DIR=$(pwd) |
||||
pushd ../.. > /dev/null |
||||
SOURCE_DIR=$(pwd) |
||||
popd > /dev/null |
||||
pushd ../functions > /dev/null |
||||
FN_DIR=$(pwd) |
||||
popd > /dev/null |
||||
popd > /dev/null |
||||
|
||||
source "${SCRIPT_DIR}/functions.sh" |
||||
|
||||
function usage { |
||||
cat <<-EOF |
||||
Usage: ${SCRIPT_NAME} [<options ...>] |
||||
|
||||
Options: |
||||
-s | --source DIR Path to source to build. |
||||
Defaults to "${SOURCE_DIR}" |
||||
|
||||
-r | --release Include the release in the version |
||||
|
||||
-g | --git Take git variables into account |
||||
|
||||
-h | --help Print this help text. |
||||
EOF |
||||
} |
||||
|
||||
function err_usage { |
||||
err "$1" |
||||
err "" |
||||
err "$(usage)" |
||||
} |
||||
|
||||
function main { |
||||
declare sdir="${SOURCE_DIR}" |
||||
declare -i release=0 |
||||
declare -i git_info=0 |
||||
|
||||
while test $# -gt 0 |
||||
do |
||||
case "$1" in |
||||
-h | --help ) |
||||
usage |
||||
return 0 |
||||
;; |
||||
-s | --source ) |
||||
if test -z "$2" |
||||
then |
||||
err_usage "ERROR: option -s/--source requires an argument" |
||||
return 1 |
||||
fi |
||||
|
||||
if ! test -d "$2" |
||||
then |
||||
err_usage "ERROR: '$2' is not a directory and not suitable for the value of -s/--source" |
||||
return 1 |
||||
fi |
||||
|
||||
sdir="$2" |
||||
shift 2 |
||||
;; |
||||
-r | --release ) |
||||
release=1 |
||||
shift |
||||
;; |
||||
-g | --git ) |
||||
git_info=1 |
||||
shift |
||||
;; |
||||
*) |
||||
err_usage "ERROR: Unknown argument: '$1'" |
||||
return 1 |
||||
;; |
||||
esac |
||||
done |
||||
|
||||
parse_version "${sdir}" "${release}" "${git_info}" || return 1 |
||||
|
||||
return 0 |
||||
} |
||||
|
||||
main $@ |
||||
exit $? |
||||
|
Loading…
Reference in new issue