Skip to content

Commit

Permalink
Add a way to install extra packages in the imges
Browse files Browse the repository at this point in the history
Long due change to provide a way to automatically install extra
packages in the local custom built images.
This can be useful to test different versions of packages or just
test new dependencies or tools.
Also adding a visual separation to some build logic parts.
  • Loading branch information
elfosardo committed Dec 9, 2020
1 parent 1b6768f commit 1350689
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
12 changes: 11 additions & 1 deletion 04_setup_ironic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ fi

for IMAGE_VAR in $(env | grep "_LOCAL_IMAGE=" | grep -o "^[^=]*") ; do
IMAGE=${!IMAGE_VAR}
BUILD_COMMAND_ARGS=""

sudo -E podman pull --authfile $PULL_SECRET_FILE $OPENSHIFT_RELEASE_IMAGE

Expand Down Expand Up @@ -73,14 +74,23 @@ for IMAGE_VAR in $(env | grep "_LOCAL_IMAGE=" | grep -o "^[^=]*") ; do
git fetch origin pull/${IMAGE_PR}/head:pr${IMAGE_PR}
git checkout pr${IMAGE_PR}
fi

# If we set extra packages, we add them to the main pkgs base file
EXTRA_PKGS_FILE_NAME=${IMAGE_VAR/_LOCAL_IMAGE}_EXTRA_PACKAGES
EXTRA_PKGS_FILE=${!EXTRA_PKGS_FILE_NAME:-}
if [[ -n $EXTRA_PKGS_FILE ]]; then
cp $EXTRA_PKGS_FILE "$REPOPATH"
BUILD_COMMAND_ARGS+=" --build-arg EXTRA_PKGS_LIST=$EXTRA_PKGS_FILE"
fi

# If we built a custom base image, we should use it as a new base in
# the Dockerfile to prevent discrepancies between locally built images.
# Replace all FROM entries with the base-image.
if [[ -n ${BASE_IMAGE_DIR:-} ]]; then
sed -i "s/^FROM [^ ]*/FROM ${BASE_IMAGE_DIR}/g" ${IMAGE_DOCKERFILE}
fi
sudo podman build --authfile $PULL_SECRET_FILE -t ${!IMAGE_VAR} -f $IMAGE_DOCKERFILE .

sudo podman build --authfile $PULL_SECRET_FILE $BUILD_COMMAND_ARGS -t ${!IMAGE_VAR} -f $IMAGE_DOCKERFILE .
cd -
sudo podman push --tls-verify=false --authfile $PULL_SECRET_FILE ${!IMAGE_VAR} ${!IMAGE_VAR}
fi
Expand Down
4 changes: 4 additions & 0 deletions config_example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ set -x
# NOTE: If a checkout already exists in $HOME, it won't be re-created.
# NOTE: You must set CUSTOM_REPO_FILE to build some OpenShift images, e.g. ironic ones.

# Use <IMAGE_NAME>_EXTRA_PACKAGES to set a file with extra packages to install
# one per line. They will be added to the image. For example:
# export IRONIC_IPA_DOWNLOADER_EXTRA_PACKAGES=ipa-downloader-extra-pkgs.txt

# Set this variable to point the custom base image to a different location
# It can be an absolute path or a local path under the dev-scripts dir
# export BASE_IMAGE_DIR=base-image
Expand Down

0 comments on commit 1350689

Please sign in to comment.