11#! /usr/bin/env bash
22set -eo pipefail
33shopt -s expand_aliases
4- alias podman=" podman --cgroup-manager=cgroupfs --events-backend=file"
4+
5+ log_level=" error"
6+ if [[ " ${DRYCC_DEBUG} " ]]; then
7+ log_level=" debug"
8+ unset DRYCC_DEBUG
9+ fi
10+
11+ alias podman=' podman --log-level ${log_level} --cgroup-manager=cgroupfs --events-backend=file'
512
613function clean_before_exit {
714 # delay before exiting, so stdout/stderr flushes through the logging system
@@ -29,12 +36,6 @@ function waiting_process {
2936 done
3037}
3138
32- log_level=" error"
33- if [[ " ${DRYCC_DEBUG} " ]]; then
34- log_level=" debug"
35- unset DRYCC_DEBUG
36- fi
37-
3839CONTAINERS_CONFIG_DIR=" ${HOME} " /.config/containers
3940mkdir -p " ${CONTAINERS_CONFIG_DIR} "
4041from_registries_file=" /etc/imagebuilder/registries.conf"
@@ -43,6 +44,8 @@ if [ -f "${from_registries_file}" ]; then
4344 install -D " ${from_registries_file} " " ${CONTAINERS_CONFIG_DIR} " /registries.conf
4445fi
4546
47+ # The directory cannot be changed, the position is hard coded, pack cli needs to be used.
48+ # https://github.com/buildpacks/pack/blob/main/internal/docker/context.go
4649REGISTRY_AUTH_FILE=" ${HOME} " /.docker/config.json
4750readonly REGISTRY_AUTH_FILE
4851from_auths_file=" /etc/imagebuilder/auths.json"
@@ -100,23 +103,27 @@ image_latest_name="${image_base_name}":latest
100103# Building
101104if [[ " ${DRYCC_STACK} " == " container" ]] ; then
102105 echo " ---> Building container"
103- if [[ $log_level == " debug" ]] ; then
104- podman build --tag" ${IMAGE_NAME} " --network host .
105- podman push " ${IMAGE_NAME} " --tls-verify=false
106- else
107- podman build --quiet --tag " ${IMAGE_NAME} " --network host .
108- podman push " ${IMAGE_NAME} " --quiet --tls-verify=false
106+ podman_build=" podman build . --tag ${IMAGE_NAME} --network host"
107+ podman_push=" podman push ${IMAGE_NAME} --tls-verify=false"
108+ if [[ -f .build-env ]] ; then
109+ for build_arg in $( < .build-env )
110+ do
111+ podman_build=" $podman_build --build-arg $build_arg "
112+ done
109113 fi
114+ $podman_build
115+ $podman_push
110116else
111117 echo " ---> Building pack"
112118 echo " ---> Using builder ${pack_builder} "
113119 # podman connection
114- DOCKER_HOST=" unix://$( podman info -f " {{.Host.RemoteSocket.Path}}" ) "
120+ DOCKER_HOST=" unix://$( podman info -f ' {{.Host.RemoteSocket.Path}}' ) "
115121 readonly DOCKER_HOST
116122 export DOCKER_HOST
117123
118124 pack_build=" pack build ${IMAGE_NAME} \
119125 --builder ${pack_builder} \
126+ --lifecycle-image ${pack_builder} \
120127 --env DRYCC_APP=${drycc_app} \
121128 --docker-host ${DOCKER_HOST} \
122129 --previous-image ${image_latest_name} \
0 commit comments