Skip to content

Commit

Permalink
buildah-*: re-generate
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Cmiel <[email protected]>
  • Loading branch information
chmeliik committed Sep 12, 2024
1 parent a3b94c1 commit 5d49817
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 24 deletions.
36 changes: 28 additions & 8 deletions task/buildah-oci-ta/0.2/buildah-oci-ta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,35 @@ spec:
# Setting new namespace to run buildah - 2^32-2
echo 'root:1:4294967294' | tee -a /etc/subuid >>/etc/subgid
build_args=()
if [ -n "${BUILD_ARGS_FILE}" ]; then
# Parse BUILD_ARGS_FILE ourselves because dockerfile-json doesn't support it
echo "Parsing ARGs from $BUILD_ARGS_FILE"
mapfile -t build_args < <(
# https://www.mankier.com/1/buildah-build#--build-arg-file
# delete lines that start with #
# delete blank lines
sed -e '/^#/d' -e '/^\s*$/d' "${SOURCE_CODE_DIR}/${BUILD_ARGS_FILE}"
)
fi
# Append BUILD_ARGS
# Note: this may result in multiple --build-arg=KEY=value flags with the same KEY being
# passed to buildah. In that case, the *last* occurrence takes precedence. This is why
# we append BUILD_ARGS after the content of the BUILD_ARGS_FILE - they take precedence.
build_args+=("$@")
BUILD_ARG_FLAGS=()
for build_arg in "${build_args[@]}"; do
BUILD_ARG_FLAGS+=("--build-arg=$build_arg")
done
BASE_IMAGES=$(
dockerfile-json "${BUILD_ARG_FLAGS[@]}" "$dockerfile_path" |
jq -r '.Stages[] | select(.From | .Stage or .Scratch | not) | .BaseName'
)
BUILDAH_ARGS=()
BASE_IMAGES=$(dockerfile-json "$dockerfile_path" | jq -r '.Stages[] | select(.From | .Stage or .Scratch | not) | .BaseName')
if [ "${HERMETIC}" == "true" ]; then
BUILDAH_ARGS+=("--pull=never")
UNSHARE_ARGS="--net"
Expand All @@ -302,13 +328,7 @@ spec:
BUILDAH_ARGS+=("--target=${TARGET_STAGE}")
fi
if [ -n "${BUILD_ARGS_FILE}" ]; then
BUILDAH_ARGS+=("--build-arg-file=$(pwd)/$SOURCE_CODE_DIR/${BUILD_ARGS_FILE}")
fi
for build_arg in "$@"; do
BUILDAH_ARGS+=("--build-arg=$build_arg")
done
BUILDAH_ARGS+=("${BUILD_ARG_FLAGS[@]}")
if [ -n "${ADD_CAPABILITIES}" ]; then
BUILDAH_ARGS+=("--cap-add=${ADD_CAPABILITIES}")
Expand Down
36 changes: 28 additions & 8 deletions task/buildah-remote-oci-ta/0.2/buildah-remote-oci-ta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,35 @@ spec:
# Setting new namespace to run buildah - 2^32-2
echo 'root:1:4294967294' | tee -a /etc/subuid >>/etc/subgid
build_args=()
if [ -n "${BUILD_ARGS_FILE}" ]; then
# Parse BUILD_ARGS_FILE ourselves because dockerfile-json doesn't support it
echo "Parsing ARGs from $BUILD_ARGS_FILE"
mapfile -t build_args < <(
# https://www.mankier.com/1/buildah-build#--build-arg-file
# delete lines that start with #
# delete blank lines
sed -e '/^#/d' -e '/^\s*$/d' "${SOURCE_CODE_DIR}/${BUILD_ARGS_FILE}"
)
fi
# Append BUILD_ARGS
# Note: this may result in multiple --build-arg=KEY=value flags with the same KEY being
# passed to buildah. In that case, the *last* occurrence takes precedence. This is why
# we append BUILD_ARGS after the content of the BUILD_ARGS_FILE - they take precedence.
build_args+=("$@")
BUILD_ARG_FLAGS=()
for build_arg in "${build_args[@]}"; do
BUILD_ARG_FLAGS+=("--build-arg=$build_arg")
done
BASE_IMAGES=$(
dockerfile-json "${BUILD_ARG_FLAGS[@]}" "$dockerfile_path" |
jq -r '.Stages[] | select(.From | .Stage or .Scratch | not) | .BaseName'
)
BUILDAH_ARGS=()
BASE_IMAGES=$(dockerfile-json "$dockerfile_path" | jq -r '.Stages[] | select(.From | .Stage or .Scratch | not) | .BaseName')
if [ "${HERMETIC}" == "true" ]; then
BUILDAH_ARGS+=("--pull=never")
UNSHARE_ARGS="--net"
Expand All @@ -337,13 +363,7 @@ spec:
BUILDAH_ARGS+=("--target=${TARGET_STAGE}")
fi
if [ -n "${BUILD_ARGS_FILE}" ]; then
BUILDAH_ARGS+=("--build-arg-file=$(pwd)/$SOURCE_CODE_DIR/${BUILD_ARGS_FILE}")
fi
for build_arg in "$@"; do
BUILDAH_ARGS+=("--build-arg=$build_arg")
done
BUILDAH_ARGS+=("${BUILD_ARG_FLAGS[@]}")
if [ -n "${ADD_CAPABILITIES}" ]; then
BUILDAH_ARGS+=("--cap-add=${ADD_CAPABILITIES}")
Expand Down
36 changes: 28 additions & 8 deletions task/buildah-remote/0.2/buildah-remote.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,35 @@ spec:
# Setting new namespace to run buildah - 2^32-2
echo 'root:1:4294967294' | tee -a /etc/subuid >> /etc/subgid
build_args=()
if [ -n "${BUILD_ARGS_FILE}" ]; then
# Parse BUILD_ARGS_FILE ourselves because dockerfile-json doesn't support it
echo "Parsing ARGs from $BUILD_ARGS_FILE"
mapfile -t build_args < <(
# https://www.mankier.com/1/buildah-build#--build-arg-file
# delete lines that start with #
# delete blank lines
sed -e '/^#/d' -e '/^\s*$/d' "${SOURCE_CODE_DIR}/${BUILD_ARGS_FILE}"
)
fi
# Append BUILD_ARGS
# Note: this may result in multiple --build-arg=KEY=value flags with the same KEY being
# passed to buildah. In that case, the *last* occurrence takes precedence. This is why
# we append BUILD_ARGS after the content of the BUILD_ARGS_FILE - they take precedence.
build_args+=("$@")
BUILD_ARG_FLAGS=()
for build_arg in "${build_args[@]}"; do
BUILD_ARG_FLAGS+=("--build-arg=$build_arg")
done
BASE_IMAGES=$(
dockerfile-json "${BUILD_ARG_FLAGS[@]}" "$dockerfile_path" |
jq -r '.Stages[] | select(.From | .Stage or .Scratch | not) | .BaseName'
)
BUILDAH_ARGS=()
BASE_IMAGES=$(dockerfile-json "$dockerfile_path" | jq -r '.Stages[] | select(.From | .Stage or .Scratch | not) | .BaseName')
if [ "${HERMETIC}" == "true" ]; then
BUILDAH_ARGS+=("--pull=never")
UNSHARE_ARGS="--net"
Expand All @@ -319,13 +345,7 @@ spec:
BUILDAH_ARGS+=("--target=${TARGET_STAGE}")
fi
if [ -n "${BUILD_ARGS_FILE}" ]; then
BUILDAH_ARGS+=("--build-arg-file=$(pwd)/$SOURCE_CODE_DIR/${BUILD_ARGS_FILE}")
fi
for build_arg in "$@"; do
BUILDAH_ARGS+=("--build-arg=$build_arg")
done
BUILDAH_ARGS+=("${BUILD_ARG_FLAGS[@]}")
if [ -n "${ADD_CAPABILITIES}" ]; then
BUILDAH_ARGS+=("--cap-add=${ADD_CAPABILITIES}")
Expand Down

0 comments on commit 5d49817

Please sign in to comment.