From 5958e889dfa1a320d93fd9967ecc1f28ac27ff11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jiri=20Dan=C4=9Bk?= Date: Mon, 12 Sep 2022 17:09:32 +0200 Subject: [PATCH 1/2] Add Dockerfile for multiarch build --- Dockerfile | 27 +++++++++++++++++++++++++++ build_docker.sh | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ build_java.sh | 5 +++++ create_links.sh | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 115 insertions(+) create mode 100644 Dockerfile create mode 100755 build_docker.sh create mode 100755 build_java.sh create mode 100755 create_links.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..6b3ebdf7 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +FROM fedora:latest + +WORKDIR /var/lib/cli-java + +ENV LANG=C.UTF-8 +RUN yum install \ + -y --setopt=install_weak_deps=0 --setopt=tsflags=nodocs \ + java-11-openjdk-headless \ + bzip2 unzip xz \ + bzr git mercurial openssh-clients subversion procps \ + gnupg dirmngr \ + ca-certificates curl wget \ + && dnf clean all -y + +RUN mkdir /main + +COPY cli-qpid-jms/target/cli-qpid-jms-1.2.2-SNAPSHOT-*.jar /main/cli-qpid.jar +COPY cli-activemq/target/cli-activemq-1.2.2-SNAPSHOT-*.jar /main/cli-activemq.jar +COPY cli-artemis-jms/target/cli-artemis-jms-1.2.2-SNAPSHOT-*.jar /main/cli-artemis.jar +COPY cli-paho-java/target/cli-paho-java-1.2.2-SNAPSHOT-*.jar /main/cli-paho.jar + +COPY create_links.sh /main +RUN bash /main/create_links.sh + + +RUN groupadd cli-java && useradd -d /var/lib/cli-java -ms /bin/bash -g cli-java -G cli-java cli-java +USER cli-java:cli-java diff --git a/build_docker.sh b/build_docker.sh new file mode 100755 index 00000000..3d6428f7 --- /dev/null +++ b/build_docker.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash + +# +# Copyright (c) 2022 Red Hat, Inc. +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +set -Eeuo pipefail +set -x + +ARCH="amd64 arm64 ppc64le s390x" +VERSION="${1:-latest}" +REGISTRY="${2:-quay.io}" +NAMESPACE="${3:-messaging}" + +IMAGE_NAME="${REGISTRY}/${NAMESPACE}/cli-java:${VERSION}" + +# https://docs.docker.com/build/buildx/multiplatform-images/ +sudo podman run --privileged --rm docker.io/tonistiigi/binfmt --install all +podman manifest rm ${IMAGE_NAME} || true + +# https://gitlab.cee.redhat.com/keycloak/rhsso-openshift-intermediate-docker-image/-/blob/main/build.sh +echo "Creating a new manifest: ${IMAGE_NAME}" +podman manifest create ${IMAGE_NAME} + +echo "Building a new docker image: ${IMAGE_NAME}, arch: ${ARCH}" +for i in $ARCH +do + podman build --arch=$i -t ${IMAGE_NAME}.${i} --build-arg ARCH=${i} --build-arg VERSION=${VERSION} . + podman push ${IMAGE_NAME}.${i} + podman manifest add ${IMAGE_NAME} ${IMAGE_NAME}.${i} +done + +echo "Pushing a new manifest: ${IMAGE_NAME}" +podman manifest push ${IMAGE_NAME} docker://${IMAGE_NAME} diff --git a/build_java.sh b/build_java.sh new file mode 100755 index 00000000..55cc8001 --- /dev/null +++ b/build_java.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +set -Eeuo pipefail +set -x + +mvn -B package --file pom.xml -DskipTests diff --git a/create_links.sh b/create_links.sh new file mode 100755 index 00000000..e9e75199 --- /dev/null +++ b/create_links.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +set -Eeuo pipefail +set -x + +# +# Copyright (c) 2022 Red Hat, Inc. +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +cd /main; for i in *.jar; do +for j in sender receiver connector; do + filename="/usr/local/bin/${i%.jar}-${j}" + cat > "${filename}" <<'EOF' +#!/bin/sh + +java ${JAVA_OPTS} ${CLI_QPID_JMS_OPTS} -jar /main/cli-paho.jar sender $@ +EOF + chmod +x "$filename" + done +done From aae2eb8903985091f5b00230b4f8caa4fc67e825 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jiri=20Dan=C4=9Bk?= Date: Mon, 12 Sep 2022 18:28:30 +0200 Subject: [PATCH 2/2] fixup Startup scripts parameterize --- create_links.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/create_links.sh b/create_links.sh index e9e75199..ebe943ec 100755 --- a/create_links.sh +++ b/create_links.sh @@ -24,10 +24,10 @@ set -x cd /main; for i in *.jar; do for j in sender receiver connector; do filename="/usr/local/bin/${i%.jar}-${j}" - cat > "${filename}" <<'EOF' + cat > "${filename}" << EOF #!/bin/sh -java ${JAVA_OPTS} ${CLI_QPID_JMS_OPTS} -jar /main/cli-paho.jar sender $@ +java \${JAVA_OPTS} \${CLI_QPID_JMS_OPTS} -jar /main/${i} ${j} \$@ EOF chmod +x "$filename" done