Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a new hotfix image build script #959

Merged
merged 1 commit into from
May 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 5 additions & 7 deletions bin/build
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@ TAG=latest

ARCH=`uname -m`

RPM_BUILD_OPTIONS=${RPM_BUILD_OPTIONS:-""}
RPM_BUILD_IMAGE=${RPM_BUILD_IMAGE:-"manageiq/rpm_build:$TAG"}
RPM_PREFIX=${RPM_PREFIX:-"manageiq"}
Comment on lines -7 to -9
Copy link
Member

@Fryguy Fryguy May 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That being said I never understood building the RPMs as part of this script - always felt like if that's what's wanted the rpms should be built separately and then passed in.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally downstream builds are using RPM_PREFIX


while getopts "t:d:r:hblnops" opt; do
while getopts "t:c:d:r:hblnops" opt; do
case $opt in
b) REBUILD_RPM="true" ;;
c) CONTAINER_PREFIX=$OPTARG ;;
d) BASE_DIR=$OPTARG ;;
l) LOCAL_RPM="true" ;;
n) NO_CACHE="true" ;;
Expand All @@ -19,7 +16,7 @@ while getopts "t:d:r:hblnops" opt; do
r) REPO=$OPTARG ;;
s) RELEASE_BUILD="true" ;;
t) TAG=$OPTARG ;;
h) echo "Usage: $0 [-hblnops] [-d BASE_DIR] [-r IMAGE_REPOSITORY] [-t IMAGE_TAG]"; exit 1
h) echo "Usage: $0 [-hblnops] [-c CONTAINER_PREFIX] [-d BASE_DIR] [-r IMAGE_REPOSITORY] [-t IMAGE_TAG]"; exit 1
esac
done

Expand All @@ -28,10 +25,11 @@ if [ -n "$LOCAL_RPM" ] && [ -n "$REBUILD_RPM" ]; then
exit 1
fi

REPO=${REPO:-docker.io/manageiq}
BASE_DIR=${BASE_DIR:-$PWD}
CONTAINER_PREFIX=${CONTAINER_PREFIX:-manageiq}
Copy link
Member

@Fryguy Fryguy May 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume we'll start using this in the future?

I mean for the image names that we loop over

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but for now we can at least have the same options.

IMAGE_DIR="$BASE_DIR/images"
OPERATOR_DIR="$BASE_DIR/manageiq-operator"
REPO=${REPO:-docker.io/manageiq}

CONTAINER_COMMAND="$(which podman &>/dev/null && echo "podman" || echo "docker")"

Expand Down
69 changes: 69 additions & 0 deletions bin/build_hotfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/bin/bash

TAG=latest

ARCH=`uname -m`

while getopts "t:c:d:r:hblnops" opt; do
case $opt in
b) REBUILD_RPM="true" ;;
c) CONTAINER_PREFIX=$OPTARG ;;
d) BASE_DIR=$OPTARG ;;
l) LOCAL_RPM="true" ;;
n) NO_CACHE="true" ;;
o) NO_OPERATOR="true" ;;
p) PUSH="true" ;;
r) REPO=$OPTARG ;;
s) RELEASE_BUILD="true" ;;
t) TAG=$OPTARG ;;
h) echo "Usage: $0 [-hblnops] [-c CONTAINER_PREFIX] [-d BASE_DIR] [-r IMAGE_REPOSITORY] [-t IMAGE_TAG]"; exit 1
esac
done

BASE_DIR=${BASE_DIR:-$PWD}
CONTAINER_PREFIX=${CONTAINER_PREFIX:-manageiq}
IMAGE_DIR="$BASE_DIR/images"
OPERATOR_DIR="$BASE_DIR/manageiq-operator"
REPO=${REPO:-docker.io/manageiq}

CONTAINER_COMMAND="$(which podman &>/dev/null && echo "podman" || echo "docker")"

set -e

pushd $IMAGE_DIR
cmd="$CONTAINER_COMMAND build"

hotfix_images="manageiq-base manageiq-base-worker manageiq-orchestrator manageiq-webserver-worker manageiq-ui-worker"
for image in $hotfix_images; do
cmd="$CONTAINER_COMMAND build"

if [ "$CONTAINER_COMMAND" == "podman" ]; then
cmd+=" --format docker"
fi

cmd+=" --tag $REPO/$image:$TAG \
--build-arg CONTAINER_PREFIX=$CONTAINER_PREFIX \
--build-arg FROM_REPO=$REPO \
--build-arg FROM_TAG=$TAG \
--pull \
manageiq-hotfix"

echo "Building hotfix for $image: $cmd"
$cmd
done
popd

if [ -n "$PUSH" ]; then
push_images="manageiq-base manageiq-base-worker manageiq-orchestrator manageiq-webserver-worker manageiq-ui-worker"

for image in $push_images; do
cmd="$CONTAINER_COMMAND push $REPO/$image:$TAG"

if [ "$CONTAINER_COMMAND" == "podman" ]; then
cmd+=" --format docker"
fi

echo "Pushing: $cmd"
$cmd
done
fi
15 changes: 15 additions & 0 deletions images/manageiq-hotfix/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ARG CONTAINER_PREFIX=manageiq
ARG FROM_REPO=manageiq
ARG FROM_TAG=latest

FROM ${FROM_REPO}/${CONTAINER_PREFIX}-base:${FROM_TAG}

COPY rpms/* /tmp/rpms/

RUN /create_local_yum_repo.sh && \
dnf -y --repo=local-rpm update && \
chgrp -R 0 $APP_ROOT && \
chmod -R g=u $APP_ROOT && \
source /etc/default/evm && \
/usr/bin/generate_rpm_manifest.sh && \
clean_dnf_rpm
Empty file.