2019-02-04 18:49:59 -05:00
|
|
|
#!/bin/sh
|
2019-02-02 03:12:17 -05:00
|
|
|
# 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.
|
|
|
|
|
2019-02-04 18:49:59 -05:00
|
|
|
# Setting the script to fail if anything goes wrong
|
2018-10-22 21:11:02 -04:00
|
|
|
set -e
|
|
|
|
|
2019-02-04 18:49:59 -05:00
|
|
|
#This is a script to Prepare an artemis folder to generate the Release.
|
2018-10-22 21:11:02 -04:00
|
|
|
|
|
|
|
|
2021-02-07 16:51:50 -05:00
|
|
|
usage () {
|
|
|
|
cat <<HERE
|
|
|
|
|
|
|
|
$@
|
|
|
|
|
|
|
|
Usage:
|
|
|
|
# Prepare for build the Docker Image from the local distribution
|
|
|
|
./prepare-docker.sh --from-local-dist --local-dist-path {local-distribution-directory}
|
|
|
|
|
|
|
|
# Prepare for build the Docker Image from the release version
|
|
|
|
./prepare-docker.sh --from-release --artemis-version {release-version}
|
|
|
|
|
|
|
|
# Show the usage command
|
|
|
|
./prepare-docker.sh --help
|
|
|
|
|
|
|
|
Example:
|
|
|
|
./prepare-docker.sh --from-local-dist --local-dist-path ../artemis-distribution/target/apache-artemis-2.17.0-SNAPSHOT-bin/apache-artemis-2.17.0-SNAPSHOT
|
2022-09-14 15:07:14 -04:00
|
|
|
./prepare-docker.sh --from-release --artemis-version 2.16.0
|
2021-02-07 16:51:50 -05:00
|
|
|
|
|
|
|
HERE
|
|
|
|
exit 1
|
2019-02-04 18:49:59 -05:00
|
|
|
}
|
|
|
|
|
2021-02-07 16:51:50 -05:00
|
|
|
next_step () {
|
|
|
|
cat <<HERE
|
2018-10-22 21:11:02 -04:00
|
|
|
|
2022-09-17 11:28:01 -04:00
|
|
|
Well done! Now you can continue with building the Docker image:
|
2022-09-14 15:07:14 -04:00
|
|
|
|
2022-09-17 11:28:01 -04:00
|
|
|
# Go to $ARTEMIS_DIST_DIR
|
|
|
|
$ cd $ARTEMIS_DIST_DIR
|
2021-02-07 16:51:50 -05:00
|
|
|
|
2022-09-19 10:57:43 -04:00
|
|
|
# For CentOS with full JDK
|
2022-09-18 14:43:22 -04:00
|
|
|
$ docker build -f ./docker/Dockerfile-centos7-11 -t artemis-centos .
|
|
|
|
|
2022-09-19 10:57:43 -04:00
|
|
|
# For Ubuntu with full JDK
|
2022-09-18 14:43:22 -04:00
|
|
|
$ docker build -f ./docker/Dockerfile-ubuntu-11 -t artemis-ubuntu .
|
2021-02-07 16:51:50 -05:00
|
|
|
|
2022-09-19 10:57:43 -04:00
|
|
|
# For Ubuntu with just JRE
|
2022-09-18 14:43:22 -04:00
|
|
|
$ docker build -f ./docker/Dockerfile-ubuntu-11-jre -t artemis-ubuntu .
|
2021-02-07 16:51:50 -05:00
|
|
|
|
2022-09-19 10:57:43 -04:00
|
|
|
# For Ubuntu on Linux ARMv7/ARM64 with full JDK
|
2022-09-18 14:43:22 -04:00
|
|
|
$ docker buildx build --platform linux/arm64,linux/arm/v7 --push -t {your-repository}/apache-artemis:2.17.0-SNAPSHOT -f ./docker/Dockerfile-ubuntu-11 .
|
2021-02-07 16:51:50 -05:00
|
|
|
|
2022-09-18 14:43:22 -04:00
|
|
|
Note: -t artemis-centos and -t artemis-ubuntu are just tag names for the purpose of this guide
|
2021-02-07 16:51:50 -05:00
|
|
|
|
2022-09-19 10:57:43 -04:00
|
|
|
For more info see readme.md
|
2021-02-07 16:51:50 -05:00
|
|
|
|
|
|
|
HERE
|
2022-03-24 11:24:45 -04:00
|
|
|
exit 0
|
2021-02-07 16:51:50 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
while [ "$#" -ge 1 ]
|
|
|
|
do
|
|
|
|
key="$1"
|
|
|
|
case $key in
|
|
|
|
--help)
|
|
|
|
usage
|
|
|
|
;;
|
|
|
|
--from-local-dist)
|
|
|
|
FROM_LOCAL="true"
|
|
|
|
;;
|
|
|
|
--from-release)
|
|
|
|
FROM_RELEASE="true"
|
|
|
|
;;
|
|
|
|
--local-dist-path)
|
|
|
|
LOCAL_DIST_PATH="$2"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
--artemis-version)
|
|
|
|
ARTEMIS_VERSION="$2"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
# unknown option
|
|
|
|
usage "Unknown option"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
# TMPDIR must be contained within the working directory so it is part of the
|
2022-09-17 11:28:01 -04:00
|
|
|
# Docker context. (i.e. it can't be in /tmp)
|
2021-02-07 16:51:50 -05:00
|
|
|
BASE_TMPDIR="_TMP_/artemis"
|
|
|
|
|
2022-09-17 11:28:01 -04:00
|
|
|
if [ -n "${FROM_RELEASE}" ] && [ -z "${ARTEMIS_VERSION}" ]; then
|
|
|
|
usage "You must specify the release version (e.g. --artemis-version 2.16.0)"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "${FROM_RELEASE}" ]; then
|
|
|
|
ARTEMIS_DIST_DIR="${BASE_TMPDIR}/${ARTEMIS_VERSION}"
|
|
|
|
|
|
|
|
# Prepare directory
|
|
|
|
if [ ! -d "${ARTEMIS_DIST_DIR}" ]; then
|
|
|
|
echo "Creating ${ARTEMIS_DIST_DIR}"
|
|
|
|
mkdir -p "${ARTEMIS_DIST_DIR}"
|
|
|
|
elif [ ! -z "$(find "${BASE_TMPDIR}" -name "${ARTEMIS_VERSION}" -type d -mmin +60)" ]; then
|
|
|
|
echo "Cleaning up ${ARTEMIS_DIST_DIR}"
|
|
|
|
rm -rf ${ARTEMIS_DIST_DIR}/*
|
2021-02-07 16:51:50 -05:00
|
|
|
else
|
2022-09-17 11:28:01 -04:00
|
|
|
echo "Using ${ARTEMIS_DIST_DIR}"
|
2021-02-07 16:51:50 -05:00
|
|
|
fi
|
|
|
|
|
2022-09-17 11:28:01 -04:00
|
|
|
# Check if the release is already available locally, if not try to download it
|
|
|
|
if [ -z "$(ls -A ${ARTEMIS_DIST_DIR})" ]; then
|
|
|
|
CDN="$(curl -s https://www.apache.org/dyn/closer.cgi\?preferred=true)activemq/activemq-artemis/${ARTEMIS_VERSION}/"
|
|
|
|
ARCHIVE="https://archive.apache.org/dist/activemq/activemq-artemis/${ARTEMIS_VERSION}/"
|
|
|
|
ARTEMIS_BASE_URL=${CDN}
|
|
|
|
ARTEMIS_DIST_FILE_NAME="apache-artemis-${ARTEMIS_VERSION}-bin.tar.gz"
|
|
|
|
CURL_OUTPUT="${ARTEMIS_DIST_DIR}/${ARTEMIS_DIST_FILE_NAME}"
|
|
|
|
|
|
|
|
# Fallback to the Apache archive if the version doesn't exist on the CDN anymore
|
|
|
|
if [ -z "$(curl -Is ${ARTEMIS_BASE_URL}${ARTEMIS_DIST_FILE_NAME} | head -n 1 | grep 200)" ]; then
|
|
|
|
ARTEMIS_BASE_URL=${ARCHIVE}
|
|
|
|
|
|
|
|
# If the archive also doesn't work then report the failure and abort
|
|
|
|
if [ -z "$(curl -Is ${ARTEMIS_BASE_URL}${ARTEMIS_DIST_FILE_NAME} | head -n 1 | grep 200)" ]; then
|
|
|
|
echo "Failed to find ${ARTEMIS_DIST_FILE_NAME}. Tried both ${CDN} and ${ARCHIVE}."
|
|
|
|
exit 1
|
|
|
|
fi
|
2022-09-15 11:27:22 -04:00
|
|
|
fi
|
2022-09-14 15:07:14 -04:00
|
|
|
|
2021-02-07 16:51:50 -05:00
|
|
|
echo "Downloading ${ARTEMIS_DIST_FILE_NAME} from ${ARTEMIS_BASE_URL}..."
|
|
|
|
curl --progress-bar "${ARTEMIS_BASE_URL}${ARTEMIS_DIST_FILE_NAME}" --output "${CURL_OUTPUT}"
|
|
|
|
|
2022-09-17 11:28:01 -04:00
|
|
|
echo "Expanding ${ARTEMIS_DIST_DIR}/${ARTEMIS_DIST_FILE_NAME}..."
|
|
|
|
tar xzf "$CURL_OUTPUT" --directory "${ARTEMIS_DIST_DIR}" --strip 1
|
2021-02-07 16:51:50 -05:00
|
|
|
|
2022-09-17 11:28:01 -04:00
|
|
|
echo "Removing ${ARTEMIS_DIST_DIR}/${ARTEMIS_DIST_FILE_NAME}..."
|
|
|
|
rm -rf "${ARTEMIS_DIST_DIR}"/"${ARTEMIS_DIST_FILE_NAME}"
|
2021-02-07 16:51:50 -05:00
|
|
|
fi
|
|
|
|
|
|
|
|
elif [ -n "${FROM_LOCAL}" ]; then
|
2022-09-14 15:07:14 -04:00
|
|
|
|
2021-02-07 16:51:50 -05:00
|
|
|
if [ -n "${LOCAL_DIST_PATH}" ]; then
|
2022-09-17 11:28:01 -04:00
|
|
|
ARTEMIS_DIST_DIR=${LOCAL_DIST_PATH}
|
2022-09-19 10:57:43 -04:00
|
|
|
echo "Using ${ARTEMIS_DIST_DIR}"
|
2022-09-14 15:07:14 -04:00
|
|
|
else
|
2021-02-07 16:51:50 -05:00
|
|
|
usage "You must specify the local distribution directory"
|
|
|
|
fi
|
|
|
|
|
2022-09-17 11:28:01 -04:00
|
|
|
if [ ! -d "${ARTEMIS_DIST_DIR}" ]; then
|
|
|
|
usage "Directory ${ARTEMIS_DIST_DIR} does not exist"
|
2021-02-07 16:51:50 -05:00
|
|
|
fi
|
|
|
|
|
2022-09-17 11:28:01 -04:00
|
|
|
if [ -d "${ARTEMIS_DIST_DIR}/docker" ]; then
|
2022-09-19 10:57:43 -04:00
|
|
|
echo "Cleaning up ${ARTEMIS_DIST_DIR}/docker"
|
2022-09-17 11:28:01 -04:00
|
|
|
rm -rf "${ARTEMIS_DIST_DIR}/docker"
|
2021-02-07 16:51:50 -05:00
|
|
|
fi
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
usage
|
2019-02-04 18:49:59 -05:00
|
|
|
|
|
|
|
fi
|
2018-10-22 21:11:02 -04:00
|
|
|
|
2022-09-17 11:28:01 -04:00
|
|
|
if [ ! -d "${ARTEMIS_DIST_DIR}/docker" ]; then
|
|
|
|
mkdir "${ARTEMIS_DIST_DIR}/docker"
|
2019-02-04 18:49:59 -05:00
|
|
|
fi
|
2018-10-22 21:11:02 -04:00
|
|
|
|
2022-09-17 11:28:01 -04:00
|
|
|
cp ./Dockerfile-* "$ARTEMIS_DIST_DIR/docker"
|
|
|
|
cp ./docker-run.sh "$ARTEMIS_DIST_DIR/docker"
|
2021-02-07 16:51:50 -05:00
|
|
|
|
2022-09-17 11:28:01 -04:00
|
|
|
echo "Docker file support files at:"
|
|
|
|
tree "$ARTEMIS_DIST_DIR/docker"
|
2021-02-07 16:51:50 -05:00
|
|
|
|
2022-03-24 11:24:45 -04:00
|
|
|
next_step
|