Skip to content

Commit

Permalink
Fix docker build (#22)
Browse files Browse the repository at this point in the history
* Fix docker-build.sh

A few bash variables were protected, causing
the build stage to fail.

Please consider using .ci/build-images instead
  • Loading branch information
PFigs authored May 21, 2019
1 parent 7084e4c commit 4ca063f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
3 changes: 1 addition & 2 deletions container/build_defaults.env
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ DOCKER_IMAGE_ARM_NAME="wm-gateway-rpi"
DOCKER_IMAGE_TAG="latest"
DOCKER_IMAGE_TAG_PYTHON_VERSION="false"

DOCKER_BUILD_CACHE=""
DOCKER_BUILD_CACHE=
#DOCKER_ARM_BUILD_TARGET="wm-lxgw-rpi"
#DOCKER_X86_BUILD_TARGET="wm-lxgw"

Expand All @@ -15,4 +15,3 @@ DOCKER_PLATFORM="x86"
# use to specify the the messaging or transport version
#DOCKER_BUILD_ARGS="--build-arg WM_MESSAGING_PKG=wirepas_messaging-1.1.0* \
# --build-arg WM_TRANSPORT_PKG=wirepas_gateway-1.1.0*"

28 changes: 14 additions & 14 deletions container/docker-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#

trap 'echo "Aborting due to errexit on line $LINENO. Exit code: $?" >&2' ERR
set -x
set -e
set -o nounset
set -o errexit
Expand Down Expand Up @@ -44,17 +45,17 @@ _defaults()

# default defaults if not defined in build file
DOCKER_IMAGE_TAG=${DOCKER_IMAGE_TAG:-"latest"}
DOCKER_BUILD_CACHE=${DOCKER_BUILD_CACHE:-""}
DOCKER_BUILD_CACHE=${DOCKER_BUILD_CACHE:-}
DOCKER_PLATFORM=${DOCKER_PLATFORM:-"x86"}
DOCKER_BUILD_TARGET=${DOCKER_BUILD_TARGET:-""}
DOCKER_BUILD_TARGET=${DOCKER_BUILD_TARGET:-}
DOCKER_FILE=${DOCKER_FILE:-"./container/dev/Dockerfile"}
DOCKER_REPO=${DOCKER_REPO:-""}
DOCKER_REPO=${DOCKER_REPO:-}
DOCKER_PUSH=${DOCKER_PUSH:-"false"}
DOCKER_SKIP_BUILD=${DOCKER_SKIP_BUILD:-"false"}
DOCKER_BUILD_ARGS=${DOCKER_BUILD_ARGS:-""}
DOCKER_BUILD_ARGS=${DOCKER_BUILD_ARGS:-}

DOCKER_IMAGE_ARM_NAME=${DOCKER_IMAGE_ARM_NAME:-""}
DOCKER_ARM_BUILD_TARGET=${DOCKER_ARM_BUILD_TARGET:-""}
DOCKER_IMAGE_ARM_NAME=${DOCKER_IMAGE_ARM_NAME:-}
DOCKER_ARM_BUILD_TARGET=${DOCKER_ARM_BUILD_TARGET:-}

DOCKER_IMAGE_TAG_PYTHON_VERSION=${DOCKER_IMAGE_TAG_PYTHON_VERSION:-"false"}
DOCKER_BUILD_GIT_HISTORY_LENGTH=${DOCKER_BUILD_GIT_HISTORY_LENGTH:-"10"}
Expand Down Expand Up @@ -95,7 +96,6 @@ _parse_build_default_path()
while [[ "${#}" -gt 0 ]]
do
key="${1}"
echo "${key}"
case "${key}" in
--build-defaults |--build_defaults)
PATH_PROJECT_DEFAULTS_PATH="${2}"
Expand All @@ -118,7 +118,6 @@ _parse()
while [[ "${#}" -gt 0 ]]
do
key="${1}"
echo "${key}"
case "${key}" in
--skip-build | --skip_build)
DOCKER_SKIP_BUILD="true"
Expand Down Expand Up @@ -203,18 +202,20 @@ _build()

_get_build_history || true
echo "building ${DOCKER_FILE} ${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG} [${DOCKER_BUILD_CACHE}] ${DOCKER_BUILD_ARGS}"
#shellcheck disable=SC2086
docker build \
--compress "${DOCKER_BUILD_CACHE}" \
--compress ${DOCKER_BUILD_CACHE} \
-t "${DOCKER_IMAGE_NAME}":"${DOCKER_IMAGE_TAG}" . \
-f "${DOCKER_FILE}" \
"${DOCKER_BUILD_TARGET}" \
"${DOCKER_BUILD_ARGS}"
-f ${DOCKER_FILE} \
${DOCKER_BUILD_TARGET} \
${DOCKER_BUILD_ARGS}
fi
}

_repo()
{
if [[ ! -z "${DOCKER_REPO}" ]]
#shellcheck disable=SC2086
if [[ ! -z ${DOCKER_REPO} ]]
then
echo "tagging ${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG} --> ${DOCKER_REPO}"
docker tag "${DOCKER_IMAGE_NAME}":"${DOCKER_IMAGE_TAG}" "${DOCKER_REPO}"/"${DOCKER_IMAGE_NAME}":"${DOCKER_IMAGE_TAG}"
Expand All @@ -241,4 +242,3 @@ _main()
}

_main "${@}"

0 comments on commit 4ca063f

Please sign in to comment.