diff --git a/.shellcheckrc b/.shellcheckrc new file mode 100644 index 0000000..ae75170 --- /dev/null +++ b/.shellcheckrc @@ -0,0 +1,18 @@ +# +# For example, go to https://github.com/koalaman/shellcheck/wiki/SC2236 for more +# information about SC2236. +# + +disable=SC1090 +disable=SC1091 +disable=SC2001 +disable=SC2016 +disable=SC2034 +disable=SC2046 +disable=SC2089 +disable=SC2090 +disable=SC2116 +disable=SC2143 +disable=SC2155 +disable=SC2181 +disable=SC2236 \ No newline at end of file diff --git a/README.markdown b/README.markdown index e94a0a4..1fccdff 100644 --- a/README.markdown +++ b/README.markdown @@ -141,7 +141,7 @@ The basic JBoss EAP configuration is governed by configuration files located within the following directory. For each version of JBoss there is a dedicated directory. ```bash -template +templates/bundle └── jboss-eap    ├── 7.2.0    │   ├── bin diff --git a/_common.sh b/_common.sh index 00968d4..bc4d27d 100755 --- a/_common.sh +++ b/_common.sh @@ -1,5 +1,21 @@ #!/bin/bash +function check_docker_buildx { + docker build buildx --help > /dev/null 2>&1 + + if [ $? -gt 0 ] + then + echo "Docker Buildx is not available." + + exit 1 + fi + + if [ $(docker buildx ls | grep -c -w "liferay-buildkit") -eq 0 ] + then + docker buildx create --name "liferay-buildkit" + fi +} + function check_liferay_additional_files() { local found_additional_files=("-" "-" "-") @@ -28,80 +44,99 @@ function check_liferay_additional_files() { echo "${found_additional_files[*]}" } -function check_utils() { +function check_utils { - # - # https://stackoverflow.com/a/677212 - # + # + # https://stackoverflow.com/a/677212 + # - for util in "${@}"; do - command -v ${util} >/dev/null 2>&1 || { - echo >&2 "The utility ${util} is not installed." - exit 1 - } - done + for util in "${@}" + do + command -v "${util}" >/dev/null 2>&1 || { echo >&2 "The utility ${util} is not installed."; exit 1; } + done } -function clean_up_temp_directory() { - rm -fr ${TEMP_DIR} +function clean_up_temp_directory { + rm -fr "${TEMP_DIR}" } -function configure_tomcat() { - printf "\nCATALINA_OPTS=\"\${CATALINA_OPTS} \${LIFERAY_JVM_OPTS}\"" >>${TEMP_DIR}/liferay/tomcat/bin/setenv.sh +function configure_tomcat { + printf "\nCATALINA_OPTS=\"\${CATALINA_OPTS} \${LIFERAY_JVM_OPTS}\"" >> "${TEMP_DIR}/liferay/tomcat/bin/setenv.sh" } -function date() { - export LC_ALL=en_US.UTF-8 - - if [ -z ${1+x} ] || [ -z ${2+x} ]; then - if [ "$(uname)" == "Darwin" ]; then - echo $(/bin/date) - elif [ -e /bin/date ]; then - echo $(/bin/date) - else - echo $(/usr/bin/date) - fi - else - if [ "$(uname)" == "Darwin" ]; then - echo $(/bin/date -jf "%a %b %e %H:%M:%S %Z %Y" "${1}" "${2}") - elif [ -e /bin/date ]; then - echo $(/bin/date -d "${1}" "${2}") - else - echo $(/usr/bin/date -d "${1}" "${2}") - fi - fi +function date { + export LC_ALL=en_US.UTF-8 + export TZ=America/Los_Angeles + + if [ -z ${1+x} ] || [ -z ${2+x} ] + then + if [ "$(uname)" == "Darwin" ] + then + /bin/date + elif [ -e /bin/date ] + then + /bin/date --iso-8601=seconds + else + /usr/bin/date --iso-8601=seconds + fi + else + if [ "$(uname)" == "Darwin" ] + then + /bin/date -jf "%a %b %e %H:%M:%S %Z %Y" "${1}" "${2}" + elif [ -e /bin/date ] + then + /bin/date -d "${1}" "${2}" + else + /usr/bin/date -d "${1}" "${2}" + fi + fi } -function download() { - local file_name=${1} +function delete_local_images { + if [[ "${LIFERAY_DOCKER_DEVELOPER_MODE}" == "true" ]] && [ -n "${1}" ] + then + echo "Deleting local ${1} images." - if [ -e ${file_name} ]; then - return - fi + for image_id in $(docker image ls | grep "${1}" | awk '{print $3}' | uniq) + do + docker image rm -f "${image_id}" + done + fi +} - local file_url=${2} +function download { + local file_name="${1}" + local file_url="${2}" - if [[ ${file_url} != http*://* ]]; then - file_url=http://${file_url} - fi + if [ -e "${file_name}" ] && [[ "${file_url}" != */nightly/* ]] && [[ "${file_url}" != */latest/* ]] + then + return + fi - if [[ ${file_url} != http://mirrors.*.liferay.com* ]] && - [[ ${file_url} != http://release-1* ]] && - [[ ${file_url} != https://release.liferay.com* ]]; then - if [ ! -n "${LIFERAY_DOCKER_MIRROR}" ]; then - LIFERAY_DOCKER_MIRROR=lax - fi + if [[ "${file_url}" != http*://* ]] + then + file_url="http://${file_url}" + fi - file_url=http://mirrors.${LIFERAY_DOCKER_MIRROR}.liferay.com/${file_url##*//} - fi + if [[ "${file_url}" != http://mirrors.*.liferay.com* ]] && + [[ "${file_url}" != http://release-1* ]] && + [[ "${file_url}" != https://release.liferay.com* ]] + then + if [ ! -n "${LIFERAY_DOCKER_MIRROR}" ] + then + LIFERAY_DOCKER_MIRROR=lax + fi + + file_url="http://mirrors.${LIFERAY_DOCKER_MIRROR}.liferay.com/"${file_url##*//} + fi - echo "" - echo "Downloading ${file_url}." - echo "" + echo "" + echo "Downloading ${file_url}." + echo "" - mkdir -p $(dirname ${file_name}) + mkdir -p $(dirname "${file_name}") - curl ${LIFERAY_DOCKER_CURL_OPTIONS} -f -o ${file_name} ${file_url} || exit 2 + curl $(echo "${LIFERAY_DOCKER_CURL_OPTIONS}") --fail --location --output "${file_name}" "${file_url}" || exit 2 } function get_abs_filename() { @@ -134,14 +169,15 @@ function get_liferay_additional_file_version() { echo "${version}" } -function get_docker_image_tags_args() { - local docker_image_tags_args="" +function get_docker_image_tags_args { + local docker_image_tags_args="" - for docker_image_tag in "${@}"; do - docker_image_tags_args="${docker_image_tags_args} --tag ${docker_image_tag}" - done + for docker_image_tag in "${@}" + do + docker_image_tags_args="${docker_image_tags_args} --tag ${docker_image_tag}" + done - echo ${docker_image_tags_args} + echo "${docker_image_tags_args}" } function get_jboss_version() { @@ -224,22 +260,38 @@ function get_patching_tool_archive() { echo "${patching_tool_archive}" } -function get_tomcat_version() { - if [ -e ${1}/tomcat-* ]; then - for temp_file_name in $(ls ${1}); do - if [[ ${temp_file_name} == tomcat-* ]]; then - local liferay_tomcat_version=${temp_file_name#*-} - fi - done - fi +function get_tomcat_version { + for temp_file_name in "${1}"/tomcat-* + do + if [ -e "${temp_file_name}" ] + then + local tomcat_folder=${temp_file_name##*/} + local liferay_tomcat_version=${tomcat_folder#*-} + fi + break + done + + if [ -z ${liferay_tomcat_version+x} ] + then + echo "Unable to determine Tomcat version." + + exit 1 + fi + + echo "${liferay_tomcat_version}" +} - if [ -z ${liferay_tomcat_version+x} ]; then - echo "Unable to determine Tomcat version." +function log_in_to_docker_hub { + if [ ! -n "${LIFERAY_DOCKER_HUB_LOGGED_IN}" ] && [ -n "${LIFERAY_DOCKER_HUB_TOKEN}" ] && [ -n "${LIFERAY_DOCKER_HUB_USERNAME}" ] + then + echo "" + echo "Logging in to Docker Hub." + echo "" - exit 1 - fi + echo "${LIFERAY_DOCKER_HUB_TOKEN}" | docker login --password-stdin -u "${LIFERAY_DOCKER_HUB_USERNAME}" - echo ${liferay_tomcat_version} + LIFERAY_DOCKER_HUB_LOGGED_IN=true + fi } function install_fix_pack() { @@ -356,22 +408,22 @@ function install_security_fix_pack() { fi } -function make_temp_directory() { - CURRENT_DATE=$(date) +function make_temp_directory { + CURRENT_DATE=$(date) - TIMESTAMP=$(date "${CURRENT_DATE}" "+%Y%m%d%H%M") + TIMESTAMP=$(date "${CURRENT_DATE}" "+%Y%m%d%H%M%S") - TEMP_DIR=temp-${TIMESTAMP} + TEMP_DIR="temp-${TIMESTAMP}" - mkdir -p ${TEMP_DIR} + mkdir -p "${TEMP_DIR}" - cp -r template/* ${TEMP_DIR} + cp -r "${1}"/* "${TEMP_DIR}" } -function pid_8080() { - local pid=$(lsof -i 4tcp:8080 -sTCP:LISTEN -Fp | head -n 1) +function pid_8080 { + local pid=$(lsof -Fp -i 4tcp:8080 -sTCP:LISTEN | head -n 1) - echo ${pid##p} + echo "${pid##p}" } function prepare_jboss_eap() { @@ -471,19 +523,23 @@ function prepare_temp_for_manual_installation() { cd ../../../ } -function prepare_tomcat() { - local liferay_tomcat_version=$(get_tomcat_version ${TEMP_DIR}/liferay) +function prepare_tomcat { + local liferay_tomcat_version=$(get_tomcat_version "${TEMP_DIR}/liferay") - mv ${TEMP_DIR}/liferay/tomcat-${liferay_tomcat_version} ${TEMP_DIR}/liferay/tomcat + mv "${TEMP_DIR}/liferay/tomcat-${liferay_tomcat_version}" "${TEMP_DIR}/liferay/tomcat" - ln -s tomcat ${TEMP_DIR}/liferay/tomcat-${liferay_tomcat_version} + ln -s tomcat "${TEMP_DIR}/liferay/tomcat-${liferay_tomcat_version}" - configure_tomcat + configure_tomcat - warm_up_tomcat + warm_up_tomcat - rm -fr ${TEMP_DIR}/liferay/logs/* - rm -fr ${TEMP_DIR}/liferay/tomcat/logs/* + rm -fr "${TEMP_DIR}"/liferay/logs/* + rm -fr "${TEMP_DIR}"/liferay/tomcat/logs/* +} + +function remove_temp_dockerfile_platform_variable { + sed -i 's/--platform=${TARGETPLATFORM} //g' "${TEMP_DIR}"/Dockerfile } function push_docker_images() { @@ -494,84 +550,92 @@ function push_docker_images() { fi } -function start_tomcat() { +function start_tomcat { - # - # Increase the available memory for warming up Tomcat. This is needed - # because LPKG hash and OSGi state processing for 7.0.x is expensive. Set - # this for all scenarios since it is limited to warming up Tomcat. - # + # + # Increase the available memory for warming up Tomcat. This is needed + # because LPKG hash and OSGi state processing for 7.0.x is expensive. Set + # this for all scenarios since it is limited to warming up Tomcat. + # - LIFERAY_JVM_OPTS="-Xmx3G" + LIFERAY_JVM_OPTS="-Xmx3G" - local pid=$(pid_8080) + local pid=$(pid_8080) - if [ -n "${pid}" ]; then - echo "" - echo "Killing process ${pid} that is listening on port 8080." - echo "" + if [ -n "${pid}" ] + then + echo "" + echo "Killing process ${pid} that is listening on port 8080." + echo "" - kill -9 ${pid} 2>/dev/null - fi + kill -9 "${pid}" 2>/dev/null + fi - ./${TEMP_DIR}/liferay/tomcat/bin/catalina.sh start + "./${TEMP_DIR}/liferay/tomcat/bin/catalina.sh" start - until $(curl --head --fail --output /dev/null --silent http://localhost:8080); do - sleep 3 - done + until curl --fail --head --output /dev/null --silent http://localhost:8080 + do + sleep 3 + done - pid=$(pid_8080) + pid=$(pid_8080) - ./${TEMP_DIR}/liferay/tomcat/bin/catalina.sh stop + "./${TEMP_DIR}/liferay/tomcat/bin/catalina.sh" stop - sleep 30 + sleep 30 - kill -9 ${pid} 2>/dev/null + kill -9 "${pid}" 2>/dev/null - rm -fr ${TEMP_DIR}/liferay/data/osgi/state - rm -fr ${TEMP_DIR}/liferay/osgi/state + rm -fr "${TEMP_DIR}/liferay/data/osgi/state" + rm -fr "${TEMP_DIR}/liferay/osgi/state" } -function stat() { - if [ "$(uname)" == "Darwin" ]; then - echo $(/usr/bin/stat -f "%z" "${1}") - else - echo $(/usr/bin/stat --printf="%s" "${1}") - fi +function stat { + if [ "$(uname)" == "Darwin" ] + then + /usr/bin/stat -f "%z" "${1}" + else + /usr/bin/stat --printf="%s" "${1}" + fi } -function test_docker_image() { - export LIFERAY_DOCKER_IMAGE_ID="${DOCKER_IMAGE_TAGS[0]}" +function test_docker_image { + export LIFERAY_DOCKER_IMAGE_ID="${DOCKER_IMAGE_TAGS[0]}" - ./test_image.sh + ./test_image.sh - if [ $? -gt 0 ]; then - echo "Testing failed, exiting." + if [ $? -gt 0 ] + then + echo "Testing failed, exiting." - exit 2 - fi + exit 2 + fi } -function warm_up_tomcat() { - - # - # Warm up Tomcat for older versions to speed up starting Tomcat. Populating - # the Hypersonic files can take over 20 seconds. - # - - if [ -d ${TEMP_DIR}/liferay/data/hsql ]; then - if [ $(stat ${TEMP_DIR}/liferay/data/hsql/lportal.script) -lt 1024000 ]; then - start_tomcat - else - echo Tomcat is already warmed up. - fi - fi - - if [ -d ${TEMP_DIR}/liferay/data/hypersonic ]; then - if [ $(stat ${TEMP_DIR}/liferay/data/hypersonic/lportal.script) -lt 1024000 ]; then - start_tomcat - else - echo Tomcat is already warmed up. - fi - fi +function warm_up_tomcat { + + # + # Warm up Tomcat for older versions to speed up starting Tomcat. Populating + # the Hypersonic files can take over 20 seconds. + # + + if [ -d "${TEMP_DIR}/liferay/data/hsql" ] + then + if [ $(stat "${TEMP_DIR}/liferay/data/hsql/lportal.script") -lt 1024000 ] + then + start_tomcat + else + echo Tomcat is already warmed up. + fi + fi + + if [ -d "${TEMP_DIR}/liferay/data/hypersonic" ] + then + if [ $(stat "${TEMP_DIR}/liferay/data/hypersonic/lportal.script") -lt 1024000 ] + then + start_tomcat + else + echo Tomcat is already warmed up. + fi + fi } diff --git a/build_all_images.sh b/build_all_images.sh index 5f361fb..c92de8a 100755 --- a/build_all_images.sh +++ b/build_all_images.sh @@ -4,334 +4,346 @@ source ./_common.sh BUILD_ALL_IMAGES_PUSH=${1} -function build_image { +function build_base_image { + log_in_to_docker_hub + + if [[ $(get_latest_docker_hub_version "base") == $(./release_notes.sh get-version) ]] && [[ "${LIFERAY_DOCKER_DEVELOPER_MODE}" != "true" ]] + then + echo "" + echo "Docker image base is up to date." + + return + fi + + echo "" + echo "Building Docker image base." + echo "" + + LIFERAY_DOCKER_IMAGE_PLATFORMS="${LIFERAY_DOCKER_IMAGE_PLATFORMS}" time ./build_base_image.sh "${BUILD_ALL_IMAGES_PUSH}" | tee -a "${LOGS_DIR}"/base.log + + if [ "${PIPESTATUS[0]}" -gt 0 ] + then + echo "FAILED: Base" >> "${LOGS_DIR}/results" + + exit 1 + else + echo "SUCCESS: Base" >> "${LOGS_DIR}/results" + fi +} + +function build_bundle_image { + local query=${1} + local version=${2} + + local additional_tags=$(get_string $( yq "${query}".additional_tags < bundles.yml)) + local bundle_url=$(get_string $(yq "${query}".bundle_url < bundles.yml)) + local fix_pack_url=$(get_string $(yq "${query}".fix_pack_url < bundles.yml)) + local latest=$(get_string $(yq "${query}".latest < bundles.yml)) + local test_hotfix_url=$(get_string $(yq "${query}".test_hotfix_url < bundles.yml)) + local test_installed_patch=$(get_string $( yq "${query}".test_installed_patch < bundles.yml)) + + if [ -n "${additional_tags}" ] + then + version="${version},${additional_tags}" + fi + + if [ ! -n "${version}" ] + then + local build_id=${bundle_url##*/} + else + local build_id=${version} + fi + + echo "" + echo "Building Docker image ${build_id} based on ${bundle_url}." + echo "" + + LIFERAY_DOCKER_FIX_PACK_URL=${fix_pack_url} LIFERAY_DOCKER_IMAGE_PLATFORMS="${LIFERAY_DOCKER_IMAGE_PLATFORMS}" LIFERAY_DOCKER_LATEST=${latest} LIFERAY_DOCKER_RELEASE_FILE_URL=${bundle_url} LIFERAY_DOCKER_RELEASE_VERSION=${version} LIFERAY_DOCKER_TEST_HOTFIX_URL=${test_hotfix_url} LIFERAY_DOCKER_TEST_INSTALLED_PATCHES=${test_installed_patch} time ./build_bundle_image.sh "${BUILD_ALL_IMAGES_PUSH}" 2>&1 | tee "${LOGS_DIR}/${build_id}.log" + + local build_bundle_image_exit_code=${PIPESTATUS[0]} + + if [ "${build_bundle_image_exit_code}" -gt 0 ] + then + echo "FAILED: ${build_id}" >> "${LOGS_DIR}/results" + + if [ "${build_bundle_image_exit_code}" -eq 4 ] + then + echo "Detected a license failure while building image ${build_id}." > "${LOGS_DIR}/license-failure" + + echo "There is an existing license failure." + + exit 4 + fi + else + echo "SUCCESS: ${build_id}" >> "${LOGS_DIR}/results" + fi +} + +function build_bundle_images { # - # LIFERAY_DOCKER_IMAGE_FILTER="7.2.10-dxp-1 " ./build_all_images.sh + # LIFERAY_DOCKER_IMAGE_FILTER="7.2.10-dxp-1 " ./build_all_images.sh # LIFERAY_DOCKER_IMAGE_FILTER=7.2.10 ./build_all_images.sh - # LIFERAY_DOCKER_IMAGE_FILTER=commerce ./build_all_images.sh # - if [ -n "${LIFERAY_DOCKER_IMAGE_FILTER}" ] && [[ ! $(echo ${1} ${2} ${3} ${4} | grep ${LIFERAY_DOCKER_IMAGE_FILTER}) ]] + local main_keys=$(yq '' < bundles.yml | grep -v ' .*' | sed 's/://') + + local specified_version=${LIFERAY_DOCKER_IMAGE_FILTER} + + if [ -z "${LIFERAY_DOCKER_IMAGE_FILTER}" ] + then + specified_version="*" + fi + + local search_output=$(yq .\""${specified_version}"\" < bundles.yml) + + if [[ "${search_output}" != "null" ]] then + local versions=$(echo "${search_output}" | grep '^.*:$' | sed 's/://') + + for version in ${versions} + do + local query=.\"$(get_main_key "${main_keys}" "${version}")\".\"${version}\" + + build_bundle_image "${query}" "${version}" + done + else + local main_key=$(get_main_key "${main_keys}" "${specified_version}") + + if [[ "${main_key}" = "null" ]] + then + echo "No bundles were found." + + exit 1 + else + local query=.\"${main_key}\".\"${specified_version}\" + + if [[ "$(yq "${query}" < bundles.yml)" != "null" ]] + then + build_bundle_image "${query}" "${specified_version}" + else + echo "No bundles were found." + + exit 1 + fi + fi + fi +} + +function build_jdk11_image { + local jdk11_image_version=1.0 + local latest_available_zulu11_amd64_version=$(get_latest_available_zulu_version "11" "amd64") + local latest_available_zulu11_arm64_version=$(get_latest_available_zulu_version "11" "arm64") + + if [[ $(get_latest_docker_hub_zulu_version "jdk11" "11" "amd64") == "${latest_available_zulu11_amd64_version}" ]] && [[ $(get_latest_docker_hub_zulu_version "jdk11" "11" "arm64") == "${latest_available_zulu11_arm64_version}" ]] && [[ "${LIFERAY_DOCKER_DEVELOPER_MODE}" != "true" ]] + then + echo "" + echo "Docker image JDK 11 is up to date." + return fi - if [ ! -n "${1}" ] + echo "" + echo "Building Docker image JDK 11." + echo "" + + LIFERAY_DOCKER_IMAGE_PLATFORMS="${LIFERAY_DOCKER_IMAGE_PLATFORMS}" LIFERAY_DOCKER_ZULU_11_AMD64_VERSION=${latest_available_zulu11_amd64_version} LIFERAY_DOCKER_ZULU_11_ARM64_VERSION=${latest_available_zulu11_arm64_version} time ./build_jdk11_image.sh "${BUILD_ALL_IMAGES_PUSH}" | tee -a "${LOGS_DIR}"/jdk11.log + + if [ "${PIPESTATUS[0]}" -gt 0 ] then - local build_id=${2##*/} + echo "FAILED: JDK 11" >> "${LOGS_DIR}/results" + + exit 1 else - local build_id=${1} + echo "SUCCESS: JDK 11" >> "${LOGS_DIR}/results" + fi +} + +function build_jdk11_jdk8_image { + local jdk11_jdk8_image_version=1.0 + local latest_available_zulu8_amd64_version=$(get_latest_available_zulu_version "8" "amd64") + local latest_available_zulu8_arm64_version=$(get_latest_available_zulu_version "8" "arm64") + + if [[ $(get_latest_docker_hub_zulu_version "jdk11-jdk8" "8" "amd64") == "${latest_available_zulu8_amd64_version}" ]] && [[ $(get_latest_docker_hub_zulu_version "jdk11-jdk8" "8" "arm64") == "${latest_available_zulu8_arm64_version}" ]] && [[ "${LIFERAY_DOCKER_DEVELOPER_MODE}" != "true" ]] + then + echo "" + echo "Docker image JDK 8 is up to date." + + return fi echo "" - echo "Building Docker image ${build_id} based on ${2}." + echo "Building Docker image JDK 11/JDK 8." echo "" - { - LIFERAY_DOCKER_FIX_PACK_URL=${3} LIFERAY_DOCKER_RELEASE_FILE_URL=${2} LIFERAY_DOCKER_RELEASE_VERSION=${1} LIFERAY_DOCKER_TEST_HOTFIX_URL=${5} LIFERAY_DOCKER_TEST_INSTALLED_PATCHES=${4} time ./build_image.sh ${BUILD_ALL_IMAGES_PUSH} 2>&1 + LIFERAY_DOCKER_IMAGE_PLATFORMS="${LIFERAY_DOCKER_IMAGE_PLATFORMS}" LIFERAY_DOCKER_ZULU_8_AMD64_VERSION=${latest_available_zulu8_amd64_version} LIFERAY_DOCKER_ZULU_8_ARM64_VERSION=${latest_available_zulu8_arm64_version} time ./build_jdk11_jdk8_image.sh "${BUILD_ALL_IMAGES_PUSH}" | tee -a "${LOGS_DIR}"/jdk11_jdk8.log - if [ $? -gt 0 ] - then - echo "FAILED: ${build_id}" >> ${LOGS_DIR}/results - else - echo "SUCCESS: ${build_id}" >> ${LOGS_DIR}/results - fi - } | tee ${LOGS_DIR}/${build_id}".log" + if [ "${PIPESTATUS[0]}" -gt 0 ] + then + echo "FAILED: JDK 11/JDK 8" >> "${LOGS_DIR}/results" + + exit 1 + else + echo "SUCCESS: JDK 11/JDK 8" >> "${LOGS_DIR}/results" + fi } -function build_images_dxp_70 { - build_image \ - 7.0.10-ga1 \ - files.liferay.com/private/ee/portal/7.0.10/liferay-dxp-digital-enterprise-tomcat-7.0-ga1-20160617092557801.zip \ - "" \ - "" +function build_job_runner_image { + if [[ $(get_latest_docker_hub_version "job-runner") == $(./release_notes.sh get-version) ]] && [[ "${LIFERAY_DOCKER_DEVELOPER_MODE}" != "true" ]] + then + echo "" + echo "Docker image job runner is up to date." - build_image \ - 7.0.10-de-27 \ - files.liferay.com/private/ee/portal/7.0.10.4/liferay-dxp-digital-enterprise-tomcat-7.0-sp4-20170705142422877.zip \ - files.liferay.com/private/ee/fix-packs/7.0.10/de/liferay-fix-pack-de-27-7010.zip \ - de-27-7010 + return + fi - for fix_pack_id in {88..89} - do - build_image \ - 7.0.10-de-${fix_pack_id} \ - files.liferay.com/private/ee/portal/7.0.10.12/liferay-dxp-digital-enterprise-tomcat-7.0.10.12-sp12-20191014182832691.7z \ - files.liferay.com/private/ee/fix-packs/7.0.10/de/liferay-fix-pack-de-${fix_pack_id}-7010.zip \ - de-${fix_pack_id}-7010 - done + local job_runner_version=1.0 + + echo "" + echo "Building Docker image job runner." + echo "" + + LIFERAY_DOCKER_IMAGE_PLATFORMS="${LIFERAY_DOCKER_IMAGE_PLATFORMS}" time ./build_job_runner_image.sh "${BUILD_ALL_IMAGES_PUSH}" | tee -a "${LOGS_DIR}"/job_runner.log - build_image \ - 7.0.10-de-90,7.0.10-sp13 \ - files.liferay.com/private/ee/portal/7.0.10.13/liferay-dxp-digital-enterprise-tomcat-7.0.10.13-sp13-slim-20200310164407389.7z \ - "" \ - de-90-7010 - - build_image \ - 7.0.10-de-91 \ - files.liferay.com/private/ee/portal/7.0.10-de-91/liferay-dxp-digital-enterprise-tomcat-7.0.10-de-91-slim-20200420163527702.7z \ - "" \ - de-91-7010,hotfix-6871-7010 \ - files.liferay.com/private/ee/fix-packs/7.0.10/hotfix/liferay-hotfix-6871-7010.zip - - build_image \ - 7.0.10-security-de-91-202003-1 \ - files.liferay.com/private/ee/portal/7.0.10-de-91/liferay-dxp-digital-enterprise-tomcat-7.0.10-de-91-20200420163527702.7z \ - files.liferay.com/private/ee/fix-packs/7.0.10/security-de/liferay-security-de-91-202003-1-7010.zip \ - de-91-7010,security-de-91-202003-1-7010 - - build_image \ - 7.0.10-de-92 \ - files.liferay.com/private/ee/portal/7.0.10-de-92/liferay-dxp-digital-enterprise-tomcat-7.0.10-de-92-slim-20200519134012683.7z \ - "" \ - de-92-7010,hotfix-6854-7010 \ - files.liferay.com/private/ee/fix-packs/7.0.10/hotfix/liferay-hotfix-6854-7010.zip - - build_image \ - 7.0.10-security-de-92-202004-2 \ - files.liferay.com/private/ee/portal/7.0.10-de-92/liferay-dxp-digital-enterprise-tomcat-7.0.10-de-92-20200519134012683.7z \ - files.liferay.com/private/ee/fix-packs/7.0.10/security-de/liferay-security-de-92-202004-2-7010.zip \ - de-92-7010,security-de-92-202004-2-7010 - - build_image \ - 7.0.10-de-93,7.0.10-sp14 \ - files.liferay.com/private/ee/portal/7.0.10.14/liferay-dxp-digital-enterprise-tomcat-7.0.10.14-sp14-slim-20200708121519436.7z \ - "" \ - de-93-7010 - - build_image \ - 7.0.10-de-94 \ - files.liferay.com/private/ee/portal/7.0.10-de-94/liferay-dxp-digital-enterprise-tomcat-7.0.10-de-94-slim-20200824095125278.7z \ - "" \ - de-94-7010,hotfix-7623-7010 \ - files.liferay.com/private/ee/fix-packs/7.0.10/hotfix/liferay-hotfix-7623-7010.zip + if [ "${PIPESTATUS[0]}" -gt 0 ] + then + echo "FAILED: Job Runner" >> "${LOGS_DIR}/results" + + exit 1 + else + echo "SUCCESS: Job Runner" >> "${LOGS_DIR}/results" + fi } -function build_images_dxp_71 { - build_image \ - 7.1.10-ga1 \ - files.liferay.com/private/ee/portal/7.1.10/liferay-dxp-tomcat-7.1.10-ga1-20180703090613030.zip \ - "" \ - "" +function get_latest_available_zulu_version { + local version=$(curl -H 'accept: */*' -L -s "https://api.azul.com/zulu/download/community/v1.0/bundles/latest/?arch=${2}&bundle_type=jdk&ext=deb&hw_bitness=64&javafx=false&java_version=${1}&os=linux" | jq -r '.zulu_version | join(".")' | cut -f1,2,3 -d'.') - for fix_pack_id in {1..4} - do - build_image \ - 7.1.10-dxp-${fix_pack_id} \ - files.liferay.com/private/ee/portal/7.1.10/liferay-dxp-tomcat-7.1.10-ga1-20180703090613030.zip \ - files.liferay.com/private/ee/fix-packs/7.1.10/dxp/liferay-fix-pack-dxp-${fix_pack_id}-7110.zip \ - dxp-${fix_pack_id}-7110 - done + echo "${version}" +} - build_image \ - 7.1.10-dxp-5,7.1.10-sp1 \ - files.liferay.com/private/ee/portal/7.1.10.1/liferay-dxp-tomcat-7.1.10.1-sp1-20190110085705206.zip \ - "" \ - dxp-5-7110 +function get_latest_docker_hub_version { + local token=$(curl -s "https://auth.docker.io/token?scope=repository:liferay/${1}:pull&service=registry.docker.io" | jq -r '.token') - for fix_pack_id in {6..9} - do - build_image \ - 7.1.10-dxp-${fix_pack_id} \ - files.liferay.com/private/ee/portal/7.1.10.1/liferay-dxp-tomcat-7.1.10.1-sp1-20190110085705206.zip \ - files.liferay.com/private/ee/fix-packs/7.1.10/dxp/liferay-fix-pack-dxp-${fix_pack_id}-7110.zip \ - dxp-${fix_pack_id}-7110 - done + local version=$(curl -s -H "Authorization: Bearer $token" "https://registry-1.docker.io/v2/liferay/${1}/manifests/latest" | grep -o '\\"org.label-schema.version\\":\\"[0-9]\.[0-9]\.[0-9]*\\"' | head -1 | sed 's/\\"//g' | sed 's:.*\:::') - build_image \ - 7.1.10-dxp-10,7.1.10-sp2 \ - files.liferay.com/private/ee/portal/7.1.10.2/liferay-dxp-tomcat-7.1.10.2-sp2-20190422172027516.zip \ - "" \ - dxp-10-7110 + echo "${version}" +} - for fix_pack_id in {11..14} - do - build_image \ - 7.1.10-dxp-${fix_pack_id} \ - files.liferay.com/private/ee/portal/7.1.10.2/liferay-dxp-tomcat-7.1.10.2-sp2-20190422172027516.zip \ - files.liferay.com/private/ee/fix-packs/7.1.10/dxp/liferay-fix-pack-dxp-${fix_pack_id}-7110.zip \ - dxp-${fix_pack_id}-7110 - done +function get_latest_docker_hub_zulu_version { + local token=$(curl -s "https://auth.docker.io/token?scope=repository:liferay/${1}:pull&service=registry.docker.io" | jq -r '.token') - build_image \ - 7.1.10-dxp-15,7.1.10-sp3 \ - files.liferay.com/private/ee/portal/7.1.10.3/liferay-dxp-tomcat-7.1.10.3-sp3-slim-20191118185746787.7z \ - "" \ - dxp-15-7110 + local version=$(curl -s -H "Authorization: Bearer $token" "https://registry-1.docker.io/v2/liferay/${1}/manifests/latest" | grep -o "\\\\\"org.label-schema.zulu${2}_${3}_version\\\\\":\\\\\"[0-9]*\.[0-9]*\.[0-9]*\\\\\"" | head -1 | sed 's/\\"//g' | sed 's:.*\:::') - for fix_pack_id in {16..16} + echo "${version}" +} + +function get_main_key { + local main_keys=${1} + local version=${2} + + for main_key in ${main_keys} do - build_image \ - 7.1.10-dxp-${fix_pack_id} \ - files.liferay.com/private/ee/portal/7.1.10.3/liferay-dxp-tomcat-7.1.10.3-sp3-20191118185746787.7z \ - files.liferay.com/private/ee/fix-packs/7.1.10/dxp/liferay-fix-pack-dxp-${fix_pack_id}-7110.zip \ - dxp-${fix_pack_id}-7110 - done + local count=$(echo "${version}" | grep -c -E "${main_key}-|${main_key}\.") - build_image \ - 7.1.10-dxp-17,7.1.10-sp4 \ - files.liferay.com/private/ee/portal/7.1.10.4/liferay-dxp-tomcat-7.1.10.4-sp4-slim-20200331093526761.7z \ - "" \ - dxp-17-7110 - - build_image \ - 7.1.10-security-dxp-17-202003-3 \ - files.liferay.com/private/ee/portal/7.1.10.4/liferay-dxp-tomcat-7.1.10.4-sp4-20200331093526761.7z \ - files.liferay.com/private/ee/fix-packs/7.1.10/security-dxp/liferay-security-dxp-17-202003-3-7110.zip \ - dxp-17-7110,security-dxp-17-202003-3-7110 - - build_image \ - 7.1.10-security-dxp-17-202004-4 \ - files.liferay.com/private/ee/portal/7.1.10.4/liferay-dxp-tomcat-7.1.10.4-sp4-20200331093526761.7z \ - files.liferay.com/private/ee/fix-packs/7.1.10/security-dxp/liferay-security-dxp-17-202004-4-7110.zip \ - dxp-17-7110,security-dxp-17-202004-4-7110 - - build_image \ - 7.1.10-dxp-18 \ - files.liferay.com/private/ee/portal/7.1.10-dxp-18/liferay-dxp-tomcat-7.1.10-dxp-18-slim-20200708071442461.7z \ - "" \ - dxp-18-7110,hotfix-4445-7110 \ - files.liferay.com/private/ee/fix-packs/7.1.10/hotfix/liferay-hotfix-4445-7110.zip - - build_image \ - 7.1.10-dxp-19 \ - files.liferay.com/private/ee/portal/7.1.10-dxp-19/liferay-dxp-tomcat-7.1.10-dxp-19-slim-20200910000111431.7z \ - "" \ - dxp-19-7110,hotfix-4673-7110 \ - files.liferay.com/private/ee/fix-packs/7.1.10/hotfix/liferay-hotfix-4673-7110.zip -} + if [ "${count}" -gt 0 ] + then + echo "${main_key}" -function build_images_dxp_72 { - build_image \ - 7.2.10-ga1 \ - files.liferay.com/private/ee/portal/7.2.10/liferay-dxp-tomcat-7.2.10-ga1-20190531140450482.7z \ - "" \ - "" - - build_image \ - 7.2.10-dxp-1 \ - files.liferay.com/private/ee/portal/7.2.10/liferay-dxp-tomcat-7.2.10-ga1-20190531140450482.7z \ - files.liferay.com/private/ee/fix-packs/7.2.10/dxp/liferay-fix-pack-dxp-1-7210.zip \ - dxp-1-7210 - - build_image \ - 7.2.10-dxp-2,7.2.10-sp1 \ - files.liferay.com/private/ee/portal/7.2.10.1/liferay-dxp-tomcat-7.2.10.1-sp1-slim-20191009103614075.7z \ - "" \ - dxp-2-7210 - - build_image \ - 7.2.10-dxp-3 \ - files.liferay.com/private/ee/portal/7.2.10.1/liferay-dxp-tomcat-7.2.10.1-sp1-20191009103614075.7z \ - files.liferay.com/private/ee/fix-packs/7.2.10/dxp/liferay-fix-pack-dxp-3-7210.zip \ - dxp-3-7210 - - build_image \ - 7.2.10-dxp-4 \ - files.liferay.com/private/ee/portal/7.2.10-dxp-4/liferay-dxp-tomcat-7.2.10-dxp-4-slim-20200121112425051.7z \ - "" \ - dxp-4-7210,hotfix-1167-7210 \ - files.liferay.com/private/ee/fix-packs/7.2.10/hotfix/liferay-hotfix-1167-7210.zip - - build_image \ - 7.2.10-security-dxp-4-202003-4 \ - files.liferay.com/private/ee/portal/7.2.10-dxp-4/liferay-dxp-tomcat-7.2.10-dxp-4-20200121112425051.7z \ - files.liferay.com/private/ee/fix-packs/7.2.10/security-dxp/liferay-security-dxp-4-202003-4-7210.zip \ - dxp-4-7210,security-dxp-4-202003-4-7210 - - build_image \ - 7.2.10-dxp-5,7.2.10-sp2 \ - files.liferay.com/private/ee/portal/7.2.10.2/liferay-dxp-tomcat-7.2.10.2-sp2-slim-20200511121558464.7z \ - "" \ - dxp-5-7210,hotfix-1467-7210 \ - files.liferay.com/private/ee/fix-packs/7.2.10/hotfix/liferay-hotfix-1467-7210.zip - - build_image \ - 7.2.10-security-dxp-5-202003-1 \ - files.liferay.com/private/ee/portal/7.2.10.2/liferay-dxp-tomcat-7.2.10.2-sp2-20200511121558464.7z \ - files.liferay.com/private/ee/fix-packs/7.2.10/security-dxp/liferay-security-dxp-5-202003-1-7210.zip \ - dxp-5-7210,security-dxp-5-202003-1-7210 - - build_image \ - 7.2.10-dxp-6 \ - files.liferay.com/private/ee/portal/7.2.10-dxp-6/liferay-dxp-tomcat-7.2.10-dxp-6-slim-20200611120504742.7z \ - "" \ - dxp-6-7210,hotfix-1992-7210 \ - files.liferay.com/private/ee/fix-packs/7.2.10/hotfix/liferay-hotfix-1992-7210.zip - - build_image \ - 7.2.10-security-dxp-6-202004-4 \ - files.liferay.com/private/ee/portal/7.2.10-dxp-6/liferay-dxp-tomcat-7.2.10-dxp-6-20200611120504742.7z \ - files.liferay.com/private/ee/fix-packs/7.2.10/security-dxp/liferay-security-dxp-6-202004-4-7210.zip \ - dxp-6-7210,security-dxp-6-202004-4-7210 - - build_image \ - 7.2.10-dxp-7 \ - files.liferay.com/private/ee/portal/7.2.10-dxp-7/liferay-dxp-tomcat-7.2.10-dxp-7-slim-20200727205713822.7z \ - "" \ - dxp-7-7210,hotfix-2457-7210 \ - files.liferay.com/private/ee/fix-packs/7.2.10/hotfix/liferay-hotfix-2457-7210.zip - - build_image \ - 7.2.10-dxp-8,7.2.10-sp3 \ - files.liferay.com/private/ee/portal/7.2.10.3/liferay-dxp-tomcat-7.2.10.3-sp3-slim-20200910120006703.7z \ - "" \ - dxp-8-7210,hotfix-2824-7210 \ - files.liferay.com/private/ee/fix-packs/7.2.10/hotfix/liferay-hotfix-2824-7210.zip + break + fi + done } -function build_images_dxp_73 { - build_image \ - 7.3.10-ep6 \ - files.liferay.com/private/ee/portal/7.3.10-ep6/liferay-dxp-tomcat-7.3.10-ga1-20200914085138595.7z \ - "" \ - "" +function get_string { + if [ "${1}" == "null" ] + then + echo "" + else + echo "${1}" + fi } function main { + check_utils 7z curl docker git java jq sed sort tr unzip yq + if [ "${BUILD_ALL_IMAGES_PUSH}" == "push" ] && ! ./release_notes.sh fail-on-change then exit 1 fi + if [ "${BUILD_ALL_IMAGES_PUSH}" == "push" ] && [ -z "${LIFERAY_DOCKER_IMAGE_PLATFORMS}" ] + then + LIFERAY_DOCKER_IMAGE_PLATFORMS=linux/amd64,linux/arm64 + fi + + validate_bundles_yml + LOGS_DIR=logs-$(date "$(date)" "+%Y%m%d%H%M") - mkdir -p ${LOGS_DIR} - - local release_file_urls=( - #releases.liferay.com/commerce/2.0.7/liferay-commerce-2.0.7-7.2.x-201912261227.7z - files.liferay.com/private/ee/commerce/2.1.2/liferay-commerce-enterprise-2.1.2-7.1.x-202007312031.7z - files.liferay.com/private/ee/commerce/2.1.2/liferay-commerce-enterprise-2.1.2-7.2.x-202007312039.7z - releases.liferay.com/portal/6.1.2-ga3/liferay-portal-tomcat-6.1.2-ce-ga3-20130816114619181.zip - files.liferay.com/private/ee/portal/6.1.30.5/liferay-portal-tomcat-6.1-ee-ga3-sp5-20160201142343123.zip - releases.liferay.com/portal/6.2.5-ga6/liferay-portal-tomcat-6.2-ce-ga6-20160112152609836.zip - files.liferay.com/private/ee/portal/6.2.10.21/liferay-portal-tomcat-6.2-ee-sp20-20170717160924965.zip - releases.liferay.com/portal/7.0.6-ga7/liferay-ce-portal-tomcat-7.0-ga7-20180507111753223.zip - releases.liferay.com/portal/7.1.3-ga4/liferay-ce-portal-tomcat-7.1.3-ga4-20190508171117552.7z - releases.liferay.com/portal/7.2.1-ga2/liferay-ce-portal-tomcat-7.2.1-ga2-20191111141448326.7z - releases.liferay.com/portal/7.3.4-ga5/liferay-ce-portal-tomcat-7.3.4-ga5-20200811154319029.7z - #releases.liferay.com/portal/snapshot-7.1.x/201902130905/liferay-portal-tomcat-7.1.x.7z - #releases.liferay.com/portal/snapshot-master/201902131509/liferay-portal-tomcat-master.7z - #files.liferay.com/private/ee/portal/snapshot-ee-6.2.x/201808160944/liferay-portal-tomcat-ee-6.2.x.zip - #files.liferay.com/private/ee/portal/snapshot-7.1.x-private/201808162051/liferay-portal-tomcat-7.1.x-private.zip - ) - - for release_file_url in ${release_file_urls[@]} - do - build_image "" ${release_file_url} "" "" - done + mkdir -p "${LOGS_DIR}" + + build_base_image + + build_jdk11_image - build_images_dxp_70 - build_images_dxp_71 - build_images_dxp_72 - build_images_dxp_73 + build_jdk11_jdk8_image + + build_job_runner_image + + build_bundle_images echo "" echo "Results: " echo "" - cat ${LOGS_DIR}/results + cat "${LOGS_DIR}/results" +} + +function validate_bundles_yml { + if [ $(yq '.*.*.latest' < bundles.yml | grep "true" -c) -gt 2 ] + then + echo "There are too many images designated as latest." + + exit 1 + fi + + local dxp_latest_key_counter=0 + local main_keys=$(yq '' < bundles.yml | grep -v ' .*' | sed 's/://') + local portal_latest_key_counter=0 + + for main_key in ${main_keys} + do + if [ $(yq .\""${main_key}"\".*.latest < bundles.yml | grep "true\|false" -c) -gt 0 ] + then + local minor_keys=$(yq .\""${main_key}"\" < bundles.yml | grep -v ' .*' | sed 's/://') + + for minor_key in ${minor_keys} + do + if [ $(yq .\""${main_key}"\".\""${minor_key}"\".latest < bundles.yml | grep "true\|false" -c) -gt 0 ] + then + if [ $(yq .\""${main_key}"\".\""${minor_key}"\".bundle_url < bundles.yml | grep "portal-tomcat") ] + then + portal_latest_key_counter=$((portal_latest_key_counter+1)) + elif [ $(yq .\""${main_key}"\".\""${minor_key}"\".bundle_url < bundles.yml | grep "dxp-tomcat") ] + then + dxp_latest_key_counter=$((dxp_latest_key_counter+1)) + fi + fi + done + fi + done + + if [ ${dxp_latest_key_counter} -gt 1 ] + then + echo "There are ${dxp_latest_key_counter} latest DXP images." + + exit 1 + elif [ ${portal_latest_key_counter} -gt 1 ] + then + echo "There are ${portal_latest_key_counter} latest portal images." + + exit 1 + fi } main \ No newline at end of file diff --git a/build_base_image.sh b/build_base_image.sh new file mode 100644 index 0000000..54c735c --- /dev/null +++ b/build_base_image.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +source ./_common.sh + +function build_docker_image { + local image_version=$(./release_notes.sh get-version) + + DOCKER_IMAGE_TAGS=() + DOCKER_IMAGE_TAGS+=("${LIFERAY_DOCKER_REPOSITORY}liferay/base:${image_version}-${TIMESTAMP}") + DOCKER_IMAGE_TAGS+=("${LIFERAY_DOCKER_REPOSITORY}liferay/base") + + if [ "${1}" == "push" ] + then + check_docker_buildx + + docker buildx build \ + --build-arg LABEL_BUILD_DATE=$(date "${CURRENT_DATE}" "+%Y-%m-%dT%H:%M:%SZ") \ + --build-arg LABEL_NAME="Liferay Base" \ + --build-arg LABEL_VCS_REF=$(git rev-parse HEAD) \ + --build-arg LABEL_VCS_URL="https://github.com/liferay/liferay-docker" \ + --build-arg LABEL_VERSION="${image_version}" \ + --builder "liferay-buildkit" \ + --platform "${LIFERAY_DOCKER_IMAGE_PLATFORMS}" \ + --push \ + $(get_docker_image_tags_args "${DOCKER_IMAGE_TAGS[@]}") \ + "${TEMP_DIR}" || exit 1 + else + remove_temp_dockerfile_platform_variable + + docker build \ + --build-arg LABEL_BUILD_DATE=$(date "${CURRENT_DATE}" "+%Y-%m-%dT%H:%M:%SZ") \ + --build-arg LABEL_NAME="Liferay Base" \ + --build-arg LABEL_VCS_REF=$(git rev-parse HEAD) \ + --build-arg LABEL_VCS_URL="https://github.com/liferay/liferay-docker" \ + --build-arg LABEL_VERSION="${image_version}" \ + $(get_docker_image_tags_args "${DOCKER_IMAGE_TAGS[@]}") \ + "${TEMP_DIR}" || exit 1 + fi +} + +function main { + delete_local_images "liferay/base" + + make_temp_directory templates/base + + log_in_to_docker_hub + + build_docker_image "${1}" + + clean_up_temp_directory +} + +main "${@}" \ No newline at end of file diff --git a/build_bundle_image.sh b/build_bundle_image.sh new file mode 100644 index 0000000..cd804cd --- /dev/null +++ b/build_bundle_image.sh @@ -0,0 +1,340 @@ +#!/bin/bash + +source ./_common.sh + +function build_docker_image { + if [[ ${LIFERAY_DOCKER_RELEASE_FILE_URL%} == */snapshot-* ]] + then + DOCKER_IMAGE_NAME=${DOCKER_IMAGE_NAME}-snapshot + fi + + if [[ ${LIFERAY_DOCKER_RELEASE_FILE_URL} == http://release-* ]] || [[ ${LIFERAY_DOCKER_RELEASE_FILE_URL} == *release.liferay.com* ]] + then + DOCKER_IMAGE_NAME=${DOCKER_IMAGE_NAME}-snapshot + fi + + local release_version=${LIFERAY_DOCKER_RELEASE_FILE_URL%/*} + + release_version=${release_version##*/} + + if [[ ${LIFERAY_DOCKER_RELEASE_FILE_URL} == http://release-* ]] || [[ ${LIFERAY_DOCKER_RELEASE_FILE_URL} == *release.liferay.com* ]] + then + release_version=${LIFERAY_DOCKER_RELEASE_FILE_URL#*tomcat-} + release_version=${release_version%.*} + fi + + if [[ ${LIFERAY_DOCKER_RELEASE_FILE_URL} == *files.liferay.com/* ]] && [[ ${LIFERAY_DOCKER_RELEASE_FILE_URL%} != */snapshot-* ]] + then + local file_name_release_version=${LIFERAY_DOCKER_RELEASE_FILE_URL#*tomcat-} + + file_name_release_version=${file_name_release_version%.*} + file_name_release_version=${file_name_release_version%-*} + + if [[ ${file_name_release_version} == *-slim ]] + then + file_name_release_version=${file_name_release_version%-slim} + fi + + local service_pack_name=${file_name_release_version##*-} + fi + + if [[ ${service_pack_name} == ga* ]] || [[ ${service_pack_name} == sp* ]] + then + release_version=${release_version}-${service_pack_name} + fi + + LABEL_VERSION=${release_version} + + if [[ ${LIFERAY_DOCKER_RELEASE_FILE_URL%} == */snapshot-* ]] + then + local release_branch=${LIFERAY_DOCKER_RELEASE_FILE_URL%/*} + + release_branch=${release_branch%/*} + release_branch=${release_branch%-private*} + release_branch=${release_branch##*-} + + local release_hash=$(cat "${TEMP_DIR}/liferay/.githash") + + release_hash=${release_hash:0:7} + + if [[ ${release_branch} == master ]] + then + LABEL_VERSION="Master Snapshot on ${LABEL_VERSION} at ${release_hash}" + else + LABEL_VERSION="${release_branch} Snapshot on ${LABEL_VERSION} at ${release_hash}" + fi + fi + + if [ -n "${LIFERAY_DOCKER_RELEASE_VERSION}" ] + then + release_version=${LIFERAY_DOCKER_RELEASE_VERSION} + fi + + DOCKER_IMAGE_TAGS=() + + local default_ifs=${IFS} + + IFS="," + + for release_version_single in ${release_version} + do + if [[ ${LIFERAY_DOCKER_RELEASE_FILE_URL%} == */snapshot-* ]] + then + DOCKER_IMAGE_TAGS+=("${LIFERAY_DOCKER_REPOSITORY}liferay/${DOCKER_IMAGE_NAME}:${release_branch}-${release_version_single}-${release_hash}") + DOCKER_IMAGE_TAGS+=("${LIFERAY_DOCKER_REPOSITORY}liferay/${DOCKER_IMAGE_NAME}:${release_branch}-$(date "${CURRENT_DATE}" "+%Y%m%d")") + DOCKER_IMAGE_TAGS+=("${LIFERAY_DOCKER_REPOSITORY}liferay/${DOCKER_IMAGE_NAME}:${release_branch}") + else + DOCKER_IMAGE_TAGS+=("${LIFERAY_DOCKER_REPOSITORY}liferay/${DOCKER_IMAGE_NAME}:${release_version_single}-d$(./release_notes.sh get-version)-${TIMESTAMP}") + DOCKER_IMAGE_TAGS+=("${LIFERAY_DOCKER_REPOSITORY}liferay/${DOCKER_IMAGE_NAME}:${release_version_single}") + fi + done + + if [[ "${LIFERAY_DOCKER_LATEST}" = "true" ]] + then + DOCKER_IMAGE_TAGS+=("${LIFERAY_DOCKER_REPOSITORY}liferay/${DOCKER_IMAGE_NAME}:latest") + fi + + if [ -e "${TEMP_DIR}/liferay/.githash" ] + then + LIFERAY_VCS_REF=$(cat "${TEMP_DIR}/liferay/.githash") + fi + + IFS=${default_ifs} + + remove_temp_dockerfile_platform_variable + + docker build \ + --build-arg LABEL_BUILD_DATE=$(date "${CURRENT_DATE}" "+%Y-%m-%dT%H:%M:%SZ") \ + --build-arg LABEL_LIFERAY_VCS_REF="${LIFERAY_VCS_REF}" \ + --build-arg LABEL_NAME="${DOCKER_LABEL_NAME}" \ + --build-arg LABEL_TOMCAT_VERSION=$(get_tomcat_version "${TEMP_DIR}/liferay") \ + --build-arg LABEL_VCS_REF=$(git rev-parse HEAD) \ + --build-arg LABEL_VCS_URL="https://github.com/liferay/liferay-docker" \ + --build-arg LABEL_VERSION="${LABEL_VERSION}" \ + $(get_docker_image_tags_args "${DOCKER_IMAGE_TAGS[@]}") \ + "${TEMP_DIR}" || exit 1 +} + +function check_release { + if [[ ${RELEASE_FILE_NAME} == *-dxp-* ]] || [[ ${RELEASE_FILE_NAME} == *-private* ]] + then + DOCKER_IMAGE_NAME="dxp" + DOCKER_LABEL_NAME="Liferay DXP" + elif [[ ${RELEASE_FILE_NAME} == *-portal-* ]] + then + DOCKER_IMAGE_NAME="portal" + DOCKER_LABEL_NAME="Liferay Portal" + else + echo "${RELEASE_FILE_NAME} is an unsupported release file name." + + exit 1 + fi +} + +function check_usage { + if [ ! -n "${LIFERAY_DOCKER_RELEASE_FILE_URL}" ] + then + echo "Usage: ${0} " + echo "" + echo "The script reads the following environment variables:" + echo "" + echo " LIFERAY_DOCKER_DEVELOPER_MODE (optional): If set to \"true\" all local images will be deleted before building a one." + echo " LIFERAY_DOCKER_FIX_PACK_URL (optional): URL to a fix pack" + echo " LIFERAY_DOCKER_HUB_TOKEN (optional): Docker Hub token to log in automatically" + echo " LIFERAY_DOCKER_HUB_USERNAME (optional): Docker Hub username to log in automatically" + echo " LIFERAY_DOCKER_IMAGE_PLATFORMS (optional): Comma separated Docker image platforms to build when the \"push\" parameter is set" + echo " LIFERAY_DOCKER_LICENSE_API_HEADER (required for DXP): API header used to generate the trial license" + echo " LIFERAY_DOCKER_LICENSE_API_URL (required for DXP): API URL to generate the trial license" + echo " LIFERAY_DOCKER_RELEASE_FILE_URL (required): URL to a Liferay bundle" + echo " LIFERAY_DOCKER_REPOSITORY (optional): Docker repository" + echo "" + echo "Example: LIFERAY_DOCKER_RELEASE_FILE_URL=files.liferay.com/private/ee/portal/7.2.10/liferay-dxp-tomcat-7.2.10-ga1-20190531140450482.7z ${0} push" + echo "" + echo "Set \"push\" as a parameter to automatically push the image to Docker Hub." + + exit 1 + fi + + check_utils 7z curl docker java unzip +} + +function download_trial_dxp_license { + if [[ ${DOCKER_IMAGE_NAME} == "dxp" ]] + then + rm -fr "${TEMP_DIR}/liferay/data/license" + + if (! ./download_trial_dxp_license.sh "${TEMP_DIR}/liferay" $(date "${CURRENT_DATE}" "+%s000")) + then + exit 4 + fi + fi +} + +function install_fix_pack { + if [ -n "${LIFERAY_DOCKER_FIX_PACK_URL}" ] + then + local fix_pack_url=${LIFERAY_DOCKER_FIX_PACK_URL} + + FIX_PACK_FILE_NAME=${fix_pack_url##*/} + + download downloads/fix-packs/"${FIX_PACK_FILE_NAME}" "${fix_pack_url}" + + cp "downloads/fix-packs/${FIX_PACK_FILE_NAME}" "${TEMP_DIR}/liferay/patching-tool/patches" + + "${TEMP_DIR}/liferay/patching-tool/patching-tool.sh" install + "${TEMP_DIR}/liferay/patching-tool/patching-tool.sh" separate temp + + rm -fr "${TEMP_DIR}/liferay/osgi/state/"* + rm -f "${TEMP_DIR}/liferay/patching-tool/patches/"* + fi +} + +function main { + check_usage "${@}" + + make_temp_directory templates/bundle + + set_parent_image + + prepare_temp_directory "${@}" + + check_release "${@}" + + update_patching_tool + + install_fix_pack "${@}" + + prepare_tomcat + + download_trial_dxp_license + + build_docker_image + + test_docker_image + + log_in_to_docker_hub + + push_docker_image "${1}" + + clean_up_temp_directory +} + +function prepare_temp_directory { + RELEASE_FILE_NAME=${LIFERAY_DOCKER_RELEASE_FILE_URL##*/} + + local download_dir=${LIFERAY_DOCKER_RELEASE_FILE_URL%/*} + + download_dir=${download_dir#*com/} + download_dir=${download_dir#*com/} + download_dir=${download_dir#*liferay-release-tool/} + download_dir=${download_dir#*private/ee/} + download_dir=downloads/${download_dir} + + download "${download_dir}/${RELEASE_FILE_NAME}" "${LIFERAY_DOCKER_RELEASE_FILE_URL}" + + if [[ ${RELEASE_FILE_NAME} == *.7z ]] + then + 7z x -O"${TEMP_DIR}" "${download_dir}/${RELEASE_FILE_NAME}" || exit 3 + else + unzip -d "${TEMP_DIR}" -q "${download_dir}/${RELEASE_FILE_NAME}" || exit 3 + fi + + mv "${TEMP_DIR}/liferay-"* "${TEMP_DIR}/liferay" +} + +function push_docker_image { + if [ "${1}" == "push" ] + then + check_docker_buildx + + sed -i '1s/FROM /FROM --platform=${TARGETPLATFORM} /g' "${TEMP_DIR}"/Dockerfile + + docker buildx build \ + --build-arg LABEL_BUILD_DATE=$(date "${CURRENT_DATE}" "+%Y-%m-%dT%H:%M:%SZ") \ + --build-arg LABEL_LIFERAY_VCS_REF="${LIFERAY_VCS_REF}" \ + --build-arg LABEL_NAME="${DOCKER_LABEL_NAME}" \ + --build-arg LABEL_TOMCAT_VERSION=$(get_tomcat_version "${TEMP_DIR}/liferay") \ + --build-arg LABEL_VCS_REF=$(git rev-parse HEAD) \ + --build-arg LABEL_VCS_URL="https://github.com/liferay/liferay-docker" \ + --build-arg LABEL_VERSION="${LABEL_VERSION}" \ + --builder "liferay-buildkit" \ + --platform "${LIFERAY_DOCKER_IMAGE_PLATFORMS}" \ + --push \ + $(get_docker_image_tags_args "${DOCKER_IMAGE_TAGS[@]}") \ + "${TEMP_DIR}" || exit 1 + fi +} + +function set_parent_image { + if [ "$(echo "${LIFERAY_DOCKER_RELEASE_VERSION%-*}" | cut -f1,2,3 -d'.' | cut -f1 -d '-' | sed 's/\.//g' )" -le 7310 ] + then + sed -i 's/liferay\/jdk11:latest/liferay\/jdk11-jdk8:latest/g' "${TEMP_DIR}"/Dockerfile + fi +} + +function update_patching_tool { + if [ -e "${TEMP_DIR}/liferay/patching-tool" ] + then + local patching_tool_minor_version=$("${TEMP_DIR}"/liferay/patching-tool/patching-tool.sh info | grep "patching-tool version") + + if [ ! -n "${patching_tool_minor_version}" ] + then + patching_tool_minor_version="2.0.0" + else + patching_tool_minor_version=${patching_tool_minor_version##*patching-tool version: } + fi + + patching_tool_minor_version=${patching_tool_minor_version%.*} + + if (! echo ${patching_tool_minor_version} | grep -e '[0-9]*[.][0-9]*' >/dev/null) + then + echo "Patching Tool update is skipped as it's not a 1.0+ version or the bundle did not include a properly configured Patching Tool." + + return + fi + + mv "${TEMP_DIR}/liferay/patching-tool/patches" "${TEMP_DIR}/liferay/patching-tool-upgrade-patches" + + rm -fr "${TEMP_DIR}/liferay/patching-tool" + + + local latest_patching_tool_version + + # + # Set the latest patching tool version in a separate line to get the + # proper exit code. + # + + latest_patching_tool_version=$(./patching_tool_version.sh ${patching_tool_minor_version}) + + local exit_code=$? + + if [ ${exit_code} -gt 0 ] + then + echo "./patching_tool_version.sh returned with an error: ${latest_patching_tool_version}" + + exit ${exit_code} + fi + + echo "" + echo "Updating Patching Tool to version ${latest_patching_tool_version}." + echo "" + + download "downloads/patching-tool/patching-tool-${latest_patching_tool_version}.zip" "files.liferay.com/private/ee/fix-packs/patching-tool/patching-tool-${latest_patching_tool_version}.zip" + + unzip -d "${TEMP_DIR}/liferay" -q "downloads/patching-tool/patching-tool-${latest_patching_tool_version}.zip" + + "${TEMP_DIR}/liferay/patching-tool/patching-tool.sh" auto-discovery + + rm -fr "${TEMP_DIR}/liferay/patching-tool/patches" + + mv "${TEMP_DIR}/liferay/patching-tool-upgrade-patches" "${TEMP_DIR}/liferay/patching-tool/patches" + + if [ ! -n "${LIFERAY_DOCKER_TEST_PATCHING_TOOL_VERSION}" ] + then + export LIFERAY_DOCKER_TEST_PATCHING_TOOL_VERSION="${latest_patching_tool_version}" + fi + fi +} + +main "${@}" \ No newline at end of file diff --git a/build_image.sh b/build_image.sh deleted file mode 100755 index 0b9eb01..0000000 --- a/build_image.sh +++ /dev/null @@ -1,258 +0,0 @@ -#!/bin/bash - -source ./_common.sh - -function build_docker_image { - local docker_image_name - local label_name - - if [[ ${RELEASE_FILE_NAME} == *-commerce-enterprise-* ]] - then - docker_image_name="commerce-enterprise" - label_name="Liferay Commerce Enterprise" - elif [[ ${RELEASE_FILE_NAME} == *-commerce-* ]] - then - docker_image_name="commerce" - label_name="Liferay Commerce" - elif [[ ${RELEASE_FILE_NAME} == *-dxp-* ]] || [[ ${RELEASE_FILE_NAME} == *-private* ]] - then - docker_image_name="dxp" - label_name="Liferay DXP" - elif [[ ${RELEASE_FILE_NAME} == *-portal-* ]] - then - docker_image_name="portal" - label_name="Liferay Portal" - else - echo "${RELEASE_FILE_NAME} is an unsupported release file name." - - exit 1 - fi - - if [[ ${LIFERAY_DOCKER_RELEASE_FILE_URL%} == */snapshot-* ]] - then - docker_image_name=${docker_image_name}-snapshot - fi - - if [[ ${LIFERAY_DOCKER_RELEASE_FILE_URL} == http://release-* ]] || [[ ${LIFERAY_DOCKER_RELEASE_FILE_URL} == *release.liferay.com* ]] - then - docker_image_name=${docker_image_name}-snapshot - fi - - local release_version=${LIFERAY_DOCKER_RELEASE_FILE_URL%/*} - - release_version=${release_version##*/} - - if [[ ${LIFERAY_DOCKER_RELEASE_FILE_URL} == http://release-* ]] || [[ ${LIFERAY_DOCKER_RELEASE_FILE_URL} == *release.liferay.com* ]] - then - release_version=${LIFERAY_DOCKER_RELEASE_FILE_URL#*tomcat-} - release_version=${release_version%.*} - fi - - if [[ ${LIFERAY_DOCKER_RELEASE_FILE_URL} == *files.liferay.com/* ]] && [[ ${LIFERAY_DOCKER_RELEASE_FILE_URL%} != */snapshot-* ]] - then - local file_name_release_version=${LIFERAY_DOCKER_RELEASE_FILE_URL#*tomcat-} - - file_name_release_version=${file_name_release_version%.*} - file_name_release_version=${file_name_release_version%-*} - - if [[ ${file_name_release_version} == *-slim ]] - then - file_name_release_version=${file_name_release_version%-slim} - fi - - local service_pack_name=${file_name_release_version##*-} - fi - - if [[ ${service_pack_name} == ga* ]] || [[ ${service_pack_name} == sp* ]] - then - release_version=${release_version}-${service_pack_name} - fi - - if [[ ${RELEASE_FILE_NAME} == *-commerce-* ]] - then - local commerce_portal_variant=${LIFERAY_DOCKER_RELEASE_FILE_URL%-*} - - commerce_portal_variant=${commerce_portal_variant: -5} - - release_version=${release_version}-${commerce_portal_variant} - fi - - local label_version=${release_version} - - if [[ ${LIFERAY_DOCKER_RELEASE_FILE_URL%} == */snapshot-* ]] - then - local release_branch=${LIFERAY_DOCKER_RELEASE_FILE_URL%/*} - - release_branch=${release_branch%/*} - release_branch=${release_branch%-private*} - release_branch=${release_branch##*-} - - local release_hash=$(cat ${TEMP_DIR}/liferay/.githash) - - release_hash=${release_hash:0:7} - - if [[ ${release_branch} == master ]] - then - label_version="Master Snapshot on ${label_version} at ${release_hash}" - else - label_version="${release_branch} Snapshot on ${label_version} at ${release_hash}" - fi - fi - - if [ -n "${LIFERAY_DOCKER_RELEASE_VERSION}" ] - then - release_version=${LIFERAY_DOCKER_RELEASE_VERSION} - fi - - DOCKER_IMAGE_TAGS=() - - local default_ifs=${IFS} - - IFS="," - - for release_version_single in ${release_version} - do - if [[ ${LIFERAY_DOCKER_RELEASE_FILE_URL%} == */snapshot-* ]] - then - DOCKER_IMAGE_TAGS+=("liferay/${docker_image_name}:${release_branch}-${release_version_single}-${release_hash}") - DOCKER_IMAGE_TAGS+=("liferay/${docker_image_name}:${release_branch}-$(date "${CURRENT_DATE}" "+%Y%m%d")") - DOCKER_IMAGE_TAGS+=("liferay/${docker_image_name}:${release_branch}") - else - DOCKER_IMAGE_TAGS+=("liferay/${docker_image_name}:${release_version_single}-d$(./release_notes.sh get-version)-${TIMESTAMP}") - DOCKER_IMAGE_TAGS+=("liferay/${docker_image_name}:${release_version_single}") - fi - done - - IFS=${default_ifs} - - docker build \ - --build-arg LABEL_BUILD_DATE=$(date "${CURRENT_DATE}" "+%Y-%m-%dT%H:%M:%SZ") \ - --build-arg LABEL_NAME="${label_name}" \ - --build-arg LABEL_VCS_REF=$(git rev-parse HEAD) \ - --build-arg LABEL_VCS_URL="https://github.com/liferay/liferay-docker" \ - --build-arg LABEL_VERSION="${label_version}" \ - $(get_docker_image_tags_args ${DOCKER_IMAGE_TAGS[@]}) \ - ${TEMP_DIR} -} - -function check_usage { - if [ ! -n "${LIFERAY_DOCKER_RELEASE_FILE_URL}" ] - then - echo "Usage: ${0} " - echo "" - echo "The script reads the following environment variables:" - echo "" - echo " LIFERAY_DOCKER_FIX_PACK_URL (optional): URL to a fix pack" - echo " LIFERAY_DOCKER_LICENSE_CMD (required for DXP): Command to generate the trial license" - echo " LIFERAY_DOCKER_RELEASE_FILE_URL (required): URL to a Liferay bundle" - echo "" - echo "Example: LIFERAY_DOCKER_RELEASE_FILE_URL=files.liferay.com/private/ee/portal/7.2.10/liferay-dxp-tomcat-7.2.10-ga1-20190531140450482.7z ${0} push" - echo "" - echo "Set \"push\" as a parameter to automatically push the image to Docker Hub." - - exit 1 - fi - - check_utils 7z curl docker java unzip -} - -function download_trial_dxp_license { - rm -fr ${TEMP_DIR}/liferay/data/license - - ./download_trial_dxp_license.sh ${TEMP_DIR}/liferay $(date "${CURRENT_DATE}" "+%s%3N") ${RELEASE_FILE_NAME} -} - -function install_fix_pack { - if [ -n "${LIFERAY_DOCKER_FIX_PACK_URL}" ] - then - local fix_pack_url=${LIFERAY_DOCKER_FIX_PACK_URL} - - FIX_PACK_FILE_NAME=${fix_pack_url##*/} - - download downloads/fix-packs/${FIX_PACK_FILE_NAME} ${fix_pack_url} - - cp downloads/fix-packs/${FIX_PACK_FILE_NAME} ${TEMP_DIR}/liferay/patching-tool/patches - - ${TEMP_DIR}/liferay/patching-tool/patching-tool.sh install - ${TEMP_DIR}/liferay/patching-tool/patching-tool.sh separate temp - - rm -fr ${TEMP_DIR}/liferay/osgi/state/* - rm -f ${TEMP_DIR}/liferay/patching-tool/patches/* - fi -} - -function main { - check_usage ${@} - - make_temp_directory - - prepare_temp_directory ${@} - - update_patching_tool - - install_fix_pack ${@} - - prepare_tomcat - - download_trial_dxp_license - - build_docker_image - - test_docker_image - - push_docker_images ${1} - - clean_up_temp_directory -} - -function prepare_temp_directory { - RELEASE_FILE_NAME=${LIFERAY_DOCKER_RELEASE_FILE_URL##*/} - - local download_dir=${LIFERAY_DOCKER_RELEASE_FILE_URL%/*} - - download_dir=${download_dir#*com/} - download_dir=${download_dir#*com/} - download_dir=${download_dir#*liferay-release-tool/} - download_dir=${download_dir#*private/ee/} - download_dir=downloads/${download_dir} - - download ${download_dir}/${RELEASE_FILE_NAME} ${LIFERAY_DOCKER_RELEASE_FILE_URL} - - if [[ ${RELEASE_FILE_NAME} == *.7z ]] - then - 7z x -O${TEMP_DIR} ${download_dir}/${RELEASE_FILE_NAME} || exit 3 - else - unzip -q ${download_dir}/${RELEASE_FILE_NAME} -d ${TEMP_DIR} || exit 3 - fi - - mv ${TEMP_DIR}/liferay-* ${TEMP_DIR}/liferay -} - -function update_patching_tool { - if [ -e ${TEMP_DIR}/liferay/patching-tool ] - then - mv ${TEMP_DIR}/liferay/patching-tool/patches ${TEMP_DIR}/liferay/patching-tool-upgrade-patches - - rm -fr ${TEMP_DIR}/liferay/patching-tool - - download ${TEMP_DIR}/LATEST-2.0.txt files.liferay.com/private/ee/fix-packs/patching-tool/LATEST-2.0.txt - - local latest_patching_tool_version=$(cat ${TEMP_DIR}/LATEST-2.0.txt) - - echo "" - echo "Updating Patching Tool to version ${latest_patching_tool_version}." - echo "" - - download downloads/patching-tool/patching-tool-${latest_patching_tool_version}.zip files.liferay.com/private/ee/fix-packs/patching-tool/patching-tool-${latest_patching_tool_version}.zip - - unzip -d ${TEMP_DIR}/liferay -q downloads/patching-tool/patching-tool-${latest_patching_tool_version}.zip - - ${TEMP_DIR}/liferay/patching-tool/patching-tool.sh auto-discovery - - rm -fr ${TEMP_DIR}/liferay/patching-tool/patches - - mv ${TEMP_DIR}/liferay/patching-tool-upgrade-patches ${TEMP_DIR}/liferay/patching-tool/patches - fi -} - -main ${@} \ No newline at end of file diff --git a/build_jdk11_image.sh b/build_jdk11_image.sh new file mode 100755 index 0000000..3aad292 --- /dev/null +++ b/build_jdk11_image.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +source ./_common.sh + +function build_docker_image { + local image_version=$(./release_notes.sh get-version) + + DOCKER_IMAGE_TAGS=() + DOCKER_IMAGE_TAGS+=("${LIFERAY_DOCKER_REPOSITORY}liferay/jdk11:${image_version}-${TIMESTAMP}") + DOCKER_IMAGE_TAGS+=("${LIFERAY_DOCKER_REPOSITORY}liferay/jdk11") + + if [ "${1}" == "push" ] + then + check_docker_buildx + + docker buildx build \ + --build-arg LABEL_BUILD_DATE=$(date "${CURRENT_DATE}" "+%Y-%m-%dT%H:%M:%SZ") \ + --build-arg LABEL_NAME="Liferay JDK11" \ + --build-arg LABEL_VCS_REF=$(git rev-parse HEAD) \ + --build-arg LABEL_VCS_URL="https://github.com/liferay/liferay-docker" \ + --build-arg LABEL_VERSION="${image_version}" \ + --build-arg LABEL_ZULU_11_AMD64_VERSION="${LIFERAY_DOCKER_ZULU_11_AMD64_VERSION}" \ + --build-arg LABEL_ZULU_11_ARM64_VERSION="${LIFERAY_DOCKER_ZULU_11_ARM64_VERSION}" \ + --builder "liferay-buildkit" \ + --platform "${LIFERAY_DOCKER_IMAGE_PLATFORMS}" \ + --push \ + $(get_docker_image_tags_args "${DOCKER_IMAGE_TAGS[@]}") \ + "${TEMP_DIR}" || exit 1 + else + remove_temp_dockerfile_platform_variable + + docker build \ + --build-arg LABEL_BUILD_DATE=$(date "${CURRENT_DATE}" "+%Y-%m-%dT%H:%M:%SZ") \ + --build-arg LABEL_NAME="Liferay JDK11" \ + --build-arg LABEL_VCS_REF=$(git rev-parse HEAD) \ + --build-arg LABEL_VCS_URL="https://github.com/liferay/liferay-docker" \ + --build-arg LABEL_VERSION="${image_version}" \ + --build-arg LABEL_ZULU_11_AMD64_VERSION="${LIFERAY_DOCKER_ZULU_11_AMD64_VERSION}" \ + --build-arg LABEL_ZULU_11_ARM64_VERSION="${LIFERAY_DOCKER_ZULU_11_ARM64_VERSION}" \ + $(get_docker_image_tags_args "${DOCKER_IMAGE_TAGS[@]}") \ + "${TEMP_DIR}" || exit 1 + fi +} + +function main { + delete_local_images "liferay/jdk11" + + make_temp_directory templates/jdk11 + + log_in_to_docker_hub + + build_docker_image "${1}" + + clean_up_temp_directory +} + +main "${@}" \ No newline at end of file diff --git a/build_jdk11_jdk8_image.sh b/build_jdk11_jdk8_image.sh new file mode 100755 index 0000000..8cede7f --- /dev/null +++ b/build_jdk11_jdk8_image.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +source ./_common.sh + +function build_docker_image { + local image_version=$(./release_notes.sh get-version) + + DOCKER_IMAGE_TAGS=() + DOCKER_IMAGE_TAGS+=("${LIFERAY_DOCKER_REPOSITORY}liferay/jdk11-jdk8:${image_version}-${TIMESTAMP}") + DOCKER_IMAGE_TAGS+=("${LIFERAY_DOCKER_REPOSITORY}liferay/jdk11-jdk8") + + if [ "${1}" == "push" ] + then + check_docker_buildx + + docker buildx build \ + --build-arg LABEL_BUILD_DATE=$(date "${CURRENT_DATE}" "+%Y-%m-%dT%H:%M:%SZ") \ + --build-arg LABEL_NAME="Liferay JDK11 JDK8" \ + --build-arg LABEL_VCS_REF=$(git rev-parse HEAD) \ + --build-arg LABEL_VCS_URL="https://github.com/liferay/liferay-docker" \ + --build-arg LABEL_VERSION="${image_version}" \ + --build-arg LABEL_ZULU_8_AMD64_VERSION="${LIFERAY_DOCKER_ZULU_8_AMD64_VERSION}" \ + --build-arg LABEL_ZULU_8_ARM64_VERSION="${LIFERAY_DOCKER_ZULU_8_ARM64_VERSION}" \ + --builder "liferay-buildkit" \ + --platform "${LIFERAY_DOCKER_IMAGE_PLATFORMS}" \ + --push \ + $(get_docker_image_tags_args "${DOCKER_IMAGE_TAGS[@]}") \ + "${TEMP_DIR}" || exit 1 + else + remove_temp_dockerfile_platform_variable + + docker build \ + --build-arg LABEL_BUILD_DATE=$(date "${CURRENT_DATE}" "+%Y-%m-%dT%H:%M:%SZ") \ + --build-arg LABEL_NAME="Liferay JDK11 JDK8" \ + --build-arg LABEL_VCS_REF=$(git rev-parse HEAD) \ + --build-arg LABEL_VCS_URL="https://github.com/liferay/liferay-docker" \ + --build-arg LABEL_VERSION="${image_version}" \ + --build-arg LABEL_ZULU_8_AMD64_VERSION="${LIFERAY_DOCKER_ZULU_8_AMD64_VERSION}" \ + --build-arg LABEL_ZULU_8_ARM64_VERSION="${LIFERAY_DOCKER_ZULU_8_ARM64_VERSION}" \ + $(get_docker_image_tags_args "${DOCKER_IMAGE_TAGS[@]}") \ + "${TEMP_DIR}" || exit 1 + fi +} + +function main { + delete_local_images "liferay/jdk11-jdk8" + + make_temp_directory templates/jdk11-jdk8 + + log_in_to_docker_hub + + build_docker_image "${1}" + + clean_up_temp_directory +} + +main "${@}" \ No newline at end of file diff --git a/build_job_runner_image.sh b/build_job_runner_image.sh new file mode 100755 index 0000000..46b8ac9 --- /dev/null +++ b/build_job_runner_image.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +source ./_common.sh + +function build_docker_image { + local base_image_version=$(./release_notes.sh get-version) + local job_runner_image_version=0.1.5 + + DOCKER_IMAGE_TAGS=() + DOCKER_IMAGE_TAGS+=("${LIFERAY_DOCKER_REPOSITORY}liferay/job-runner:${job_runner_image_version}-d${base_image_version}-${TIMESTAMP}") + DOCKER_IMAGE_TAGS+=("${LIFERAY_DOCKER_REPOSITORY}liferay/job-runner:${job_runner_image_version%.*}") + DOCKER_IMAGE_TAGS+=("${LIFERAY_DOCKER_REPOSITORY}liferay/job-runner") + + if [ "${1}" == "push" ] + then + check_docker_buildx + + docker buildx build \ + --build-arg LABEL_BUILD_DATE=$(date "${CURRENT_DATE}" "+%Y-%m-%dT%H:%M:%SZ") \ + --build-arg LABEL_JOB_RUNNER_VERSION="${job_runner_image_version}" \ + --build-arg LABEL_NAME="Liferay Job Runner" \ + --build-arg LABEL_VCS_REF=$(git rev-parse HEAD) \ + --build-arg LABEL_VCS_URL="https://github.com/liferay/liferay-docker" \ + --build-arg LABEL_VERSION="${base_image_version}" \ + --builder "liferay-buildkit" \ + --platform "${LIFERAY_DOCKER_IMAGE_PLATFORMS}" \ + --push \ + $(get_docker_image_tags_args "${DOCKER_IMAGE_TAGS[@]}") \ + "${TEMP_DIR}" || exit 1 + else + remove_temp_dockerfile_platform_variable + + docker build \ + --build-arg LABEL_BUILD_DATE=$(date "${CURRENT_DATE}" "+%Y-%m-%dT%H:%M:%SZ") \ + --build-arg LABEL_JOB_RUNNER_VERSION="${job_runner_image_version}" \ + --build-arg LABEL_NAME="Liferay Job Runner" \ + --build-arg LABEL_VCS_REF=$(git rev-parse HEAD) \ + --build-arg LABEL_VCS_URL="https://github.com/liferay/liferay-docker" \ + --build-arg LABEL_VERSION="${base_image_version}" \ + $(get_docker_image_tags_args "${DOCKER_IMAGE_TAGS[@]}") \ + "${TEMP_DIR}" || exit 1 + fi +} + +function main { + make_temp_directory templates/job-runner + + log_in_to_docker_hub + + build_docker_image "${1}" + + clean_up_temp_directory +} + +main "${@}" \ No newline at end of file diff --git a/build_local_image.sh b/build_local_image.sh index ed49047..74266c0 100755 --- a/build_local_image.sh +++ b/build_local_image.sh @@ -2,9 +2,9 @@ source ./_common.sh -function build_docker_image() { - local docker_image_name=${2} - local release_version=${3} +function build_docker_image { + local docker_image_name=${2} + local release_version=${3} DOCKER_IMAGE_TAGS=() @@ -48,7 +48,7 @@ function check_usage() { function main() { check_usage ${@} - make_temp_directory + make_temp_directory templates/bundle if [[ ${5} == "jboss-eap" ]]; then @@ -67,18 +67,18 @@ function main() { install_hotfix "${@}" else - prepare_temp_directory ${@} + prepare_temp_directory "${@}" prepare_tomcat fi - build_docker_image ${@} + build_docker_image "${@}" if [[ ${5} != "jboss-eap" ]]; then test_docker_image fi - push_docker_images ${4} + push_docker_images "${4}" clean_up_temp_directory } @@ -96,7 +96,7 @@ function prepare_patching_tool() { } function prepare_temp_directory() { - cp -a ${1} ${TEMP_DIR}/liferay + cp -a "${1}" "${TEMP_DIR}/liferay" } -main ${@} +main "${@}" diff --git a/bundles.yml b/bundles.yml new file mode 100644 index 0000000..b1694c1 --- /dev/null +++ b/bundles.yml @@ -0,0 +1,345 @@ +6.1.2: + 6.1.2-ga3: + bundle_url: releases.liferay.com/portal/6.1.2-ga3/liferay-portal-tomcat-6.1.2-ce-ga3-20130816114619181.zip +6.1.30: + 6.1.30.5: + bundle_url: files.liferay.com/private/ee/portal/6.1.30.5/liferay-portal-tomcat-6.1-ee-ga3-sp5-20160201142343123.zip +6.2.5: + 6.2.5-ga6: + bundle_url: releases.liferay.com/portal/6.2.5-ga6/liferay-portal-tomcat-6.2-ce-ga6-20160112152609836.zip +6.2.10: + 6.2.10.21: + bundle_url: files.liferay.com/private/ee/portal/6.2.10.21/liferay-portal-tomcat-6.2-ee-sp20-20170717160924965.zip +7.0.6: + 7.0.6-ga7: + bundle_url: releases.liferay.com/portal/7.0.6-ga7/liferay-ce-portal-tomcat-7.0-ga7-20180507111753223.zip +7.0.10: + 7.0.10-ga1: + bundle_url: files.liferay.com/private/ee/portal/7.0.10/liferay-dxp-digital-enterprise-tomcat-7.0-ga1-20160617092557801.zip + 7.0.10-de-27: + bundle_url: files.liferay.com/private/ee/portal/7.0.10.4/liferay-dxp-digital-enterprise-tomcat-7.0-sp4-20170705142422877.zip + fix_pack_url: files.liferay.com/private/ee/fix-packs/7.0.10/de/liferay-fix-pack-de-27-7010.zip + test_installed_patch: de-27-7010 + 7.0.10-de-88: + bundle_url: files.liferay.com/private/ee/portal/7.0.10.12/liferay-dxp-digital-enterprise-tomcat-7.0.10.12-sp12-20191014182832691.7z + fix_pack_url: files.liferay.com/private/ee/fix-packs/7.0.10/de/liferay-fix-pack-de-88-7010.zip + test_installed_patch: de-88-7010 + 7.0.10-de-89: + bundle_url: files.liferay.com/private/ee/portal/7.0.10.12/liferay-dxp-digital-enterprise-tomcat-7.0.10.12-sp12-20191014182832691.7z + fix_pack_url: files.liferay.com/private/ee/fix-packs/7.0.10/de/liferay-fix-pack-de-89-7010.zip + test_installed_patch: de-89-7010 + 7.0.10-sp13: + additional_tags: 7.0.10-de-90 + bundle_url: files.liferay.com/private/ee/portal/7.0.10.13/liferay-dxp-digital-enterprise-tomcat-7.0.10.13-sp13-slim-20200310164407389.7z + test_installed_patch: de-90-7010 + 7.0.10-de-91: + bundle_url: files.liferay.com/private/ee/portal/7.0.10-de-91/liferay-dxp-digital-enterprise-tomcat-7.0.10-de-91-slim-20200420163527702.7z + test_installed_patch: de-91-7010,hotfix-6871-7010 + test_hotfix_url: files.liferay.com/private/ee/fix-packs/7.0.10/hotfix/liferay-hotfix-6871-7010.zip + 7.0.10-security-de-91-202003-1: + bundle_url: files.liferay.com/private/ee/portal/7.0.10-de-91/liferay-dxp-digital-enterprise-tomcat-7.0.10-de-91-20200420163527702.7z + fix_pack_url: files.liferay.com/private/ee/fix-packs/7.0.10/security-de/liferay-security-de-91-202003-1-7010.zip + test_installed_patch: de-91-7010,security-de-91-202003-1-7010 + 7.0.10-de-92: + bundle_url: files.liferay.com/private/ee/portal/7.0.10-de-92/liferay-dxp-digital-enterprise-tomcat-7.0.10-de-92-slim-20200519134012683.7z + test_installed_patch: de-92-7010,hotfix-6854-7010 + test_hotfix_url: files.liferay.com/private/ee/fix-packs/7.0.10/hotfix/liferay-hotfix-6854-7010.zip + 7.0.10-security-de-92-202004-2: + bundle_url: files.liferay.com/private/ee/portal/7.0.10-de-92/liferay-dxp-digital-enterprise-tomcat-7.0.10-de-92-20200519134012683.7z + fix_pack_url: files.liferay.com/private/ee/fix-packs/7.0.10/security-de/liferay-security-de-92-202004-2-7010.zip + test_installed_patch: de-92-7010,security-de-92-202004-2-7010 + 7.0.10-sp14: + additional_tags: 7.0.10-de-93 + bundle_url: files.liferay.com/private/ee/portal/7.0.10.14/liferay-dxp-digital-enterprise-tomcat-7.0.10.14-sp14-slim-20200708121519436.7z + test_installed_patch: de-93-7010 + 7.0.10-de-94: + bundle_url: files.liferay.com/private/ee/portal/7.0.10-de-94/liferay-dxp-digital-enterprise-tomcat-7.0.10-de-94-slim-20200824095125278.7z + test_installed_patch: de-94-7010,hotfix-7623-7010 + test_hotfix_url: files.liferay.com/private/ee/fix-packs/7.0.10/hotfix/liferay-hotfix-7623-7010.zip + 7.0.10-de-95: + bundle_url: files.liferay.com/private/ee/portal/7.0.10-de-95/liferay-dxp-digital-enterprise-tomcat-7.0.10-de-95-slim-20200925114352092.7z + test_installed_patch: de-95-7010,hotfix-7683-7010 + test_hotfix_url: files.liferay.com/private/ee/fix-packs/7.0.10/hotfix/liferay-hotfix-7683-7010.zip + 7.0.10-sp15: + additional_tags: 7.0.10-de-96 + bundle_url: files.liferay.com/private/ee/portal/7.0.10.15/liferay-dxp-digital-enterprise-tomcat-7.0.10.15-sp15-slim-20201027133245711.7z + test_installed_patch: de-96-7010,hotfix-7777-7010 + test_hotfix_url: files.liferay.com/private/ee/fix-packs/7.0.10/hotfix/liferay-hotfix-7777-7010.zip + 7.0.10-de-97: + bundle_url: files.liferay.com/private/ee/portal/7.0.10-de-97/liferay-dxp-digital-enterprise-tomcat-7.0.10-de-97-slim-20210204052206153.7z + test_installed_patch: de-97-7010,hotfix-7996-7010 + test_hotfix_url: files.liferay.com/private/ee/fix-packs/7.0.10/hotfix/liferay-hotfix-7996-7010.zip + 7.0.10-de-98: + bundle_url: files.liferay.com/private/ee/portal/7.0.10-de-98/liferay-dxp-digital-enterprise-tomcat-7.0.10-de-98-slim-20210310205342362.7z + test_installed_patch: de-98-7010,hotfix-8081-7010 + test_hotfix_url: files.liferay.com/private/ee/fix-packs/7.0.10/hotfix/liferay-hotfix-8081-7010.zip + 7.0.10-sp16: + additional_tags: 7.0.10-de-99 + bundle_url: files.liferay.com/private/ee/portal/7.0.10.16/liferay-dxp-digital-enterprise-tomcat-7.0.10.16-sp16-slim-20210422121811252.7z + test_installed_patch: de-99-7010,hotfix-8205-7010 + test_hotfix_url: files.liferay.com/private/ee/fix-packs/7.0.10/hotfix/liferay-hotfix-8205-7010.zip + 7.0.10-de-100: + bundle_url: files.liferay.com/private/ee/portal/7.0.10-de-100/liferay-dxp-digital-enterprise-tomcat-7.0.10-de-100-slim-20210602170649068.7z + test_installed_patch: de-100-7010,hotfix-8262-7010 + test_hotfix_url: files.liferay.com/private/ee/fix-packs/7.0.10/hotfix/liferay-hotfix-8262-7010.zip + 7.0.10-de-101: + bundle_url: files.liferay.com/private/ee/portal/7.0.10-de-101/liferay-dxp-digital-enterprise-tomcat-7.0.10-de-101-slim-20210713081427192.7z + test_installed_patch: de-101-7010,hotfix-8457-7010 + test_hotfix_url: files.liferay.com/private/ee/fix-packs/7.0.10/hotfix/liferay-hotfix-8457-7010.zip + 7.0.10-de-102: + bundle_url: files.liferay.com/private/ee/portal/7.0.10.17/liferay-dxp-digital-enterprise-tomcat-7.0.10.17-sp17-slim-20211014075354439.7z + test_installed_patch: de-102-7010,hotfix-8594-7010 + test_hotfix_url: files.liferay.com/private/ee/fix-packs/7.0.10/hotfix/liferay-hotfix-8594-7010.zip +7.1.3: + 7.1.3-ga4: + bundle_url: releases.liferay.com/portal/7.1.3-ga4/liferay-ce-portal-tomcat-7.1.3-ga4-20190508171117552.7z +7.1.10: + 7.1.10-ga1: + bundle_url: files.liferay.com/private/ee/portal/7.1.10/liferay-dxp-tomcat-7.1.10-ga1-20180703090613030.zip + 7.1.10-dxp-1: + bundle_url: files.liferay.com/private/ee/portal/7.1.10/liferay-dxp-tomcat-7.1.10-ga1-20180703090613030.zip + fix_pack_url: files.liferay.com/private/ee/fix-packs/7.1.10/dxp/liferay-fix-pack-dxp-1-7110.zip + test_installed_patch: dxp-1-7110 + 7.1.10-dxp-2: + bundle_url: files.liferay.com/private/ee/portal/7.1.10/liferay-dxp-tomcat-7.1.10-ga1-20180703090613030.zip + fix_pack_url: files.liferay.com/private/ee/fix-packs/7.1.10/dxp/liferay-fix-pack-dxp-2-7110.zip + test_installed_patch: dxp-2-7110 + 7.1.10-dxp-3: + bundle_url: files.liferay.com/private/ee/portal/7.1.10/liferay-dxp-tomcat-7.1.10-ga1-20180703090613030.zip + fix_pack_url: files.liferay.com/private/ee/fix-packs/7.1.10/dxp/liferay-fix-pack-dxp-3-7110.zip + test_installed_patch: dxp-3-7110 + 7.1.10-dxp-4: + bundle_url: files.liferay.com/private/ee/portal/7.1.10/liferay-dxp-tomcat-7.1.10-ga1-20180703090613030.zip + fix_pack_url: files.liferay.com/private/ee/fix-packs/7.1.10/dxp/liferay-fix-pack-dxp-4-7110.zip + test_installed_patch: dxp-4-7110 + 7.1.10-sp1: + additional_tags: 7.1.10-dxp-5 + bundle_url: files.liferay.com/private/ee/portal/7.1.10.1/liferay-dxp-tomcat-7.1.10.1-sp1-20190110085705206.zip + test_installed_patch: dxp-5-7110 + 7.1.10-dxp-6: + bundle_url: files.liferay.com/private/ee/portal/7.1.10.1/liferay-dxp-tomcat-7.1.10.1-sp1-20190110085705206.zip + fix_pack_url: files.liferay.com/private/ee/fix-packs/7.1.10/dxp/liferay-fix-pack-dxp-6-7110.zip + test_installed_patch: dxp-6-7110 + 7.1.10-dxp-7: + bundle_url: files.liferay.com/private/ee/portal/7.1.10.1/liferay-dxp-tomcat-7.1.10.1-sp1-20190110085705206.zip + fix_pack_url: files.liferay.com/private/ee/fix-packs/7.1.10/dxp/liferay-fix-pack-dxp-7-7110.zip + test_installed_patch: dxp-7-7110 + 7.1.10-dxp-8: + bundle_url: files.liferay.com/private/ee/portal/7.1.10.1/liferay-dxp-tomcat-7.1.10.1-sp1-20190110085705206.zip + fix_pack_url: files.liferay.com/private/ee/fix-packs/7.1.10/dxp/liferay-fix-pack-dxp-8-7110.zip + test_installed_patch: dxp-8-7110 + 7.1.10-dxp-9: + bundle_url: files.liferay.com/private/ee/portal/7.1.10.1/liferay-dxp-tomcat-7.1.10.1-sp1-20190110085705206.zip + fix_pack_url: files.liferay.com/private/ee/fix-packs/7.1.10/dxp/liferay-fix-pack-dxp-9-7110.zip + test_installed_patch: dxp-9-7110 + 7.1.10-sp2: + additional_tags: 7.1.10-dxp-10 + bundle_url: files.liferay.com/private/ee/portal/7.1.10.2/liferay-dxp-tomcat-7.1.10.2-sp2-20190422172027516.zip + test_installed_patch: dxp-10-7110 + 7.1.10-dxp-11: + bundle_url: files.liferay.com/private/ee/portal/7.1.10.2/liferay-dxp-tomcat-7.1.10.2-sp2-20190422172027516.zip + fix_pack_url: files.liferay.com/private/ee/fix-packs/7.1.10/dxp/liferay-fix-pack-dxp-11-7110.zip + test_installed_patch: dxp-11-7110 + 7.1.10-dxp-12: + bundle_url: files.liferay.com/private/ee/portal/7.1.10.2/liferay-dxp-tomcat-7.1.10.2-sp2-20190422172027516.zip + fix_pack_url: files.liferay.com/private/ee/fix-packs/7.1.10/dxp/liferay-fix-pack-dxp-12-7110.zip + test_installed_patch: dxp-12-7110 + 7.1.10-dxp-13: + bundle_url: files.liferay.com/private/ee/portal/7.1.10.2/liferay-dxp-tomcat-7.1.10.2-sp2-20190422172027516.zip + fix_pack_url: files.liferay.com/private/ee/fix-packs/7.1.10/dxp/liferay-fix-pack-dxp-13-7110.zip + test_installed_patch: dxp-13-7110 + 7.1.10-dxp-14: + bundle_url: files.liferay.com/private/ee/portal/7.1.10.2/liferay-dxp-tomcat-7.1.10.2-sp2-20190422172027516.zip + fix_pack_url: files.liferay.com/private/ee/fix-packs/7.1.10/dxp/liferay-fix-pack-dxp-14-7110.zip + test_installed_patch: dxp-14-7110 + 7.1.10-sp3: + additional_tags: 7.1.10-dxp-15 + bundle_url: files.liferay.com/private/ee/portal/7.1.10.3/liferay-dxp-tomcat-7.1.10.3-sp3-slim-20191118185746787.7z + test_installed_patch: dxp-15-7110 + 7.1.10-dxp-16: + bundle_url: files.liferay.com/private/ee/portal/7.1.10.3/liferay-dxp-tomcat-7.1.10.3-sp3-20191118185746787.7z + fix_pack_url: files.liferay.com/private/ee/fix-packs/7.1.10/dxp/liferay-fix-pack-dxp-16-7110.zip + test_installed_patch: dxp-16-7110 + 7.1.10-sp4: + additional_tags: 7.1.10-dxp-17 + bundle_url: files.liferay.com/private/ee/portal/7.1.10.4/liferay-dxp-tomcat-7.1.10.4-sp4-slim-20200331093526761.7z + test_installed_patch: dxp-17-7110 + 7.1.10-security-dxp-17-202003-3: + bundle_url: files.liferay.com/private/ee/portal/7.1.10.4/liferay-dxp-tomcat-7.1.10.4-sp4-20200331093526761.7z + fix_pack_url: files.liferay.com/private/ee/fix-packs/7.1.10/security-dxp/liferay-security-dxp-17-202003-3-7110.zip + test_installed_patch: dxp-17-7110,security-dxp-17-202003-3-7110 + 7.1.10-security-dxp-17-202004-4: + bundle_url: files.liferay.com/private/ee/portal/7.1.10.4/liferay-dxp-tomcat-7.1.10.4-sp4-20200331093526761.7z + fix_pack_url: files.liferay.com/private/ee/fix-packs/7.1.10/security-dxp/liferay-security-dxp-17-202004-4-7110.zip + test_installed_patch: dxp-17-7110,security-dxp-17-202004-4-7110 + 7.1.10-dxp-18: + bundle_url: files.liferay.com/private/ee/portal/7.1.10-dxp-18/liferay-dxp-tomcat-7.1.10-dxp-18-slim-20200708071442461.7z + test_installed_patch: dxp-18-7110,hotfix-4445-7110 + test_hotfix_url: files.liferay.com/private/ee/fix-packs/7.1.10/hotfix/liferay-hotfix-4445-7110.zip + 7.1.10-dxp-19: + bundle_url: files.liferay.com/private/ee/portal/7.1.10-dxp-19/liferay-dxp-tomcat-7.1.10-dxp-19-slim-20200910000111431.7z + test_installed_patch: dxp-19-7110,hotfix-4673-7110 + test_hotfix_url: files.liferay.com/private/ee/fix-packs/7.1.10/hotfix/liferay-hotfix-4673-7110.zip + 7.1.10-sp5: + additional_tags: 7.1.10-dxp-20 + bundle_url: https://files.liferay.com/private/ee/portal/7.1.10.5/liferay-dxp-tomcat-7.1.10.5-sp5-slim-20201203111512784.7z + test_installed_patch: dxp-20-7110,hotfix-5087-7110 + test_hotfix_url: http://files.liferay.com/private/ee/fix-packs/7.1.10/hotfix/liferay-hotfix-5087-7110.zip + 7.1.10-dxp-21: + bundle_url: files.liferay.com/private/ee/portal/7.1.10-dxp-21/liferay-dxp-tomcat-7.1.10-dxp-21-slim-20210129112915686.7z + test_installed_patch: dxp-21-7110,hotfix-5178-7110 + test_hotfix_url: files.liferay.com/private/ee/fix-packs/7.1.10/hotfix/liferay-hotfix-5178-7110.zip + 7.1.10-dxp-22: + bundle_url: files.liferay.com/private/ee/portal/7.1.10-dxp-22/liferay-dxp-tomcat-7.1.10-dxp-22-slim-20210303111136677.7z + test_installed_patch: dxp-22-7110,hotfix-5330-7110 + test_hotfix_url: files.liferay.com/private/ee/fix-packs/7.1.10/hotfix/liferay-hotfix-5330-7110.zip + 7.1.10-sp6: + additional_tags: 7.1.10-dxp-23 + bundle_url: files.liferay.com/private/ee/portal/7.1.10.6/liferay-dxp-tomcat-7.1.10.6-sp6-slim-20210507185421428.7z + test_installed_patch: dxp-23-7110,hotfix-5503-7110 + test_hotfix_url: files.liferay.com/private/ee/fix-packs/7.1.10/hotfix/liferay-hotfix-5503-7110.zip + 7.1.10-dxp-24: + bundle_url: files.liferay.com/private/ee/portal/7.1.10-dxp-24/liferay-dxp-tomcat-7.1.10-dxp-24-slim-20210607121821009.7z + test_installed_patch: dxp-24-7110,hotfix-5545-7110 + test_hotfix_url: files.liferay.com/private/ee/fix-packs/7.1.10/hotfix/liferay-hotfix-5545-7110.zip + 7.1.10-dxp-25: + bundle_url: files.liferay.com/private/ee/portal/7.1.10-dxp-25/liferay-dxp-tomcat-7.1.10-dxp-25-slim-20210914164558560.7z + test_installed_patch: dxp-25-7110,hotfix-5779-7110 + test_hotfix_url: files.liferay.com/private/ee/fix-packs/7.1.10/hotfix/liferay-hotfix-5779-7110.zip + 7.1.10-sp7: + additional_tags: 7.1.10-dxp-26 + bundle_url: files.liferay.com/private/ee/portal/7.1.10.7/liferay-dxp-tomcat-7.1.10.7-sp7-slim-20211103124348738.7z + test_installed_patch: dxp-26-7110,hotfix-5886-7110 + test_hotfix_url: files.liferay.com/private/ee/fix-packs/7.1.10/hotfix/liferay-hotfix-5886-7110.zip +7.2.1: + 7.2.1-ga2: + bundle_url: releases.liferay.com/portal/7.2.1-ga2/liferay-ce-portal-tomcat-7.2.1-ga2-20191111141448326.7z +7.2.10: + 7.2.10-ga1: + bundle_url: files.liferay.com/private/ee/portal/7.2.10/liferay-dxp-tomcat-7.2.10-ga1-20190531140450482.7z + 7.2.10-dxp-1: + bundle_url: files.liferay.com/private/ee/portal/7.2.10/liferay-dxp-tomcat-7.2.10-ga1-20190531140450482.7z + fix_pack_url: files.liferay.com/private/ee/fix-packs/7.2.10/dxp/liferay-fix-pack-dxp-1-7210.zip + test_installed_patch: dxp-1-7210 + 7.2.10-dxp-2: + bundle_url: files.liferay.com/private/ee/portal/7.2.10.1/liferay-dxp-tomcat-7.2.10.1-sp1-slim-20191009103614075.7z + test_installed_patch: dxp-2-7210 + 7.2.10-dxp-3: + bundle_url: files.liferay.com/private/ee/portal/7.2.10.1/liferay-dxp-tomcat-7.2.10.1-sp1-20191009103614075.7z + fix_pack_url: files.liferay.com/private/ee/fix-packs/7.2.10/dxp/liferay-fix-pack-dxp-3-7210.zip + test_installed_patch: dxp-3-7210 + 7.2.10-dxp-4: + bundle_url: files.liferay.com/private/ee/portal/7.2.10-dxp-4/liferay-dxp-tomcat-7.2.10-dxp-4-slim-20200121112425051.7z + test_installed_patch: dxp-4-7210,hotfix-1167-7210 + test_hotfix_url: files.liferay.com/private/ee/fix-packs/7.2.10/hotfix/liferay-hotfix-1167-7210.zip + 7.2.10-security-dxp-4-202003-4: + bundle_url: files.liferay.com/private/ee/portal/7.2.10-dxp-4/liferay-dxp-tomcat-7.2.10-dxp-4-20200121112425051.7z + fix_pack_url: files.liferay.com/private/ee/fix-packs/7.2.10/security-dxp/liferay-security-dxp-4-202003-4-7210.zip + test_installed_patch: dxp-4-7210,security-dxp-4-202003-4-7210 + 7.2.10-sp2: + additional_tags: 7.2.10-dxp-5 + bundle_url: files.liferay.com/private/ee/portal/7.2.10.2/liferay-dxp-tomcat-7.2.10.2-sp2-slim-20200511121558464.7z + test_installed_patch: dxp-5-7210,hotfix-1467-7210 + test_hotfix_url: files.liferay.com/private/ee/fix-packs/7.2.10/hotfix/liferay-hotfix-1467-7210.zip + 7.2.10-security-dxp-5-202003-1: + bundle_url: files.liferay.com/private/ee/portal/7.2.10.2/liferay-dxp-tomcat-7.2.10.2-sp2-20200511121558464.7z + fix_pack_url: files.liferay.com/private/ee/fix-packs/7.2.10/security-dxp/liferay-security-dxp-5-202003-1-7210.zip + test_installed_patch: dxp-5-7210,security-dxp-5-202003-1-7210 + 7.2.10-dxp-6: + bundle_url: files.liferay.com/private/ee/portal/7.2.10-dxp-6/liferay-dxp-tomcat-7.2.10-dxp-6-slim-20200611120504742.7z + test_installed_patch: dxp-6-7210,hotfix-1992-7210 + test_hotfix_url: files.liferay.com/private/ee/fix-packs/7.2.10/hotfix/liferay-hotfix-1992-7210.zip + 7.2.10-security-dxp-6-202004-4: + bundle_url: files.liferay.com/private/ee/portal/7.2.10-dxp-6/liferay-dxp-tomcat-7.2.10-dxp-6-20200611120504742.7z + fix_pack_url: files.liferay.com/private/ee/fix-packs/7.2.10/security-dxp/liferay-security-dxp-6-202004-4-7210.zip + test_installed_patch: dxp-6-7210,security-dxp-6-202004-4-7210 + 7.2.10-dxp-7: + bundle_url: files.liferay.com/private/ee/portal/7.2.10-dxp-7/liferay-dxp-tomcat-7.2.10-dxp-7-slim-20200727205713822.7z + test_installed_patch: dxp-7-7210,hotfix-2457-7210 + test_hotfix_url: files.liferay.com/private/ee/fix-packs/7.2.10/hotfix/liferay-hotfix-2457-7210.zip + 7.2.10-sp3: + additional_tags: 7.2.10-dxp-8 + bundle_url: files.liferay.com/private/ee/portal/7.2.10.3/liferay-dxp-tomcat-7.2.10.3-sp3-slim-20200910120006703.7z + test_installed_patch: dxp-8-7210,hotfix-2824-7210 + test_hotfix_url: files.liferay.com/private/ee/fix-packs/7.2.10/hotfix/liferay-hotfix-2824-7210.zip + 7.2.10-dxp-9: + bundle_url: files.liferay.com/private/ee/portal/7.2.10-dxp-9/liferay-dxp-tomcat-7.2.10-dxp-9-slim-20201208192626082.7z + test_installed_patch: dxp-9-7210,hotfix-3661-7210 + test_hotfix_url: files.liferay.com/private/ee/fix-packs/7.2.10/hotfix/liferay-hotfix-3661-7210.zip + 7.2.10-dxp-10: + bundle_url: files.liferay.com/private/ee/portal/7.2.10-dxp-10/liferay-dxp-tomcat-7.2.10-dxp-10-slim-20210112204850440.7z + test_installed_patch: dxp-10-7210,hotfix-3971-7210 + test_hotfix_url: files.liferay.com/private/ee/fix-packs/7.2.10/hotfix/liferay-hotfix-3971-7210.zip + 7.2.10-sp4: + additional_tags: 7.2.10-dxp-11 + bundle_url: files.liferay.com/private/ee/portal/7.2.10.4/liferay-dxp-tomcat-7.2.10.4-sp4-slim-20210302130725158.7z + test_installed_patch: dxp-11-7210,hotfix-4327-7210 + test_hotfix_url: files.liferay.com/private/ee/fix-packs/7.2.10/hotfix/liferay-hotfix-4327-7210.zip + 7.2.10-dxp-12: + bundle_url: files.liferay.com/private/ee/portal/7.2.10-dxp-12/liferay-dxp-tomcat-7.2.10-dxp-12-slim-20210402105245543.7z + test_installed_patch: dxp-12-7210,hotfix-4498-7210 + test_hotfix_url: files.liferay.com/private/ee/fix-packs/7.2.10/hotfix/liferay-hotfix-4498-7210.zip + 7.2.10-dxp-13: + bundle_url: files.liferay.com/private/ee/portal/7.2.10-dxp-13/liferay-dxp-tomcat-7.2.10-dxp-13-slim-20210511104400086.7z + test_installed_patch: dxp-13-7210,hotfix-4803-7210 + test_hotfix_url: files.liferay.com/private/ee/fix-packs/7.2.10/hotfix/liferay-hotfix-4803-7210.zip + 7.2.10-sp5: + additional_tags: 7.2.10-dxp-14 + bundle_url: files.liferay.com/private/ee/portal/7.2.10.5/liferay-dxp-tomcat-7.2.10.5-sp5-slim-20210716110942552.7z + test_installed_patch: dxp-14-7210,hotfix-5317-7210 + test_hotfix_url: files.liferay.com/private/ee/fix-packs/7.2.10/hotfix/liferay-hotfix-5317-7210.zip + 7.2.10-dxp-15: + bundle_url: files.liferay.com/private/ee/portal/7.2.10-dxp-15/liferay-dxp-tomcat-7.2.10-dxp-15-slim-20211011153401541.7z + test_installed_patch: dxp-15-7210,hotfix-5714-7210 + test_hotfix_url: files.liferay.com/private/ee/fix-packs/7.2.10/hotfix/liferay-hotfix-5714-7210.zip + 7.2.10-dxp-16: + bundle_url: files.liferay.com/private/ee/portal/7.2.10-dxp-16/liferay-dxp-tomcat-7.2.10-dxp-16-slim-20211111033058210.7z + test_installed_patch: dxp-16-7210,hotfix-5904-7210 + test_hotfix_url: files.liferay.com/private/ee/fix-packs/7.2.10/hotfix/liferay-hotfix-5904-7210.zip + 7.2.10-sp6: + additional_tags: 7.2.10-dxp-17 + bundle_url: files.liferay.com/private/ee/portal/7.2.10.6/liferay-dxp-tomcat-7.2.10.6-sp6-slim-20220317203828855.7z + test_installed_patch: dxp-17-7210,hotfix-6814-7210 + test_hotfix_url: files.liferay.com/private/ee/fix-packs/7.2.10/hotfix/liferay-hotfix-6814-7210.zip + 7.2.10-dxp-18: + bundle_url: files.liferay.com/private/ee/portal/7.2.10-dxp-18/liferay-dxp-tomcat-7.2.10-dxp-18-slim-20220506062749778.7z + test_installed_patch: dxp-18-7210,hotfix-7204-7210 + test_hotfix_url: files.liferay.com/private/ee/fix-packs/7.2.10/hotfix/liferay-hotfix-7204-7210.zip +7.3.7: + 7.3.7-ga8: + bundle_url: releases.liferay.com/portal/7.3.7-ga8/liferay-ce-portal-tomcat-7.3.7-ga8-20210610183559721.7z +7.3.10: + 7.3.10-ga1: + bundle_url: files.liferay.com/private/ee/portal/7.3.10/liferay-dxp-tomcat-7.3.10-ga1-20200930160533946.7z + test_installed_patch: hotfix-234-7310 + test_hotfix_url: files.liferay.com/private/ee/fix-packs/7.3.10/hotfix/liferay-hotfix-234-7310.zip + 7.3.10-dxp-1: + bundle_url: files.liferay.com/private/ee/portal/7.3.10.1/liferay-dxp-tomcat-7.3.10.1-sp1-slim-20210303153956119.7z + test_installed_patch: dxp-1-7310,hotfix-699-7310 + test_hotfix_url: files.liferay.com/private/ee/fix-packs/7.3.10/hotfix/liferay-hotfix-699-7310.zip + 7.3.10-dxp-2: + bundle_url: files.liferay.com/private/ee/portal/7.3.10-dxp-2/liferay-dxp-tomcat-7.3.10-dxp-2-slim-20210623003016661.7z + test_installed_patch: dxp-2-7310,hotfix-1736-7310 + test_hotfix_url: files.liferay.com/private/ee/fix-packs/7.3.10/hotfix/liferay-hotfix-1736-7310.zip + 7.3.10-sp3: + additional_tags: 7.3.10-dxp-3 + bundle_url: files.liferay.com/private/ee/portal/7.3.10.3/liferay-dxp-tomcat-7.3.10.3-sp3-20211220153201800.7z + test_installed_patch: hotfix-3567-7310 + test_hotfix_url: files.liferay.com/private/ee/fix-packs/7.3.10/hotfix/liferay-hotfix-3567-7310.zip + 7.3.10-u4: + bundle_url: files.liferay.com/private/ee/portal/7.3.10-u4/liferay-dxp-tomcat-7.3.10.u4-20220510200601795.7z + test_installed_patch: hotfix-5343-7310 + test_hotfix_url: files.liferay.com/private/ee/fix-packs/7.3.10/hotfix/liferay-hotfix-5343-7310.zip +7.4.3.26: + 7.4.3.26-ga26: + bundle_url: releases.liferay.com/portal/7.4.3.26-ga26/liferay-ce-portal-tomcat-7.4.3.26-ga26-20220520184751553.7z + latest: true +7.4.13: + 7.4.13-u26: + bundle_url: files.liferay.com/private/ee/portal/7.4.13-u26/liferay-dxp-tomcat-7.4.13.u26-20220520174220157.7z + latest: true + 7.4.13.nightly: + bundle_url: files.liferay.com/private/ee/portal/nightly/liferay-dxp-tomcat-7.4.13.nightly.7z +snapshot: + snapshot-master: + bundle_url: releases.liferay.com/portal/snapshot-master/latest/liferay-portal-tomcat-master.7z \ No newline at end of file diff --git a/demos/job-runner/docker-compose.yml b/demos/job-runner/docker-compose.yml new file mode 100644 index 0000000..6a73aaf --- /dev/null +++ b/demos/job-runner/docker-compose.yml @@ -0,0 +1,5 @@ +services: + job-runner: + image: liferay/job-runner:latest + volumes: + - ./files:/mnt/liferay \ No newline at end of file diff --git a/demos/job-runner/files/job-crontab b/demos/job-runner/files/job-crontab new file mode 100644 index 0000000..b2dd750 --- /dev/null +++ b/demos/job-runner/files/job-crontab @@ -0,0 +1,2 @@ +* * * * * /usr/local/bin/register_job.sh every_minute +*/2 * * * * /usr/local/bin/register_job.sh every_two_minutes diff --git a/demos/job-runner/files/jobs/every_minute.sh b/demos/job-runner/files/jobs/every_minute.sh new file mode 100755 index 0000000..6e0e5c4 --- /dev/null +++ b/demos/job-runner/files/jobs/every_minute.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +echo "Run ${0} and sleep for 5 seconds." + +sleep 5 \ No newline at end of file diff --git a/demos/job-runner/files/jobs/every_two_minutes.sh b/demos/job-runner/files/jobs/every_two_minutes.sh new file mode 100755 index 0000000..6e0e5c4 --- /dev/null +++ b/demos/job-runner/files/jobs/every_two_minutes.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +echo "Run ${0} and sleep for 5 seconds." + +sleep 5 \ No newline at end of file diff --git a/demos/liferay-stack/docker-compose.yml b/demos/liferay-stack/docker-compose.yml new file mode 100644 index 0000000..5431746 --- /dev/null +++ b/demos/liferay-stack/docker-compose.yml @@ -0,0 +1,53 @@ +services: + database: + command: mysqld --character-set-filesystem=utf8mb4 --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci --disable-ssl --max_allowed_packet=256M + environment: + - MARIADB_DATABASE=lportal + - MARIADB_PASSWORD=password + - MARIADB_ROOT_HOST=% + - MARIADB_ROOT_PASSWORD=T9Hh4mc9TK3p6TcX + - MARIADB_USER=user + healthcheck: + interval: 40s + retries: 3 + test: mysqladmin ping --host 127.0.0.1 --password=password --user user + timeout: 5s + image: mariadb:10.4 + ports: + - "3306:3306" + liferay: + depends_on: + database: + condition: service_healthy + search: + condition: service_healthy + environment: + - LIFERAY_CLUSTER_PERIOD_LINK_PERIOD_ENABLED=false + - LIFERAY_JDBC_PERIOD_DEFAULT_PERIOD_DRIVER_UPPERCASEC_LASS_UPPERCASEN_AME=org.mariadb.jdbc.Driver + - LIFERAY_JDBC_PERIOD_DEFAULT_PERIOD_PASSWORD=T9Hh4mc9TK3p6TcX + - LIFERAY_JDBC_PERIOD_DEFAULT_PERIOD_URL=jdbc:mariadb://database/lportal?characterEncoding=UTF-8&dontTrackOpenResources=true&holdResultsOpenOverStatementClose=true&serverTimezone=GMT&useFastDateParsing=false&useUnicode=true&useSSL=false + - LIFERAY_JDBC_PERIOD_DEFAULT_PERIOD_USERNAME=root + - LIFERAY_SETUP_PERIOD_DATABASE_PERIOD_JAR_PERIOD_URL_OPENBRACKET_COM_PERIOD_MYSQL_PERIOD_CJ_PERIOD_JDBC_PERIOD__UPPERCASED_RIVER_CLOSEBRACKET_=https://repo1.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/3.0.4/mariadb-java-client-3.0.4.jar + image: liferay/dxp:latest + ports: + - "8080:8080" + search: + entrypoint: /mnt/search_entrypoint.sh + environment: + - discovery.type=single-node + - xpack.ml.enabled=false + - xpack.monitoring.enabled=false + - xpack.security.enabled=false + - xpack.sql.enabled=false + - xpack.watcher.enabled=false + healthcheck: + interval: 40s + retries: 3 + test: curl localhost:9200/_cat/health | grep green + timeout: 5s + image: elasticsearch:7.17.3 + ports: + - "9200:9200" + - "9300:9300" + volumes: + - ./files:/mnt \ No newline at end of file diff --git a/demos/liferay-stack/files/search_entrypoint.sh b/demos/liferay-stack/files/search_entrypoint.sh new file mode 100755 index 0000000..21c86c6 --- /dev/null +++ b/demos/liferay-stack/files/search_entrypoint.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +/usr/share/elasticsearch/bin/elasticsearch-plugin install analysis-icu analysis-kuromoji analysis-smartcn analysis-stempel + +exec /usr/local/bin/docker-entrypoint.sh elasticsearch \ No newline at end of file diff --git a/download_trial_dxp_license.sh b/download_trial_dxp_license.sh index b823415..578e0c7 100755 --- a/download_trial_dxp_license.sh +++ b/download_trial_dxp_license.sh @@ -3,66 +3,47 @@ function main { local license_dir=${1} local license_start_date=${2} - local release_file_name=${3} - if [[ ${release_file_name} == *-commerce-enterprise-* ]] || [[ ${release_file_name} == *-dxp-* ]] + if [ -z "${LIFERAY_DOCKER_LICENSE_API_HEADER}" ] then - if [ -z "${LIFERAY_DOCKER_LICENSE_CMD}" ] - then - echo "Set the environment variable LIFERAY_DOCKER_LICENSE_CMD to generate a trial DXP license." + echo "Set the environment variable LIFERAY_DOCKER_LICENSE_API_HEADER to generate a trial DXP license." - exit 1 - else - mkdir -p ${license_dir}/deploy + exit 1 + elif [ -z "${LIFERAY_DOCKER_LICENSE_API_URL}" ] + then + echo "Set the environment variable LIFERAY_DOCKER_LICENSE_API_URL to generate a trial DXP license." - local license_file_name=trial-dxp-license-${license_start_date}.xml + exit 1 + else + mkdir -p "${license_dir}/deploy" - eval "curl --silent --header \"${LIFERAY_DOCKER_LICENSE_CMD}?licenseLifetime=$(expr 1000 \* 60 \* 60 \* 24 \* 90)&startDate=${license_start_date}&owner=docker%40liferay.com\" > ${license_dir}/deploy/${license_file_name}" + local license_file_name="trial-dxp-license-${license_start_date}.xml" - sed -i "s/\\\n//g" ${license_dir}/deploy/${license_file_name} - sed -i "s/\\\t//g" ${license_dir}/deploy/${license_file_name} - sed -i "s/\"\"/license>/" ${license_dir}/deploy/${license_file_name} - sed -i 's/\\"/\"/g' ${license_dir}/deploy/${license_file_name} - sed -i 's/\\\//\//g' ${license_dir}/deploy/${license_file_name} + curl --header "${LIFERAY_DOCKER_LICENSE_API_HEADER}" --silent "${LIFERAY_DOCKER_LICENSE_API_URL}?licenseLifetime=$((1000 *60 * 60 * 24 * 90))&startDate=${license_start_date}&owner=docker%40liferay.com" > "${license_dir}/deploy/${license_file_name}.json" - if [ ! -e ${license_dir}/deploy/${license_file_name} ] - then - echo "Trial DXP license does not exist at ${license_dir}/deploy/${license_file_name}." + sed "s/\\\n//g" "${license_dir}/deploy/${license_file_name}.json" | + sed "s/\\\t//g" | + sed "s/\"\"/license>/" | + sed 's/\\"/\"/g' | + sed 's/\\\//\//g' > "${license_dir}/deploy/${license_file_name}" - exit 1 - else - echo "Trial DXP license exists at ${license_dir}/deploy/${license_file_name}." - fi - fi - fi + rm -f "${license_dir}/deploy/${license_file_name}.json" - if [[ ${release_file_name} == *-commerce-enterprise-* ]] - then - if [ -z "${LIFERAY_DOCKER_COMMERCE_LICENSE_CMD}" ] + if [ ! -e "${license_dir}/deploy/${license_file_name}" ] then - echo "Set the environment variable LIFERAY_DOCKER_COMMERCE_LICENSE_CMD to generate a trial Commerce license." + echo "Trial DXP license does not exist at ${license_dir}/deploy/${license_file_name}." exit 1 - else - mkdir -p ${license_dir}/data/license - - local commerce_license_file_name=trial-commerce-enterprise-license-${license_start_date}.li - - eval "curl --silent --header \"${LIFERAY_DOCKER_COMMERCE_LICENSE_CMD}?licenseLifetime=$(expr 1000 \* 60 \* 60 \* 24 \* 90)&startDate=${license_start_date}&owner=docker%40liferay.com\" > ${license_dir}/data/license/${commerce_license_file_name}" - - sed -i 's/["]//g' ${license_dir}/data/license/${commerce_license_file_name} - - if [ ! -e ${license_dir}/data/license/${commerce_license_file_name} ] - then - echo "Trial Commerce license does not exist at ${license_dir}/data/license/${commerce_license_file_name}." + elif ! grep -q "docker@liferay.com" "${license_dir}/deploy/${license_file_name}" + then + echo "Invalid trial DXP license exists at ${license_dir}/deploy/${license_file_name}." - exit 1 - else - echo "Trial Commerce license exists at ${license_dir}/data/license/${commerce_license_file_name}." - fi + exit 1 + else + echo "Valid Trial DXP license exists at ${license_dir}/deploy/${license_file_name}." fi fi } -main ${@} \ No newline at end of file +main "${@}" \ No newline at end of file diff --git a/lefthook.yml b/lefthook.yml new file mode 100644 index 0000000..b7f2870 --- /dev/null +++ b/lefthook.yml @@ -0,0 +1,8 @@ +pre-commit: + commands: + "shellchecker": + glob: "*.sh" + run: docker run --rm -v "$PWD:/mnt" koalaman/shellcheck:v0.8.0 {staged_files} + "beautysh": + glob: "*.sh" + run: docker run --rm -v "$PWD:/mnt" kreutzakos/beautysh:0.2 {staged_files} \ No newline at end of file diff --git a/patching_tool_version.sh b/patching_tool_version.sh new file mode 100755 index 0000000..ee382fe --- /dev/null +++ b/patching_tool_version.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +source ./_common.sh + +function check_usage { + if [ ! -n "${1}" ] + then + echo "Usage: ${0} " + echo "" + echo "This script requires the first parameter to be set to the major and minor version of the Patching Tool (e.g. 2.0)." + + exit 1 + fi +} + +function get_full_version { + if [ "${1}" == "1.0" ] + then + echo "1.0.24" + elif [ "${1}" == "2.0" ] + then + echo "2.0.16" + elif [ "${1}" == "3.0" ] + then + echo "3.0.35" + else + echo "Unable to get full version for ${1}." + + exit 2 + fi +} + +function main { + check_usage "${@}" + + get_full_version "${@}" +} + +main "${@}" \ No newline at end of file diff --git a/release_notes.sh b/release_notes.sh index 40ec95d..9672759 100755 --- a/release_notes.sh +++ b/release_notes.sh @@ -5,9 +5,9 @@ source ./_common.sh function check_usage { if [ ! -n "${1}" ] || [[ ("${1}" != "commit") && - ("${1}" != "display") && - ("${1}" != "fail-on-change") && - ("${1}" != "get-version") ]] + ("${1}" != "display") && + ("${1}" != "fail-on-change") && + ("${1}" != "get-version") ]] then echo "Usage: ${0} " echo "" @@ -25,52 +25,37 @@ function check_usage { } function generate_release_notes { - if [ ! -n "${CHANGE_LOG}" ] + if [ ! -n "${RELEASE_NOTES_CHANGE_LOG}" ] then return fi - if ( git log --pretty=%s ${RELEASE_NOTES_LATEST_SHA}..${CURRENT_SHA} | grep "#majorchange" > /dev/null ) - then - RELEASE_NOTES_VERSION_MAJOR=$(($RELEASE_NOTES_VERSION_MAJOR+1)) - RELEASE_NOTES_VERSION_MINOR=0 - RELEASE_NOTES_VERSION_MICRO=0 - elif ( git log --pretty=%s ${RELEASE_NOTES_LATEST_SHA}..${CURRENT_SHA} | grep "#minorchange" > /dev/null ) - then - RELEASE_NOTES_VERSION_MINOR=$(($RELEASE_NOTES_VERSION_MINOR+1)) - RELEASE_NOTES_VERSION_MICRO=0 - else - RELEASE_NOTES_VERSION_MICRO=$(($RELEASE_NOTES_VERSION_MICRO+1)) - fi - - local new_version=${RELEASE_NOTES_VERSION_MAJOR}.${RELEASE_NOTES_VERSION_MINOR}.${RELEASE_NOTES_VERSION_MICRO} - - echo "Bump version from ${RELEASE_NOTES_LATEST_VERSION} to ${new_version}." + echo "Bump version from ${RELEASE_NOTES_LATEST_VERSION} to ${RELEASE_NOTES_NEW_VERSION}." if [ "${1}" == "commit" ] then ( echo "" echo "#" - echo "# Liferay Docker Image Version ${new_version}" + echo "# Liferay Docker Image Version ${RELEASE_NOTES_NEW_VERSION}" echo "#" echo "" - echo "docker.image.change.log-${new_version}=${CHANGE_LOG}" - echo "docker.image.git.id-${new_version}=${CURRENT_SHA}" + echo "docker.image.change.log-${RELEASE_NOTES_NEW_VERSION}=${RELEASE_NOTES_CHANGE_LOG}" + echo "docker.image.git.id-${RELEASE_NOTES_NEW_VERSION}=${RELEASE_NOTES_CURRENT_SHA}" ) >> .releng/docker-image.changelog git add .releng/docker-image.changelog - git commit -m "${new_version} change log" + git commit -m "${RELEASE_NOTES_NEW_VERSION} change log" fi } function get_change_log { - CURRENT_SHA=$(git log -1 --pretty=%H) + RELEASE_NOTES_CURRENT_SHA=$(git log -1 --pretty=%H) - CHANGE_LOG=$(git log --pretty=%s --grep "^LPS-" ${RELEASE_NOTES_LATEST_SHA}..${CURRENT_SHA} | sed -e "s/\ .*/ /" | uniq | tr -d "\n" | tr -d "\r" | sed -e "s/ $//") + RELEASE_NOTES_CHANGE_LOG=$(git log --grep "^DOCKER-" --pretty=%s "${RELEASE_NOTES_LATEST_SHA}..${RELEASE_NOTES_CURRENT_SHA}" | sed -e "s/\ .*/ /" | uniq | tr -d "\n" | tr -d "\r" | sed -e "s/ $//") - if [ "${1}" == "fail-on-change" ] && [ -n "${CHANGE_LOG}" ] + if [ "${1}" == "fail-on-change" ] && [ -n "${RELEASE_NOTES_CHANGE_LOG}" ] then echo "There was a change in the repository which requires regenerating the release notes." echo "" @@ -81,7 +66,7 @@ function get_change_log { } function get_latest_version { - local git_line=$(cat .releng/docker-image.changelog | grep docker.image.git.id | tail -n1) + local git_line=$(grep 'docker.image.git.id' .releng/docker-image.changelog | tail -n1) RELEASE_NOTES_LATEST_SHA=${git_line#*=} @@ -94,23 +79,56 @@ function get_latest_version { RELEASE_NOTES_VERSION_MINOR=${RELEASE_NOTES_VERSION_MINOR%.*} RELEASE_NOTES_VERSION_MICRO=${RELEASE_NOTES_LATEST_VERSION##*.} +} - if [ "${1}" == "get-version" ] +function get_new_version { + if [ ! -n "${RELEASE_NOTES_CHANGE_LOG}" ] then - echo ${RELEASE_NOTES_LATEST_VERSION} + return + fi - exit + if (git log --pretty=%s "${RELEASE_NOTES_LATEST_SHA}..${RELEASE_NOTES_CURRENT_SHA}" | grep "#majorchange" > /dev/null) + then + RELEASE_NOTES_VERSION_MAJOR=$((RELEASE_NOTES_VERSION_MAJOR+1)) + RELEASE_NOTES_VERSION_MINOR=0 + RELEASE_NOTES_VERSION_MICRO=0 + elif (git log --pretty=%s "${RELEASE_NOTES_LATEST_SHA}..${RELEASE_NOTES_CURRENT_SHA}" | grep "#minorchange" > /dev/null) + then + RELEASE_NOTES_VERSION_MINOR=$((RELEASE_NOTES_VERSION_MINOR+1)) + RELEASE_NOTES_VERSION_MICRO=0 + else + RELEASE_NOTES_VERSION_MICRO=$((RELEASE_NOTES_VERSION_MICRO+1)) fi + + RELEASE_NOTES_NEW_VERSION="${RELEASE_NOTES_VERSION_MAJOR}.${RELEASE_NOTES_VERSION_MINOR}.${RELEASE_NOTES_VERSION_MICRO}" } function main { - check_usage ${@} + check_usage "${@}" + + get_latest_version "${@}" + + get_change_log "${@}" - get_latest_version ${@} + get_new_version "${@}" - get_change_log ${@} + print_version "${@}" - generate_release_notes ${@} + generate_release_notes "${@}" +} + +function print_version { + if [ "${1}" == "get-version" ] + then + if [ -n "${RELEASE_NOTES_CHANGE_LOG}" ] + then + echo "${RELEASE_NOTES_NEW_VERSION}-snapshot" + else + echo "${RELEASE_NOTES_LATEST_VERSION}" + fi + + exit + fi } -main ${@} \ No newline at end of file +main "${@}" \ No newline at end of file diff --git a/setup_lefthook.sh b/setup_lefthook.sh new file mode 100755 index 0000000..8364af0 --- /dev/null +++ b/setup_lefthook.sh @@ -0,0 +1,61 @@ +#!/bin/bash + +function check_permission { + if [ "$(id -u)" -ne 0 ] + then + echo "This script must be run by root." + + exit 1 + fi +} + +function configure_lefthook { + cd "$(dirname "$0")" || exit + + npx lefthook add pre-commit + + if [ "${exit_code}" -gt 0 ] + then + echo "Unable to configure Lefthook." + + exit 1 + fi +} + +function install_lefthook { + npm install @arkweid/lefthook@0.7.7 --save-dev + + local exit_code=$? + + if [ "${exit_code}" -gt 0 ] + then + echo "Unable to install Lefthook." + + exit 1 + fi +} + +function install_npm { + apt install npm + + local exit_code=$? + + if [ "${exit_code}" -gt 0 ] + then + echo "Unable to install NPM." + + exit 1 + fi +} + +function main { + check_permission + + install_npm + + install_lefthook + + configure_lefthook +} + +main "${@}" \ No newline at end of file diff --git a/template/Dockerfile b/template/Dockerfile deleted file mode 100644 index 72ebbe8..0000000 --- a/template/Dockerfile +++ /dev/null @@ -1,57 +0,0 @@ -FROM azul/zulu-openjdk-alpine:8u232 - -ARG APPLICATION_SERVER -ARG LABEL_BUILD_DATE -ARG LABEL_NAME -ARG LABEL_VCS_REF -ARG LABEL_VCS_URL -ARG LABEL_VERSION - -RUN apk --no-cache add bash curl nss tomcat-native tree ttf-dejavu zulu11-jdk=11.0.5-r3 - -COPY scripts/* /usr/local/bin/ - -RUN adduser -D -h /home/liferay liferay && addgroup liferay liferay - -COPY --chown=liferay:liferay home/.bashrc /home/liferay/ -COPY --chown=liferay:liferay liferay /opt/liferay - -RUN ln -fs /opt/liferay/* /home/liferay - -ENTRYPOINT /usr/local/bin/liferay_entrypoint.sh - -ENV APPLICATION_SERVER="${APPLICATION_SERVER}" -ENV JAVA_VERSION=zulu8 -ENV JPDA_ADDRESS=8000 - -ENV LIFERAY_DISABLE_TRIAL_LICENSE=false -ENV LIFERAY_HOME=/opt/liferay -ENV LIFERAY_JPDA_ENABLED=false -ENV LIFERAY_JVM_OPTS= -ENV LIFERAY_PRODUCT_NAME="${LABEL_NAME}" - -ENV LIFERAY_MODULE_PERIOD_FRAMEWORK_PERIOD_PROPERTIES_PERIOD_OSGI_PERIOD_CONSOLE=0.0.0.0:11311 -ENV LIFERAY_SETUP_PERIOD_WIZARD_PERIOD_ADD_PERIOD_SAMPLE_PERIOD_DATA=false -ENV LIFERAY_SETUP_PERIOD_WIZARD_PERIOD_ENABLED=false -ENV LIFERAY_TERMS_PERIOD_OF_PERIOD_USE_PERIOD_REQUIRED=false -ENV LIFERAY_USERS_PERIOD_REMINDER_PERIOD_QUERIES_PERIOD_ENABLED=false - -EXPOSE 8000 8009 8080 11311 - -HEALTHCHECK \ - --interval=1m \ - --start-period=1m \ - --timeout=1m \ - CMD curl -fsS "http://localhost:8080/c/portal/layout" || exit 1 - -LABEL org.label-schema.build-date="${LABEL_BUILD_DATE}" -LABEL org.label-schema.name="${LABEL_NAME}" -LABEL org.label-schema.schema-version="1.0" -LABEL org.label-schema.vcs-ref="${LABEL_VCS_REF}" -LABEL org.label-schema.vcs-url="${LABEL_VCS_URL}" -LABEL org.label-schema.vendor="Liferay, Inc." -LABEL org.label-schema.version="${LABEL_VERSION}" - -USER liferay:liferay - -WORKDIR /opt/liferay \ No newline at end of file diff --git a/template/scripts/_liferay_common.sh b/template/scripts/_liferay_common.sh deleted file mode 100644 index b1ddbd6..0000000 --- a/template/scripts/_liferay_common.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -function execute_scripts { - if [ -e ${1} ] && [[ $(ls -A ${1}) ]] - then - echo "[LIFERAY] Executing scripts in ${1}:" - - for SCRIPT_NAME in $(ls -1 ${1} | sort) - do - echo "" - echo "[LIFERAY] Executing ${SCRIPT_NAME}." - - source ${1}/${SCRIPT_NAME} - done - - echo "" - fi -} \ No newline at end of file diff --git a/template/scripts/patch_liferay.sh b/template/scripts/patch_liferay.sh deleted file mode 100755 index f254f18..0000000 --- a/template/scripts/patch_liferay.sh +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/bash - -function apply_patch { - local patch_file_name=${1} - - if [ -e "/opt/liferay/patching-tool/patch-applied" ] - then - local installed_patch=$(cat /opt/liferay/patching-tool/patch-applied) - - if [ ! ${patch_file_name} == ${installed_patch} ] - then - echo "" - echo "[LIFERAY] ${patch_file_name} cannot be applied on this container because ${installed_patch} is already installed. Remove ${patch_file_name} from the patching directory to disable this warning message." - fi - elif ( /opt/liferay/patching-tool/patching-tool.sh apply ${LIFERAY_PATCHING_DIR}/${patch_file_name} ) - then - echo ${patch_file_name} > /opt/liferay/patching-tool/patch-applied - - install_patch_step_2 - else - install_patch_step_1 ${patch_file_name} - fi -} - -function install_patch_step_1 { - local patch_file_name=${1} - - cp ${LIFERAY_PATCHING_DIR}/${patch_file_name} /opt/liferay/patching-tool/patches - - /opt/liferay/patching-tool/patching-tool.sh setup - - if ( /opt/liferay/patching-tool/patching-tool.sh install ) - then - install_patch_step_2 - fi -} - -function install_patch_step_2 { - rm -fr /opt/liferay/osgi/state/* - - echo "" - echo "[LIFERAY] Patch applied successfully." -} - -function main { - if [[ $(ls -A ${LIFERAY_PATCHING_DIR}/patching-tool-*.zip 2>/dev/null) ]] - then - echo "" - echo "[LIFERAY] Updating Patching Tool." - - mv /opt/liferay/patching-tool/patches /opt/liferay/patching-tool-upgrade-patches - - rm -fr /opt/liferay/patching-tool - - unzip -d /opt/liferay -q ${LIFERAY_PATCHING_DIR}/patching-tool-* - - /opt/liferay/patching-tool/patching-tool.sh auto-discovery - - rm -fr /opt/liferay/patching-tool/patches - - mv /opt/liferay/patching-tool-upgrade-patches /opt/liferay/patching-tool/patches - - echo "" - echo "[LIFERAY] Patching Tool updated successfully." - fi - - if [[ $(ls -A ${LIFERAY_PATCHING_DIR}/liferay-*.zip 2>/dev/null) ]] - then - if [ `ls ${LIFERAY_PATCHING_DIR}/liferay-*.zip | wc -l` == 1 ] - then - local patch_file_name=$(basename ${LIFERAY_PATCHING_DIR}/liferay-*.zip) - - apply_patch ${patch_file_name} - else - local patch_file_name=$(basename $(ls -A ${LIFERAY_PATCHING_DIR}/liferay-*.zip 2>/dev/null | sort | tail -n 1)) - - echo "" - echo "[LIFERAY] There were multiple hotfixes in the patching folder. As only one can be installed, applying the latest one: ${patch_file_name}." - - apply_patch ${patch_file_name} - fi - fi -} - -main \ No newline at end of file diff --git a/template/scripts/set_java_version.sh b/template/scripts/set_java_version.sh deleted file mode 100755 index ae491f9..0000000 --- a/template/scripts/set_java_version.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -function main { - if [ -n "${JAVA_VERSION}" ] - then - if [ -e "/usr/lib/jvm/${JAVA_VERSION}" ] - then - JAVA_HOME=/usr/lib/jvm/${JAVA_VERSION} - PATH=/usr/lib/jvm/${JAVA_VERSION}/bin/:${PATH} - - echo "[LIFERAY] Using ${JAVA_VERSION} JDK. You can use another JDK by setting the \"JAVA_VERSION\" environment varible." - echo "" - else - echo "[LIFERAY] \"${JAVA_VERSION}\" JDK is not available in this Docker image." - echo "" - - exit 1 - fi - fi -} - -main \ No newline at end of file diff --git a/template/scripts/start_liferay.sh b/template/scripts/start_liferay.sh deleted file mode 100755 index 2a0b59c..0000000 --- a/template/scripts/start_liferay.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -function main() { - echo "" - echo "[LIFERAY] Starting ${LIFERAY_PRODUCT_NAME}. To stop the container with CTRL-C, run this container with the option \"-it\"." - echo "" - - if [ "${APPLICATION_SERVER}" == "jboss-eap" ]; then - if [ "${LIFERAY_JPDA_ENABLED}" == "true" ]; then - ${LIFERAY_HOME}/jboss-eap/bin/standalone.sh -b 0.0.0.0 --debug ${JPDA_ADDRESS} - else - ${LIFERAY_HOME}/jboss-eap/bin/standalone.sh -b 0.0.0.0 - fi - else - if [ "${LIFERAY_JPDA_ENABLED}" == "true" ]; then - ${LIFERAY_HOME}/tomcat/bin/catalina.sh jpda run - else - ${LIFERAY_HOME}/tomcat/bin/catalina.sh run - fi - fi -} - -main diff --git a/templates/base/Dockerfile b/templates/base/Dockerfile new file mode 100644 index 0000000..372538a --- /dev/null +++ b/templates/base/Dockerfile @@ -0,0 +1,25 @@ +FROM --platform=${TARGETPLATFORM} ubuntu:jammy + +ARG LABEL_BUILD_DATE +ARG LABEL_NAME +ARG LABEL_VCS_REF +ARG LABEL_VCS_URL +ARG LABEL_VERSION +ARG TARGETPLATFORM + +RUN apt-get update && \ + apt-get install -y bash curl less libnss3 telnet tini tree unzip && \ + apt-get upgrade -y && \ + apt-get clean + +RUN adduser --disabled-password --home /home/liferay liferay --uid 1000 && \ + addgroup liferay liferay && \ + usermod -g 1000 liferay + +LABEL org.label-schema.build-date="${LABEL_BUILD_DATE}" +LABEL org.label-schema.name="${LABEL_NAME}" +LABEL org.label-schema.schema-version="1.0" +LABEL org.label-schema.vcs-ref="${LABEL_VCS_REF}" +LABEL org.label-schema.vcs-url="${LABEL_VCS_URL}" +LABEL org.label-schema.vendor="Liferay, Inc." +LABEL org.label-schema.version="${LABEL_VERSION}" \ No newline at end of file diff --git a/templates/bundle/Dockerfile b/templates/bundle/Dockerfile new file mode 100644 index 0000000..85dd9fe --- /dev/null +++ b/templates/bundle/Dockerfile @@ -0,0 +1,66 @@ +FROM --platform=${TARGETPLATFORM} liferay/jdk11:latest + +ARG APPLICATION_SERVER +ARG LABEL_BUILD_DATE +ARG LABEL_LIFERAY_VCS_REF +ARG LABEL_NAME +ARG LABEL_VCS_REF +ARG LABEL_VCS_URL +ARG LABEL_VERSION +ARG TARGETPLATFORM + +RUN apt-get update && \ + apt-get install -y ffmpeg fonts-dejavu ghostscript imagemagick gifsicle libtcnative-1 && \ + apt-get upgrade -y && \ + apt-get clean + +COPY scripts/* /usr/local/bin/ + +COPY --chown=liferay:liferay liferay /opt/liferay/ + +RUN ln -fs /opt/liferay/* /home/liferay + +ENTRYPOINT ["tini", "--", "/usr/local/bin/liferay_entrypoint.sh"] + +ENV APPLICATION_SERVER="${APPLICATION_SERVER}" +ENV JPDA_ADDRESS=8000 + +ENV LIFERAY_DISABLE_TRIAL_LICENSE=false +ENV LIFERAY_HOME=/opt/liferay +ENV LIFERAY_JPDA_ENABLED=false +ENV LIFERAY_JVM_OPTS= +ENV LIFERAY_PID="${LIFERAY_HOME}/liferay.pid" +ENV LIFERAY_PRODUCT_NAME="${LABEL_NAME}" +ENV LIFERAY_THREAD_DUMP_DIRECTORY="${LIFERAY_HOME}/data/logs" +ENV LIFERAY_THREAD_DUMP_PROBE_ENABLED="false" + +ENV LIFERAY_CONFIGURATION_PERIOD_OVERRIDE_PERIOD_COM_PERIOD_LIFERAY_PERIOD_DOCUMENT_PERIOD_LIBRARY_PERIOD_PREVIEW_PERIOD_AUDIO_PERIOD_INTERNAL_PERIOD_CONFIGURATION_PERIOD__UPPERCASED__UPPERCASEL__UPPERCASEA_UDIO_UPPERCASEF__UPPERCASEF__UPPERCASEM__UPPERCASEP__UPPERCASEE__UPPERCASEG__UPPERCASEA_UDIO_UPPERCASEC_ONVERTER_UPPERCASEC_ONFIGURATION_UNDERLINE_ENABLED='"true"' +ENV LIFERAY_CONFIGURATION_PERIOD_OVERRIDE_PERIOD_COM_PERIOD_LIFERAY_PERIOD_DOCUMENT_PERIOD_LIBRARY_PERIOD_VIDEO_PERIOD_INTERNAL_PERIOD_CONFIGURATION_PERIOD__UPPERCASED__UPPERCASEL__UPPERCASEV_IDEO_UPPERCASEF__UPPERCASEF__UPPERCASEM__UPPERCASEP__UPPERCASEE__UPPERCASEG__UPPERCASEV_IDEO_UPPERCASEC_ONVERTER_UPPERCASEC_ONFIGURATION_UNDERLINE_ENABLED='"true"' +ENV LIFERAY_IMAGEMAGICK_PERIOD_ENABLED=true +ENV LIFERAY_IMAGEMAGICK_PERIOD_GLOBAL_PERIOD_SEARCH_PERIOD_PATH_OPENBRACKET_UNIX_CLOSEBRACKET_="/usr/bin:/usr/share/fonts/" +ENV LIFERAY_MODULE_PERIOD_FRAMEWORK_PERIOD_PROPERTIES_PERIOD_OSGI_PERIOD_CONSOLE=0.0.0.0:11311 +ENV LIFERAY_SETUP_PERIOD_WIZARD_PERIOD_ADD_PERIOD_SAMPLE_PERIOD_DATA=false +ENV LIFERAY_SETUP_PERIOD_WIZARD_PERIOD_ENABLED=false +ENV LIFERAY_TERMS_PERIOD_OF_PERIOD_USE_PERIOD_REQUIRED=false +ENV LIFERAY_USERS_PERIOD_REMINDER_PERIOD_QUERIES_PERIOD_ENABLED=false + +EXPOSE 8000 8009 8080 11311 + +HEALTHCHECK \ + --interval=1m \ + --start-period=1m \ + --timeout=1m \ + CMD curl -fsS "http://localhost:8080/c/portal/layout" || exit 1 + +LABEL com.liferay.vcs-ref="${LABEL_LIFERAY_VCS_REF}" +LABEL org.label-schema.build-date="${LABEL_BUILD_DATE}" +LABEL org.label-schema.name="${LABEL_NAME}" +LABEL org.label-schema.schema-version="1.0" +LABEL org.label-schema.vcs-ref="${LABEL_VCS_REF}" +LABEL org.label-schema.vcs-url="${LABEL_VCS_URL}" +LABEL org.label-schema.vendor="Liferay, Inc." +LABEL org.label-schema.version="${LABEL_VERSION}" + +USER liferay:liferay + +WORKDIR /opt/liferay \ No newline at end of file diff --git a/template/home/.bashrc b/templates/bundle/home/.bashrc similarity index 100% rename from template/home/.bashrc rename to templates/bundle/home/.bashrc diff --git a/template/jboss-eap/7.2.0/bin/standalone.conf b/templates/bundle/jboss-eap/7.2.0/bin/standalone.conf similarity index 100% rename from template/jboss-eap/7.2.0/bin/standalone.conf rename to templates/bundle/jboss-eap/7.2.0/bin/standalone.conf diff --git a/template/jboss-eap/7.2.0/modules/com/liferay/portal/main/module.xml b/templates/bundle/jboss-eap/7.2.0/modules/com/liferay/portal/main/module.xml similarity index 100% rename from template/jboss-eap/7.2.0/modules/com/liferay/portal/main/module.xml rename to templates/bundle/jboss-eap/7.2.0/modules/com/liferay/portal/main/module.xml diff --git a/template/jboss-eap/7.2.0/modules/com/liferay/portal/main/ojdbc8.jar b/templates/bundle/jboss-eap/7.2.0/modules/com/liferay/portal/main/ojdbc8.jar similarity index 100% rename from template/jboss-eap/7.2.0/modules/com/liferay/portal/main/ojdbc8.jar rename to templates/bundle/jboss-eap/7.2.0/modules/com/liferay/portal/main/ojdbc8.jar diff --git a/template/jboss-eap/7.2.0/standalone/configuration/standalone.xml b/templates/bundle/jboss-eap/7.2.0/standalone/configuration/standalone.xml similarity index 100% rename from template/jboss-eap/7.2.0/standalone/configuration/standalone.xml rename to templates/bundle/jboss-eap/7.2.0/standalone/configuration/standalone.xml diff --git a/template/jboss-eap/7.3.0/bin/standalone.conf b/templates/bundle/jboss-eap/7.3.0/bin/standalone.conf similarity index 100% rename from template/jboss-eap/7.3.0/bin/standalone.conf rename to templates/bundle/jboss-eap/7.3.0/bin/standalone.conf diff --git a/template/jboss-eap/7.3.0/modules/com/liferay/portal/main/module.xml b/templates/bundle/jboss-eap/7.3.0/modules/com/liferay/portal/main/module.xml similarity index 100% rename from template/jboss-eap/7.3.0/modules/com/liferay/portal/main/module.xml rename to templates/bundle/jboss-eap/7.3.0/modules/com/liferay/portal/main/module.xml diff --git a/template/jboss-eap/7.3.0/modules/com/liferay/portal/main/ojdbc8.jar b/templates/bundle/jboss-eap/7.3.0/modules/com/liferay/portal/main/ojdbc8.jar similarity index 100% rename from template/jboss-eap/7.3.0/modules/com/liferay/portal/main/ojdbc8.jar rename to templates/bundle/jboss-eap/7.3.0/modules/com/liferay/portal/main/ojdbc8.jar diff --git a/template/jboss-eap/7.3.0/standalone/configuration/standalone.xml b/templates/bundle/jboss-eap/7.3.0/standalone/configuration/standalone.xml similarity index 100% rename from template/jboss-eap/7.3.0/standalone/configuration/standalone.xml rename to templates/bundle/jboss-eap/7.3.0/standalone/configuration/standalone.xml diff --git a/template/jboss-eap/7.4.0/bin/standalone.conf b/templates/bundle/jboss-eap/7.4.0/bin/standalone.conf similarity index 100% rename from template/jboss-eap/7.4.0/bin/standalone.conf rename to templates/bundle/jboss-eap/7.4.0/bin/standalone.conf diff --git a/template/jboss-eap/7.4.0/standalone/configuration/standalone.xml b/templates/bundle/jboss-eap/7.4.0/standalone/configuration/standalone.xml similarity index 100% rename from template/jboss-eap/7.4.0/standalone/configuration/standalone.xml rename to templates/bundle/jboss-eap/7.4.0/standalone/configuration/standalone.xml diff --git a/templates/bundle/scripts/_liferay_common.sh b/templates/bundle/scripts/_liferay_common.sh new file mode 100644 index 0000000..3071e02 --- /dev/null +++ b/templates/bundle/scripts/_liferay_common.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +function execute_scripts { + if [ -e "${1}" ] && [[ $(find "${1}" -maxdepth 1 -name "*.sh" -printf "%f\n") ]] + then + echo "[LIFERAY] Executing scripts in ${1}:" + + for SCRIPT_NAME in $(find "${1}" -maxdepth 1 -name "*.sh" -printf "%f\n" | sort) + do + echo "" + echo "[LIFERAY] Executing ${SCRIPT_NAME}." + + source "${1}/${SCRIPT_NAME}" + done + + echo "" + fi +} \ No newline at end of file diff --git a/template/scripts/configure_liferay.sh b/templates/bundle/scripts/configure_liferay.sh similarity index 61% rename from template/scripts/configure_liferay.sh rename to templates/bundle/scripts/configure_liferay.sh index 625bc53..57b7d05 100755 --- a/template/scripts/configure_liferay.sh +++ b/templates/bundle/scripts/configure_liferay.sh @@ -9,25 +9,25 @@ function main { rm -f /opt/liferay/deploy/trial-dxp-license-*.xml fi - if [ ! -d ${LIFERAY_MOUNT_DIR} ] + if [ ! -d "${LIFERAY_MOUNT_DIR}" ] then echo "[LIFERAY] Run this container with the option \"-v \$(pwd)/xyz123:/mnt/liferay\" to bridge \$(pwd)/xyz123 in the host operating system to ${LIFERAY_MOUNT_DIR} on the container." echo "" fi - if [ -d ${LIFERAY_MOUNT_DIR}/files ] + if [ -d "${LIFERAY_MOUNT_DIR}"/files ] then - if [[ $(ls -A ${LIFERAY_MOUNT_DIR}/files) ]] + if [[ $(ls -A "${LIFERAY_MOUNT_DIR}"/files) ]] then echo "[LIFERAY] Copying files from ${LIFERAY_MOUNT_DIR}/files:" echo "" - tree --noreport ${LIFERAY_MOUNT_DIR}/files + tree --noreport "${LIFERAY_MOUNT_DIR}"/files echo "" echo "[LIFERAY] ... into ${LIFERAY_HOME}." - cp -r ${LIFERAY_MOUNT_DIR}/files/* ${LIFERAY_HOME} + cp -r "${LIFERAY_MOUNT_DIR}"/files/* "${LIFERAY_HOME}" echo "" fi @@ -36,36 +36,54 @@ function main { echo "" fi - if [ -d ${LIFERAY_MOUNT_DIR}/scripts ] + if [ -d "${LIFERAY_MOUNT_DIR}"/scripts ] then - execute_scripts ${LIFERAY_MOUNT_DIR}/scripts + execute_scripts "${LIFERAY_MOUNT_DIR}"/scripts else echo "[LIFERAY] The directory /mnt/liferay/scripts does not exist. Create the directory \$(pwd)/xyz123/scripts on the host operating system to create the directory ${LIFERAY_MOUNT_DIR}/scripts on the container. Files in ${LIFERAY_MOUNT_DIR}/scripts will be executed, in alphabetical order, before ${LIFERAY_PRODUCT_NAME} starts." echo "" fi - if [ -d ${LIFERAY_MOUNT_DIR}/deploy ] + if [ -d "${LIFERAY_MOUNT_DIR}"/deploy ] then if [[ $(ls -A /opt/liferay/deploy) ]] then - cp /opt/liferay/deploy/* ${LIFERAY_MOUNT_DIR}/deploy + cp /opt/liferay/deploy/* "${LIFERAY_MOUNT_DIR}"/deploy fi rm -fr /opt/liferay/deploy - ln -s ${LIFERAY_MOUNT_DIR}/deploy /opt/liferay/deploy + ln -s "${LIFERAY_MOUNT_DIR}"/deploy /opt/liferay/deploy echo "[LIFERAY] The directory /mnt/liferay/deploy is ready. Copy files to \$(pwd)/xyz123/deploy on the host operating system to deploy modules to ${LIFERAY_PRODUCT_NAME} at runtime." else echo "[LIFERAY] The directory /mnt/liferay/deploy does not exist. Create the directory \$(pwd)/xyz123/deploy on the host operating system to create the directory ${LIFERAY_MOUNT_DIR}/deploy on the container. Copy files to \$(pwd)/xyz123/deploy to deploy modules to ${LIFERAY_PRODUCT_NAME} at runtime." fi - export LIFERAY_PATCHING_DIR=${LIFERAY_MOUNT_DIR}/patching + export LIFERAY_PATCHING_DIR="${LIFERAY_MOUNT_DIR}"/patching - if [ -e ${LIFERAY_PATCHING_DIR} ] && [ -e /opt/liferay/patching-tool ] + if [ -e "${LIFERAY_PATCHING_DIR}" ] && [ -e /opt/liferay/patching-tool ] then patch_liferay.sh fi + + if [ -n "${LIFERAY_JDBC_PERIOD_DEFAULT_PERIOD_PASSWORD_FILE}" ] + then + LIFERAY_JDBC_PERIOD_DEFAULT_PERIOD_PASSWORD=$(cat "${LIFERAY_JDBC_PERIOD_DEFAULT_PERIOD_PASSWORD_FILE}") + + export LIFERAY_JDBC_PERIOD_DEFAULT_PERIOD_PASSWORD + + unset LIFERAY_JDBC_PERIOD_DEFAULT_PERIOD_PASSWORD_FILE + fi + + if [ -n "${LIFERAY_JDBC_PERIOD_DEFAULT_PERIOD_USERNAME_FILE}" ] + then + LIFERAY_JDBC_PERIOD_DEFAULT_PERIOD_USERNAME=$(cat "${LIFERAY_JDBC_PERIOD_DEFAULT_PERIOD_USERNAME_FILE}") + + export LIFERAY_JDBC_PERIOD_DEFAULT_PERIOD_USERNAME + + unset LIFERAY_JDBC_PERIOD_DEFAULT_PERIOD_USERNAME_FILE + fi } main \ No newline at end of file diff --git a/template/scripts/liferay_entrypoint.sh b/templates/bundle/scripts/liferay_entrypoint.sh similarity index 72% rename from template/scripts/liferay_entrypoint.sh rename to templates/bundle/scripts/liferay_entrypoint.sh index 5061084..21e4397 100755 --- a/template/scripts/liferay_entrypoint.sh +++ b/templates/bundle/scripts/liferay_entrypoint.sh @@ -19,13 +19,26 @@ function main { . set_java_version.sh - configure_liferay.sh + . configure_liferay.sh execute_scripts /usr/local/liferay/scripts/pre-startup - start_liferay.sh + start_liferay execute_scripts /usr/local/liferay/scripts/post-shutdown + +} + +function start_liferay { + set +e + + start_liferay.sh & + + START_LIFERAY_PID=$! + + echo "${START_LIFERAY_PID}" > "${LIFERAY_PID}" + + wait ${START_LIFERAY_PID} } main \ No newline at end of file diff --git a/templates/bundle/scripts/patch_liferay.sh b/templates/bundle/scripts/patch_liferay.sh new file mode 100755 index 0000000..88ab468 --- /dev/null +++ b/templates/bundle/scripts/patch_liferay.sh @@ -0,0 +1,85 @@ +#!/bin/bash + +function apply_patch { + local patch_file_name=${1} + local patch_version=$(echo "${patch_file_name}" | awk -F"-" '{ print $NF }' | awk -F"." '{ print $1 }') + + if [ -e "/opt/liferay/patching-tool/patch-applied" ] + then + local installed_patch=$(cat /opt/liferay/patching-tool/patch-applied) + + if [ ! "${patch_file_name}" == "${installed_patch}" ] + then + echo "" + echo "[LIFERAY] ${patch_file_name} cannot be applied on this container because ${installed_patch} is already installed. Remove ${patch_file_name} from the patching directory to disable this warning message." + fi + elif [ "$patch_version" -lt 7310 ] && + ( /opt/liferay/patching-tool/patching-tool.sh apply "${LIFERAY_PATCHING_DIR}/${patch_file_name}" ) + then + echo "${patch_file_name}" > /opt/liferay/patching-tool/patch-applied + + install_patch_step_2 + else + install_patch_step_1 "${patch_file_name}" + fi +} + +function install_patch_step_1 { + local patch_file_name="${1}" + + cp "${LIFERAY_PATCHING_DIR}/${patch_file_name}" /opt/liferay/patching-tool/patches + + if (/opt/liferay/patching-tool/patching-tool.sh install -force) + then + install_patch_step_2 + fi +} + +function install_patch_step_2 { + rm -fr /opt/liferay/osgi/state/* + + echo "" + echo "[LIFERAY] Patch applied successfully." +} + +function main { + if [[ $(ls -A "${LIFERAY_PATCHING_DIR}"/patching-tool-*.zip 2>/dev/null) ]] + then + echo "" + echo "[LIFERAY] Updating Patching Tool." + + mv /opt/liferay/patching-tool/patches /opt/liferay/patching-tool-upgrade-patches + + rm -fr /opt/liferay/patching-tool + + unzip -d /opt/liferay -q "${LIFERAY_PATCHING_DIR}"/patching-tool-* + + /opt/liferay/patching-tool/patching-tool.sh auto-discovery ../tomcat + + rm -fr /opt/liferay/patching-tool/patches + + mv /opt/liferay/patching-tool-upgrade-patches /opt/liferay/patching-tool/patches + + echo "" + echo "[LIFERAY] Patching Tool updated successfully." + fi + + if [[ $(find "${LIFERAY_PATCHING_DIR}" -maxdepth 1 -type f -name "liferay-*.zip" 2>/dev/null) ]] + then + if [ $(find "${LIFERAY_PATCHING_DIR}" -maxdepth 1 -type f -name "liferay-*.zip" | wc -l) == 1 ] + then + local patch_file_name=$(basename "${LIFERAY_PATCHING_DIR}"/liferay-*.zip) + + apply_patch "${patch_file_name}" + else + local patch_file_name=$(basename $(find "${LIFERAY_PATCHING_DIR}" -maxdepth 1 -name "liferay-*.zip" -type f 2>/dev/null | sort | tail -n 1)) + + echo "" + echo "[LIFERAY] There were multiple hotfixes in the patching folder. As only one can be installed, applying the latest one: ${patch_file_name}." + + apply_patch "${patch_file_name}" + fi + fi +} + +main \ No newline at end of file diff --git a/templates/bundle/scripts/probe_thread_dump.sh b/templates/bundle/scripts/probe_thread_dump.sh new file mode 100755 index 0000000..1a6278c --- /dev/null +++ b/templates/bundle/scripts/probe_thread_dump.sh @@ -0,0 +1,118 @@ +#!/bin/bash + +function check_usage { + FILE_PATH="/" + PORT=8080 + TIMEOUT=20 + + while [ "${1}" != "" ] + do + case ${1} in + -c) + shift + + CONTENT=${1} + + ;; + -d) + shift + + DOMAIN=${1} + + ;; + -h) + print_help + + ;; + -f) + shift + + FILE_PATH=${1} + + ;; + -p) + shift + + PORT=${1} + + ;; + -t) + shift + + TIMEOUT=${1} + + ;; + *) + print_help + + ;; + esac + + shift + done + + if [ ! -n "${DOMAIN}" ] + then + echo "The domain argument is required." + + exit 1 + fi +} + +function main { + if [ "${LIFERAY_THREAD_DUMP_PROBE_ENABLED}" != "true" ] + then + echo "Set the environment variable \"LIFERAY_THREAD_DUMP_PROBE_ENABLED\" to \"true\" to enable ${0}." + + exit 1 + fi + + check_usage "${@}" + + local curl_content + + curl_content=$(curl -m "${TIMEOUT}" -s --show-error --url "${DOMAIN}:${PORT}" "${DOMAIN}:${PORT}${FILE_PATH}") + + local exit_code=$? + + if [ -n "${CONTENT}" ] + then + curl_content=$(echo "${curl_content}" | grep" ${CONTENT}") + + exit_code=$? + fi + + if [ ${exit_code} -gt 1 ] + then + echo -e "${curl_content}" + + local thread_dump=$(jattach $(cat "${LIFERAY_PID}") threaddump) + + if [ ! -e "${LIFERAY_THREAD_DUMP_DIRECTORY}" ] + then + mkdir -p "${LIFERAY_THREAD_DUMP_DIRECTORY}" + fi + + echo -e "${thread_dump}" > "${LIFERAY_THREAD_DUMP_DIRECTORY}/$(hostname)_$(date +"%Y-%m-%dT%H:%M:%S%z").tdump" + fi + + exit ${exit_code} +} + +function print_help { + echo "Usage: ${0} -c -d -f -p -t " + echo "" + echo "The script can be configured with the following arguments:" + echo "" + echo " -c (optional): Content that the response must contain" + echo " -d (required): Domain of the URL to check" + echo " -f (optional): Path of the URL to check" + echo " -p (optional): HTTP port of the URL to check" + echo " -t (optional): Timeout in seconds" + echo "" + echo "Example: ${0} -d \"http://localhost\" -f \"/c/portal/layout\"" -p 8080 -t 20 + + exit 2 +} + +main "${@}" \ No newline at end of file diff --git a/templates/bundle/scripts/set_java_version.sh b/templates/bundle/scripts/set_java_version.sh new file mode 100755 index 0000000..f00334f --- /dev/null +++ b/templates/bundle/scripts/set_java_version.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +function create_symlink { + if [[ -e /usr/lib/jvm/"${2}"-"${1}" ]] && [[ ! -e /usr/lib/jvm/"${2//-/}" ]] + then + ln -sf /usr/lib/jvm/"${2}"-"${1}" /usr/lib/jvm/"${2//-/}" + fi +} + +function main { + if [ -n "${JAVA_VERSION}" ] + then + if [[ ! -e "/usr/lib/jvm/${JAVA_VERSION}" ]] + then + local architecture=$(dpkg --print-architecture) + local zulu_version=$(echo "${JAVA_VERSION}" | tr -dc '0-9') + + create_symlink "${architecture}" "zulu-${zulu_version}" + update-java-alternatives -s zulu-"${zulu_version}"-"${architecture}" + fi + + if [ -e "/usr/lib/jvm/${JAVA_VERSION}" ] + then + JAVA_HOME=/usr/lib/jvm/${JAVA_VERSION} + PATH=/usr/lib/jvm/${JAVA_VERSION}/bin/:${PATH} + + echo "[LIFERAY] Using ${JAVA_VERSION} JDK. You can use another JDK by setting the \"JAVA_VERSION\" environment varible." + echo "" + else + echo "[LIFERAY] \"${JAVA_VERSION}\" JDK is not available in this Docker image." + echo "" + + exit 1 + fi + fi +} + +main \ No newline at end of file diff --git a/templates/bundle/scripts/start_liferay.sh b/templates/bundle/scripts/start_liferay.sh new file mode 100755 index 0000000..a3c84e2 --- /dev/null +++ b/templates/bundle/scripts/start_liferay.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +function main { + echo "" + echo "[LIFERAY] Starting ${LIFERAY_PRODUCT_NAME}. To stop the container with CTRL-C, run this container with the option \"-it\"." + echo "" + + if [ "${LIFERAY_THREAD_DUMP_PROBE_ENABLED}" == "true" ] + then + cat "${LIFERAY_THREAD_DUMP_DIRECTORY}"/*.tdump + + rm "${LIFERAY_THREAD_DUMP_DIRECTORY}"/*.tdump + fi + + if [ "${APPLICATION_SERVER}" == "jboss-eap" ]; then + if [ "${LIFERAY_JPDA_ENABLED}" == "true" ]; then + ${LIFERAY_HOME}/jboss-eap/bin/standalone.sh -b 0.0.0.0 --debug ${JPDA_ADDRESS} + else + ${LIFERAY_HOME}/jboss-eap/bin/standalone.sh -b 0.0.0.0 + fi + else + if [ "${LIFERAY_JPDA_ENABLED}" == "true" ] + then + exec "${LIFERAY_HOME}"/tomcat/bin/catalina.sh jpda run + else + exec "${LIFERAY_HOME}"/tomcat/bin/catalina.sh run + fi + fi +} + +main diff --git a/templates/dynamic-rendering/Dockerfile b/templates/dynamic-rendering/Dockerfile new file mode 100644 index 0000000..e69de29 diff --git a/templates/jdk11-jdk8/Dockerfile b/templates/jdk11-jdk8/Dockerfile new file mode 100644 index 0000000..37dcc05 --- /dev/null +++ b/templates/jdk11-jdk8/Dockerfile @@ -0,0 +1,40 @@ +FROM --platform=linux/amd64 liferay/jdk11 as jdk11-jdk8-base-amd64 + +ARG LABEL_ZULU_8_AMD64_VERSION +ARG LABEL_ZULU_8_ARM64_VERSION +ARG LABEL_ZULU_8_VERSION=${LABEL_ZULU_8_AMD64_VERSION} + +FROM --platform=linux/arm64 liferay/jdk11 as jdk11-jdk8-base-arm64 + +ARG LABEL_ZULU_8_AMD64_VERSION +ARG LABEL_ZULU_8_ARM64_VERSION +ARG LABEL_ZULU_8_VERSION=${LABEL_ZULU_8_ARM64_VERSION} + +FROM jdk11-jdk8-base-${TARGETARCH} + +ARG LABEL_BUILD_DATE +ARG LABEL_NAME +ARG LABEL_VCS_REF +ARG LABEL_VCS_URL +ARG LABEL_VERSION +ARG LABEL_ZULU_8_VERSION +ARG TARGETARCH +ARG TARGETPLATFORM + +ENV JAVA_VERSION=zulu8 + +RUN curl -H 'accept: */*' -L -s -X 'GET' -o /tmp/jdk8.deb "https://api.azul.com/zulu/download/community/v1.0/bundles/latest/binary/?arch=${TARGETARCH}&bundle_type=jdk&ext=deb&hw_bitness=64&java_version=8.0&javafx=false&os=linux&zulu_version=${LABEL_ZULU_8_VERSION}" && \ + apt-get install -y /tmp/jdk8.deb && \ + rm /tmp/jdk8.deb && \ + /usr/local/bin/set_java_version.sh + +LABEL org.label-schema.build-date="${LABEL_BUILD_DATE}" +LABEL org.label-schema.name="${LABEL_NAME}" +LABEL org.label-schema.schema-version="1.0" +LABEL org.label-schema.vcs-ref="${LABEL_VCS_REF}" +LABEL org.label-schema.vcs-url="${LABEL_VCS_URL}" +LABEL org.label-schema.vendor="Liferay, Inc." +LABEL org.label-schema.version="${LABEL_VERSION}" +LABEL org.label-schema.zulu8_amd64_version="${LABEL_ZULU_8_AMD64_VERSION}" +LABEL org.label-schema.zulu8_arm64_version="${LABEL_ZULU_8_ARM64_VERSION}" +LABEL org.label-schema.zulu8_version="${LABEL_ZULU_8_VERSION}" \ No newline at end of file diff --git a/templates/jdk11/Dockerfile b/templates/jdk11/Dockerfile new file mode 100644 index 0000000..30a9122 --- /dev/null +++ b/templates/jdk11/Dockerfile @@ -0,0 +1,46 @@ +FROM --platform=linux/arm64 liferay/base as jdk11-base-arm64 + +ARG LABEL_ZULU_11_AMD64_VERSION +ARG LABEL_ZULU_11_ARM64_VERSION +ARG LABEL_ZULU_11_VERSION=${LABEL_ZULU_11_ARM64_VERSION} + +FROM --platform=linux/amd64 liferay/base as jdk11-base-amd64 + +ARG LABEL_ZULU_11_AMD64_VERSION +ARG LABEL_ZULU_11_ARM64_VERSION +ARG LABEL_ZULU_11_VERSION=${LABEL_ZULU_11_AMD64_VERSION} + +FROM jdk11-base-${TARGETARCH} + +ARG LABEL_BUILD_DATE +ARG LABEL_NAME +ARG LABEL_VCS_REF +ARG LABEL_VCS_URL +ARG LABEL_VERSION +ARG TARGETARCH +ARG TARGETPLATFORM + +ENV JAVA_VERSION=zulu11 + +COPY --chown=liferay:liferay home/.bashrc /home/liferay/ +COPY --chown=liferay:liferay scripts/set_java_version.sh /usr/local/bin/ + +RUN apt-get update && \ + apt-get install -y jattach && \ + apt-get upgrade -y && \ + apt-get clean && \ + curl -H 'accept: */*' -L -s -X 'GET' -o /tmp/jdk11.deb "https://api.azul.com/zulu/download/community/v1.0/bundles/latest/binary/?arch=${TARGETARCH}&bundle_type=jdk&ext=deb&hw_bitness=64&java_version=11.0&javafx=false&os=linux&zulu_version=${LABEL_ZULU_11_VERSION}" && \ + apt-get install -y /tmp/jdk11.deb && \ + rm /tmp/jdk11.deb && \ + /usr/local/bin/set_java_version.sh + +LABEL org.label-schema.build-date="${LABEL_BUILD_DATE}" +LABEL org.label-schema.name="${LABEL_NAME}" +LABEL org.label-schema.schema-version="1.0" +LABEL org.label-schema.vcs-ref="${LABEL_VCS_REF}" +LABEL org.label-schema.vcs-url="${LABEL_VCS_URL}" +LABEL org.label-schema.vendor="Liferay, Inc." +LABEL org.label-schema.version="${LABEL_VERSION}" +LABEL org.label-schema.zulu11_version="${LABEL_ZULU_11_VERSION}" +LABEL org.label-schema.zulu11_arm64_version="${LABEL_ZULU_11_ARM64_VERSION}" +LABEL org.label-schema.zulu11_amd64_version="${LABEL_ZULU_11_AMD64_VERSION}" \ No newline at end of file diff --git a/templates/jdk11/home/.bashrc b/templates/jdk11/home/.bashrc new file mode 100644 index 0000000..dfd42f4 --- /dev/null +++ b/templates/jdk11/home/.bashrc @@ -0,0 +1,16 @@ +function configure_jdk { + JAVA_HOME=/usr/lib/jvm/${JAVA_VERSION} + PATH=/usr/lib/jvm/${JAVA_VERSION}/bin/:${PATH} +} + +function customize_aliases { + alias la="ls -la --group-directories-first" +} + +function customize_prompt { + PS1="\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\${PWD}\[\e[0m\] \\n\$ " +} + +configure_jdk +customize_aliases +customize_prompt \ No newline at end of file diff --git a/templates/jdk11/scripts/set_java_version.sh b/templates/jdk11/scripts/set_java_version.sh new file mode 100755 index 0000000..f00334f --- /dev/null +++ b/templates/jdk11/scripts/set_java_version.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +function create_symlink { + if [[ -e /usr/lib/jvm/"${2}"-"${1}" ]] && [[ ! -e /usr/lib/jvm/"${2//-/}" ]] + then + ln -sf /usr/lib/jvm/"${2}"-"${1}" /usr/lib/jvm/"${2//-/}" + fi +} + +function main { + if [ -n "${JAVA_VERSION}" ] + then + if [[ ! -e "/usr/lib/jvm/${JAVA_VERSION}" ]] + then + local architecture=$(dpkg --print-architecture) + local zulu_version=$(echo "${JAVA_VERSION}" | tr -dc '0-9') + + create_symlink "${architecture}" "zulu-${zulu_version}" + update-java-alternatives -s zulu-"${zulu_version}"-"${architecture}" + fi + + if [ -e "/usr/lib/jvm/${JAVA_VERSION}" ] + then + JAVA_HOME=/usr/lib/jvm/${JAVA_VERSION} + PATH=/usr/lib/jvm/${JAVA_VERSION}/bin/:${PATH} + + echo "[LIFERAY] Using ${JAVA_VERSION} JDK. You can use another JDK by setting the \"JAVA_VERSION\" environment varible." + echo "" + else + echo "[LIFERAY] \"${JAVA_VERSION}\" JDK is not available in this Docker image." + echo "" + + exit 1 + fi + fi +} + +main \ No newline at end of file diff --git a/templates/job-runner/Dockerfile b/templates/job-runner/Dockerfile new file mode 100644 index 0000000..835b12e --- /dev/null +++ b/templates/job-runner/Dockerfile @@ -0,0 +1,27 @@ +FROM --platform=${TARGETPLATFORM} liferay/jdk11:latest + +ARG LABEL_BUILD_DATE +ARG LABEL_JOB_RUNNER_VERSION +ARG LABEL_NAME +ARG LABEL_VCS_REF +ARG LABEL_VCS_URL +ARG LABEL_VERSION +ARG TARGETPLATFORM + +RUN apt-get install cron && \ + apt-get clean + +COPY scripts/* /usr/local/bin/ + +ENTRYPOINT ["tini", "-v", "--", "/usr/local/bin/liferay_job_runner_entrypoint.sh"] + +LABEL org.label-schema.build-date="${LABEL_BUILD_DATE}" +LABEL org.label-schema.job-runner-version="${LABEL_JOB_RUNNER_VERSION}" +LABEL org.label-schema.name="${LABEL_NAME}" +LABEL org.label-schema.schema-version="1.0" +LABEL org.label-schema.vcs-ref="${LABEL_VCS_REF}" +LABEL org.label-schema.vcs-url="${LABEL_VCS_URL}" +LABEL org.label-schema.vendor="Liferay, Inc." +LABEL org.label-schema.version="${LABEL_VERSION}" + +WORKDIR /opt/liferay \ No newline at end of file diff --git a/templates/job-runner/scripts/job_wrapper.sh b/templates/job-runner/scripts/job_wrapper.sh new file mode 100755 index 0000000..41a1e35 --- /dev/null +++ b/templates/job-runner/scripts/job_wrapper.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +function main { + echo "" + echo "Running job ${1}." + echo "" + + time /bin/bash "/mnt/liferay/jobs/${1}.sh" +} + +main "${@}" \ No newline at end of file diff --git a/templates/job-runner/scripts/liferay_job_runner_entrypoint.sh b/templates/job-runner/scripts/liferay_job_runner_entrypoint.sh new file mode 100755 index 0000000..ccf7ecc --- /dev/null +++ b/templates/job-runner/scripts/liferay_job_runner_entrypoint.sh @@ -0,0 +1,56 @@ +#!/bin/bash + +function init { + . /usr/local/bin/set_java_version.sh + + mkdir -p /opt/liferay/job-queue + + cron +} + +function main { + init + + register_crontab + + run_jobs +} + +function register_crontab { + if [ ! -e /mnt/liferay/job-crontab ] + then + echo "The file /mnt/liferay/job-crontab does not exist." + + exit 2 + fi + + ( + crontab -l 2>/dev/null + + cat /mnt/liferay/job-crontab + ) | crontab - + + echo "Registered crontab: " + + cat /mnt/liferay/job-crontab + + echo "" +} + +function run_jobs { + while true + do + if [ $(ls /opt/liferay/job-queue | wc -l) -gt 0 ] + then + local job=$(ls -tr /opt/liferay/job-queue | head -n 1) + + rm "/opt/liferay/job-queue/${job}" + + job_wrapper.sh "${job}" + else + sleep 10 + fi + done +} + +main \ No newline at end of file diff --git a/templates/job-runner/scripts/register_job.sh b/templates/job-runner/scripts/register_job.sh new file mode 100755 index 0000000..4d9d37b --- /dev/null +++ b/templates/job-runner/scripts/register_job.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +function main { + mkdir -p /opt/liferay/job-queue + + if [ ! -e "/opt/liferay/job-queue/${1}" ] + then + touch "/opt/liferay/job-queue/${1}" + + echo "Registering ${1}." + else + echo "Skipping ${1} because it is already registered." + fi +} + +main "${@}" \ No newline at end of file diff --git a/templates/test/files/tomcat/webapps/ROOT/test_docker_image_files.jsp b/templates/test/files/tomcat/webapps/ROOT/test_docker_image_files.jsp new file mode 100644 index 0000000..5875671 --- /dev/null +++ b/templates/test/files/tomcat/webapps/ROOT/test_docker_image_files.jsp @@ -0,0 +1,3 @@ +<% +out.println("TEST"); +%> \ No newline at end of file diff --git a/templates/test/scripts/test_docker_image_scripts_1.sh b/templates/test/scripts/test_docker_image_scripts_1.sh new file mode 100755 index 0000000..4b93515 --- /dev/null +++ b/templates/test/scripts/test_docker_image_scripts_1.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +echo "TEST1" > /opt/liferay/tomcat/webapps/ROOT/test_docker_image_scripts_1.jsp +echo "TEST1" > /opt/liferay/tomcat/webapps/ROOT/test_docker_image_scripts_2.jsp \ No newline at end of file diff --git a/templates/test/scripts/test_docker_image_scripts_2.sh b/templates/test/scripts/test_docker_image_scripts_2.sh new file mode 100755 index 0000000..f1a5236 --- /dev/null +++ b/templates/test/scripts/test_docker_image_scripts_2.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +echo "TEST2" > /opt/liferay/tomcat/webapps/ROOT/test_docker_image_scripts_2.jsp \ No newline at end of file diff --git a/test_image.sh b/test_image.sh index c364dcc..0d1b9ed 100755 --- a/test_image.sh +++ b/test_image.sh @@ -10,8 +10,9 @@ function check_usage { echo "The script reads the following environment variables:" echo "" echo " LIFERAY_DOCKER_IMAGE_ID: ID of Docker image" - echo " LIFERAY_DOCKER_TEST_HOTFIX_URL: URL of the test hotfix to be installed" + echo " LIFERAY_DOCKER_TEST_HOTFIX_URL: URL of the test hotfix to install" echo " LIFERAY_DOCKER_TEST_INSTALLED_PATCHES: Comma separated list of installed patches (e.g. dxp-4-7210,hotfix-1072-7210)" + echo " LIFERAY_DOCKER_TEST_PATCHING_TOOL_URL: URL of the test Patching Tool to install" echo "" echo "Example: LIFERAY_DOCKER_IMAGE_ID=liferay/dxp:7.2.10.1-sp1-202001171544 ${0}" @@ -24,23 +25,28 @@ function check_usage { function clean_up_test_directory { if [ "${TEST_RESULT}" -eq 0 ] then - rm -fr ${TEST_DIR} + rm -fr "${TEST_DIR}" fi } -function log_test_result { - local test_result=SUCCESS +function log_test_failure { + TEST_RESULT=1 - if [ ${1} -gt 0 ] + if [ -n "${1}" ] then - TEST_RESULT=1 - - test_result=FAILED + echo "[${1}] FAILED" + else + echo "[${FUNCNAME[1]}] FAILED" fi +} - echo "[${FUNCNAME[1]}] ${test_result}" - - return ${1} +function log_test_success { + if [ -n "${1}" ] + then + echo "[${1}] SUCCESS" + else + echo "[${FUNCNAME[1]}] SUCCESS" + fi } function main { @@ -55,6 +61,7 @@ function main { test_docker_image_files test_docker_image_fix_pack_installed test_docker_image_hotfix_installed + test_docker_image_patching_tool_updated test_docker_image_scripts_1 test_docker_image_scripts_2 @@ -62,34 +69,55 @@ function main { clean_up_test_directory - exit ${TEST_RESULT} + exit "${TEST_RESULT}" } function prepare_mount { TEST_DIR=temp-test-$(date "$(date)" "+%Y%m%d%H%M") - mkdir -p ${TEST_DIR} + mkdir -p "${TEST_DIR}" - cp -r test-template/* ${TEST_DIR} + cp -r templates/test/* "${TEST_DIR}" - if [ -n "${LIFERAY_DOCKER_TEST_HOTFIX_URL}" ] + mkdir -p "${TEST_DIR}/patching" + + if [ -n "${LIFERAY_DOCKER_TEST_PATCHING_TOOL_URL}" ] then - mkdir -p ${TEST_DIR}/patching + local patcing_tool_file_name=${LIFERAY_DOCKER_TEST_PATCHING_TOOL_URL##*/} + download "downloads/patching-tool/${patcing_tool_file_name}" "${LIFERAY_DOCKER_TEST_PATCHING_TOOL_URL}" + else + local patcing_tool_file_name=$(find downloads/patching-tool/ -maxdepth 1 -name '*.zip' -printf "%T+\t%f\n" | sort | tail -n 1 | awk '{print $2}') + fi + + if [ -n "${LIFERAY_DOCKER_TEST_HOTFIX_URL}" ] + then local hotfix_file_name=${LIFERAY_DOCKER_TEST_HOTFIX_URL##*/} - download downloads/hotfix/${hotfix_file_name} ${LIFERAY_DOCKER_TEST_HOTFIX_URL} + download "downloads/hotfix/${hotfix_file_name}" "${LIFERAY_DOCKER_TEST_HOTFIX_URL}" - cp downloads/hotfix/${hotfix_file_name} ${TEST_DIR}/patching + cp "downloads/hotfix/${hotfix_file_name}" "${TEST_DIR}/patching" + fi + + if [ -n "${LIFERAY_DOCKER_TEST_PATCHING_TOOL_VERSION}" ] + then + download "downloads/patching-tool/patching-tool-${LIFERAY_DOCKER_TEST_PATCHING_TOOL_VERSION}.zip" "files.liferay.com/private/ee/fix-packs/patching-tool/patching-tool-${LIFERAY_DOCKER_TEST_PATCHING_TOOL_VERSION}.zip" + + cp "downloads/patching-tool/patching-tool-${LIFERAY_DOCKER_TEST_PATCHING_TOOL_VERSION}.zip" "${TEST_DIR}/patching/" + fi + + if [ -e "${TEST_DIR}/scripts" ] + then + chmod -R +x "${TEST_DIR}/scripts" fi } function start_container { echo "Starting container from image ${LIFERAY_DOCKER_IMAGE_ID}." - CONTAINER_ID=`docker run -d -p 8080 -v "${PWD}/${TEST_DIR}":/mnt/liferay ${LIFERAY_DOCKER_IMAGE_ID}` + CONTAINER_ID=$(docker run -d -p 8080 -v "${PWD}/${TEST_DIR}":/mnt/liferay "${LIFERAY_DOCKER_IMAGE_ID}") - CONTAINER_PORT_HTTP=`docker port ${CONTAINER_ID} 8080/tcp` + CONTAINER_PORT_HTTP=$(docker port "${CONTAINER_ID}" 8080/tcp) CONTAINER_PORT_HTTP=${CONTAINER_PORT_HTTP##*:} @@ -99,74 +127,64 @@ function start_container { function stop_container { echo "Stopping container." - docker kill ${CONTAINER_ID} > /dev/null - docker rm ${CONTAINER_ID} > /dev/null + docker kill "${CONTAINER_ID}" > /dev/null + docker rm "${CONTAINER_ID}" > /dev/null } function test_docker_image_files { - local content=`curl --fail --silent http://localhost:${CONTAINER_PORT_HTTP}/test_docker_image_files.jsp` - - if [ "${content}" == "TEST" ] - then - log_test_result 0 - else - log_test_result 1 - fi + test_page "http://localhost:${CONTAINER_PORT_HTTP}/test_docker_image_files.jsp" "TEST" } function test_docker_image_fix_pack_installed { if [ -n "${LIFERAY_DOCKER_TEST_INSTALLED_PATCHES}" ] then - local correct_fix_pack=$(echo ${LIFERAY_DOCKER_TEST_INSTALLED_PATCHES} | tr -d [:space:]) - local output=$(docker exec -it ${CONTAINER_ID} /opt/liferay/patching-tool/patching-tool.sh info | grep "Currently installed patches:") + local correct_fix_pack=$(echo "${LIFERAY_DOCKER_TEST_INSTALLED_PATCHES}" | tr -d '[:space:]') + local output=$(docker exec -it "${CONTAINER_ID}" /opt/liferay/patching-tool/patching-tool.sh info | grep "Currently installed patches:") - local installed_fix_pack=$(echo ${output##*: } | tr -d [:space:]) + local installed_fix_pack=$(echo "${output##*: }" | tr -d '[:space:]') if [ "${correct_fix_pack}" == "${installed_fix_pack}" ] then - log_test_result 0 + log_test_success else - log_test_result 1 + log_test_failure + + echo "The installed patch (${correct_fix_pack}) does not match the patch version retrived from the Patching Tool in the container (${installed_fix_pack})." fi else - log_test_result 0 + log_test_success fi } function test_docker_image_hotfix_installed { if [ -n "${LIFERAY_DOCKER_TEST_HOTFIX_URL}" ] then - local content=`curl --fail --silent http://localhost:${CONTAINER_PORT_HTTP}/` + test_page "http://localhost:${CONTAINER_PORT_HTTP}/" "Hotfix installation on the Docker image was successful." + fi +} + +function test_docker_image_patching_tool_updated { + if [ -n "${LIFERAY_DOCKER_TEST_PATCHING_TOOL_VERSION}" ] + then + local output=$(docker logs --details "${CONTAINER_ID}" 2>/dev/null) - if [[ "${content}" == *"Hotfix installation on the Docker image was successful."* ]] + if [[ "${output}" =~ .*"Patching Tool updated successfully".* ]] then - log_test_result 0 + log_test_success else - log_test_result 1 + log_test_failure + + echo "Unable to update the Patching Tool." fi fi } function test_docker_image_scripts_1 { - local content=`curl --fail --silent http://localhost:${CONTAINER_PORT_HTTP}/test_docker_image_scripts_1.jsp` - - if [ "${content}" == "TEST1" ] - then - log_test_result 0 - else - log_test_result 1 - fi + test_page "http://localhost:${CONTAINER_PORT_HTTP}/test_docker_image_scripts_1.jsp" "TEST1" } function test_docker_image_scripts_2 { - local content=`curl --fail --silent http://localhost:${CONTAINER_PORT_HTTP}/test_docker_image_scripts_2.jsp` - - if [ "${content}" == "TEST2" ] - then - log_test_result 0 - else - log_test_result 1 - fi + test_page "http://localhost:${CONTAINER_PORT_HTTP}/test_docker_image_scripts_2.jsp" "TEST2" } function test_health_status { @@ -176,13 +194,13 @@ function test_health_status { do echo -en "." - local status=`docker inspect --format="{{json .State.Health.Status}}" ${CONTAINER_ID}` + local status=$(docker inspect --format="{{json .State.Health.Status}}" "${CONTAINER_ID}") if [ "${status}" == "\"healthy\"" ] then echo "" - log_test_result 0 + log_test_success return fi @@ -192,7 +210,35 @@ function test_health_status { echo "" - log_test_result 1 + log_test_failure + + echo "Container health status is: ${status}." +} + +function test_page { + local content + + content=$(curl --fail -s --show-error "${1}") + + local exit_code=$? + + if [ ${exit_code} -gt 0 ] + then + log_test_failure "${FUNCNAME[1]}" + + echo "curl exit code is: ${exit_code}." + echo "" + echo "${content}" + else + if [[ "${content}" =~ .*"${2}".* ]] + then + log_test_success "${FUNCNAME[1]}" + else + log_test_failure "${FUNCNAME[1]}" + + echo "The \"${2}\" string is not present on the page." + fi + fi } -main ${@} \ No newline at end of file +main "${@}" \ No newline at end of file diff --git a/update_permissions.sh b/update_permissions.sh new file mode 100755 index 0000000..e1344b8 --- /dev/null +++ b/update_permissions.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +find . -name "*.sh" -type f -exec chmod 744 {} ";" \ No newline at end of file