Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@ clean:
_build-%:
WHAT=$* hack/build-go.sh

# Build image for a component. Intended to be called via another target.
# Example:
# make _image-machine-config-daemon
_image-%:
@which podman 2> /dev/null >&1 || { echo "podman must be installed to build an image"; exit 1; }
WHAT=$* hack/build-image.sh
# Use podman to build the image.
image:
hack/build-image.sh

# Build + push + deploy image for a component. Intended to be called via another target.
# Example:
Expand Down
66 changes: 1 addition & 65 deletions hack/build-image.sh
Original file line number Diff line number Diff line change
@@ -1,68 +1,4 @@
#!/usr/bin/env bash

set -eu

podman=${podman:-podman}

# Print errors to stderr
function print_error {
echo "ERROR: $1" >&2
}

function print_info {
echo "INFO: $1" >&2
}

# Warn when unprivileged
if [ `id --user` -ne 0 ]; then
print_error "Note: Building unprivileged may fail due to permissions"
fi

# Record all images files
ALL_IMAGES=Dockerfile.*

# To build will hold a list of all image files to build
TOBUILD=""

# WHAT should be defined. If not, give a list and exit
if [ -z ${WHAT+a} ]; then
print_error "WHAT must be set to one of the following:"
print_error "- all"
for x in $ALL_IMAGES ; do
print_error "- ${x#Dockerfile.}"
done

exit 1
fi


# If all is the WHAT target then set TOBUILD to all the images found
if [ ${WHAT} == "all" ]; then
TOBUILD=$ALL_IMAGES
print_info "Building all images"
else
# Otherwise WHAT should be valid at this point
TOBUILD="Dockerfile.${WHAT}"
# See Dockerfile.machine-config-daemon.upstream for why this exists
if [ -f "$TOBUILD.upstream" ]; then
TOBUILD="${TOBUILD}.upstream"
fi
fi

# Check that the target is valid
for IMAGE_TO_BUILD in $TOBUILD; do
if ! test -f "${IMAGE_TO_BUILD}"
then
print_error "no build file named '${IMAGE_TO_BUILD}'"
print_error "WHAT may be invalid: '${WHAT}'"
exit 1
fi
done

# Build all images requested
for IMAGE_TO_BUILD in $TOBUILD; do
NAME="${IMAGE_TO_BUILD#Dockerfile.}"
NAME="${NAME//.upstream}"
set -x
$podman build -t "localhost/${NAME}:latest" -f "${IMAGE_TO_BUILD}" --no-cache
done
exec $podman build -t "localhost/machine-config-operator:latest" -f Dockerfile --no-cache