Skip to content

Commit

Permalink
fix: files artifacts expander image debug tag (#2119)
Browse files Browse the repository at this point in the history
## Description:
files artifacts expander image debug tag
this will generate a new image tag which will be the same as the
original image (because there is no Dockerfile.debug for this project so
far) but will fix the current issue when trying to run a service with
the APIC in debug mode

## Is this change user facing?
NO

## References (if applicable):
  • Loading branch information
leoporoli committed Feb 8, 2024
1 parent fce3844 commit b3f7edd
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions core/files_artifacts_expander/scripts/build.sh
Expand Up @@ -19,6 +19,10 @@ DEFAULT_SKIP_DOCKER_IMAGE_BUILDING=false

DEFAULT_ARCHITECTURE_TO_BUILD="unknown"

DOCKER_DEBUG_IMAGE_NAME_SUFFIX="debug"
DEFAULT_DEBUG_IMAGE=false


if [ "$uname_arch" == "x86_64" ] || [ "$uname_arch" == "amd64" ]; then
DEFAULT_ARCHITECTURE_TO_BUILD="amd64"
elif [ "$uname_arch" == "aarch64" ] || [ "$uname_arch" == "arm64" ]; then
Expand All @@ -29,9 +33,19 @@ MAIN_GO_FILEPATH="${expander_root_dirpath}/main.go"
MAIN_BINARY_OUTPUT_FILENAME="files-artifacts-expander"
MAIN_BINARY_OUTPUT_FILEPATH="${expander_root_dirpath}/${BUILD_DIRNAME}/${MAIN_BINARY_OUTPUT_FILENAME}"

# =============================================================================
# Main Code
# =============================================================================
# ==================================================================================================
# Arg Parsing & Validation
# ==================================================================================================
show_helptext_and_exit() {
echo "Usage: $(basename "${0}") skip_docker_image_building, architecture_to_build, debug_image..."
echo ""
echo " skip_docker_image_building Whether build the Docker image"
echo " architecture_to_build The desired architecture for the project's binaries"
echo " debug_image Whether images should contains the debug server and run in debug mode, this will use the Dockerfile.debug image to build the container"
echo ""
exit 1 # Exit with an error so that if this is accidentally called by CI, the script will fail
}

skip_docker_image_building="${1:-"${DEFAULT_SKIP_DOCKER_IMAGE_BUILDING}"}"
if [ "${skip_docker_image_building}" != "true" ] && [ "${skip_docker_image_building}" != "false" ]; then
echo "Error: Invalid skip-docker-image-building arg '${skip_docker_image_building}'" >&2
Expand All @@ -42,6 +56,15 @@ if [ "${architecture_to_build}" != "amd64" ] && [ "${architecture_to_build}" !=
echo "Error: Invalid architecture-to-build arg '${architecture_to_build}'" >&2
fi

debug_image="${3:-"${DEFAULT_DEBUG_IMAGE}"}"
if [ "${debug_image}" != "true" ] && [ "${debug_image}" != "false" ]; then
echo "Error: Invalid debug_image arg: '${debug_image}'" >&2
show_helptext_and_exit
fi

# =============================================================================
# Main Code
# =============================================================================
# Checks if dockerignore file is in the root path
if ! [ -f "${expander_root_dirpath}"/.dockerignore ]; then
echo "Error: No .dockerignore file found in files artifacts expander root '${expander_root_dirpath}'; this is required so Docker caching is enabled and the image builds remain quick" >&2
Expand Down Expand Up @@ -86,6 +109,11 @@ fi

dockerfile_filepath="${expander_root_dirpath}/Dockerfile"
image_name="${IMAGE_ORG_AND_REPO}:${docker_tag}"
# specifying that this is a image for debugging
if "${debug_image}"; then
image_name="${image_name}-${DOCKER_DEBUG_IMAGE_NAME_SUFFIX}"
fi

load_not_push_image=false
docker_build_script_cmd="${git_repo_dirpath}/scripts/docker-image-builder.sh ${load_not_push_image} ${dockerfile_filepath} ${image_name}"
if ! eval "${docker_build_script_cmd}"; then
Expand Down

0 comments on commit b3f7edd

Please sign in to comment.