Skip to content

Commit

Permalink
CASMINST-4471 simplify build and properly load nexus images with new …
Browse files Browse the repository at this point in the history
…podman

syntax

Signed-off-by: Jacob Salmela <[email protected]>
  • Loading branch information
jacobsalmela committed Apr 27, 2022
1 parent 753e203 commit 18abb22
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.3
1.1.4
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ clean:
$(RM) -rf $(BUILD_DIR)

rpm_build: pit-nexus.spec systemd/nexus.service systemd/nexus-init.sh systemd/nexus-setup.sh
BUILD_METADATA="$(BUILD_METADATA)" \
BUILD_METADATA="$(BUILD_METADATA)"
rpmbuild --nodeps \
--define "_topdir $(BUILD_DIR)" \
--define "_sourcedir $(BUILD_DIR)/SOURCES" \
--define "_topdir $(BUILD_DIR)" \
--define "_sourcedir $(BUILD_DIR)/SOURCES" \
-ba $(SPEC_FILE)
29 changes: 19 additions & 10 deletions systemd/nexus-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
# helmrepo.dev.cray.com.
NEXUS_IMAGE="@@sonatype-nexus3-image@@"
NEXUS_IMAGE_PATH="@@sonatype-nexus3-path@@"
NEXUS_CONTAINER_NAME="nexus"

command -v podman >/dev/null 2>&1 || { echo >&2 "${0##*/}: command not found: podman"; exit 1; }

Expand All @@ -36,18 +37,21 @@ fi

NEXUS_PIDFILE="$1"
NEXUS_CIDFILE="$2"
NEXUS_CONTAINER_NAME="${3-nexus3}"
NEXUS_VOLUME_NAME="${4:-${NEXUS_CONTAINER_NAME}3-data}"
NEXUS_CONTAINER_NAME="${3-nexus}"
NEXUS_VOLUME_NAME="${4:-${NEXUS_CONTAINER_NAME}-data}"

NEXUS_VOLUME_MOUNT="/nexus-data:rw,exec"

set -x

# Create Nexus volume if not already present
if ! podman volume inspect "$NEXUS_VOLUME_NAME" ; then
if ! podman volume inspect "$NEXUS_VOLUME_NAME" &>/dev/null; then
# Load busybox image if it doesn't already exist
if ! podman image inspect "$NEXUS_IMAGE" >/dev/null; then
podman load -i "$NEXUS_IMAGE_PATH" "$NEXUS_IMAGE" || exit
if ! podman image inspect "$NEXUS_IMAGE" &>/dev/null; then
# load the image
podman load -i "$NEXUS_IMAGE_PATH" || exit
# get the tag
NEXUS_IMAGE_ID=$(podman images --noheading --format "{{.Id}}" --filter label="name=Nexus Repository Manager")
# tag the image
podman tag "$NEXUS_IMAGE_ID" "$NEXUS_IMAGE"
fi
podman run --rm --network host \
-v "${NEXUS_VOLUME_NAME}:${NEXUS_VOLUME_MOUNT}" \
Expand All @@ -68,11 +72,16 @@ fi
rm -f "$NEXUS_PIDFILE"

# Create Nexus container
if ! podman inspect "$NEXUS_CONTAINER_NAME" ; then
if ! podman inspect --type container "$NEXUS_CONTAINER_NAME" &>/dev/null; then
rm -f "$NEXUS_CIDFILE" || exit
# Load nexus image if it doesn't already exist
if ! podman image inspect "$NEXUS_IMAGE" >/dev/null; then
podman load "$NEXUS_IMAGE_PATH" "$NEXUS_IMAGE" || exit
if ! podman image inspect "$NEXUS_IMAGE" &>/dev/null; then
# load the image
podman load -i "$NEXUS_IMAGE_PATH"
# get the tag
NEXUS_IMAGE_ID=$(podman images --noheading --format "{{.Id}}" --filter label="name=Nexus Repository Manager")
# tag the image
podman tag "$NEXUS_IMAGE_ID" "$NEXUS_IMAGE"
fi
podman create \
--conmon-pidfile "$NEXUS_PIDFILE" \
Expand Down
9 changes: 7 additions & 2 deletions systemd/nexus-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,13 @@ fi

set -x

if ! podman image inspect "$NEXUS_SETUP_IMAGE" >/dev/null; then
podman load -i "$NEXUS_SETUP_IMAGE_PATH" "$NEXUS_SETUP_IMAGE" || exit
if ! podman image inspect --type image "$NEXUS_SETUP_IMAGE" &>/dev/null; then
# load the image
podman load -i "$NEXUS_SETUP_IMAGE_PATH" || exit
# get the image id
CRAY_NEXUS_SETUP_ID=$(podman images --noheading --format "{{.Id}}" --filter label="org.label-schema.name=cray-nexus-setup")
# tag the image
podman tag "$CRAY_NEXUS_SETUP_ID" "$NEXUS_SETUP_IMAGE"
fi

# Setup Nexus container (assumes Nexus is at http://localhost:8081)
Expand Down

0 comments on commit 18abb22

Please sign in to comment.