Skip to content
This repository has been archived by the owner on Jan 22, 2022. It is now read-only.

Commit

Permalink
Merge pull request #45 from dotCMS/tomcat-resolving
Browse files Browse the repository at this point in the history
Resolving correctly tomcat version
  • Loading branch information
victoralfaro-dotcms authored Feb 2, 2021
2 parents ea83640 + 1612139 commit 15157b9
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 46 deletions.
10 changes: 6 additions & 4 deletions images/dotcms/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ ARG BUILD_FROM=COMMIT
# Value resolved in the context of $BUILD_FROM
ARG BUILD_ID=HEAD

# Tomcat version
ARG TOMCAT_VERSION

WORKDIR /srv

# dotCMS core distributed under GPLv3 license (https://github.com/dotCMS/core/blob/master/license.txt)
COPY build-src/ /build/
RUN chmod 500 /build/build_dotcms.sh && /build/build_dotcms.sh ${BUILD_FROM} ${BUILD_ID}
RUN chmod 500 /build/build_dotcms.sh && /build/build_dotcms.sh ${BUILD_FROM} ${BUILD_ID} ${TOMCAT_VERSION}

RUN mkdir -p /srv/utils /srv/templates /srv/config /srv/home
RUN chmod -R 666 /srv && find /srv/ -type d -exec chmod a+x {} \;
Expand All @@ -36,7 +38,7 @@ WORKDIR /srv

RUN apk --no-cache upgrade \
&& apk add --no-cache bash openssl ca-certificates gnupg grep sed tini nss s6-dns go libpq git gcc musl-dev libc6-compat tomcat-native curl \
&& update-ca-certificates
&& update-ca-certificates

RUN apk add libsass --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/community/

Expand All @@ -56,7 +58,7 @@ RUN wget --quiet https://github.com/jwilder/dockerize/archive/v0.6.1.tar.gz \

RUN cd / && rm -rf /dockerize-0.6.1

RUN apk del -r --purge git gcc musl-dev go
RUN apk del -r --purge git gcc musl-dev go



Expand Down Expand Up @@ -92,4 +94,4 @@ EXPOSE 4000
USER 1000000000

ENTRYPOINT ["/sbin/tini", "--", "/srv/entrypoint.sh"]
CMD ["dotcms"]
CMD ["dotcms"]
99 changes: 57 additions & 42 deletions images/dotcms/build-src/build_dotcms.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,74 +4,89 @@ set -e

build_source=$1
build_id=$2
tomcat_version=$3
echo "Build source: $build_source"
echo "Build id: $build_id"

build_target_dir=/build/cms
mkdir -p "${build_target_dir}"

get_by_url() {
build_download_dir=/build/download
mkdir -p ${build_download_dir}
build_download_dir=/build/download
mkdir -p ${build_download_dir}

echo "Fetching build: $1"
wget --quiet -O "${build_download_dir}/dotcms.tgz" "$1"
tar xzf "${build_download_dir}/dotcms.tgz" -C "${build_target_dir}"
# We should have some verification here, but we have no source of truth yet
echo "Fetching build: $1"
wget --quiet -O "${build_download_dir}/dotcms.tgz" "$1"
tar xzf "${build_download_dir}/dotcms.tgz" -C "${build_target_dir}"
# We should have some verification here, but we have no source of truth yet
}

build_by_commit() {
mkdir -p /build/src && cd /build/src

cd /build/src/core
git clean -f -d
git pull
echo "Checking out commit/tag/branch: $1"
git checkout $1

cd dotCMS && ./gradlew createDistPrep -PuseGradleNode=false
find ../dist/ -name "*.sh" -exec chmod 500 {} \;
mv ../dist/* "${build_target_dir}"
mkdir -p /build/src && cd /build/src

cd /build/src/core
git clean -f -d
git pull

echo "Checking out commit/tag/branch: $1"
git checkout $1

cd dotCMS && ./gradlew clonePullTomcatDist createDistPrep -PuseGradleNode=false
find ../dist/ -name "*.sh" -exec chmod 500 {} \;
mv ../dist/* "${build_target_dir}"
}

set_tomcat_dir() {
TOMCAT_VERSION=$(find /srv/dotserver/ -type d -name tomcat-* | grep -oP "(?<=tomcat-)[0-9]{1}\.[0-9]{1}\.[0-9]+$" | head -n 1)
[[ -z "${TOMCAT_VERSION}" ]] && echo "ERROR: Unable to determine Tomcat version" && exit 1
echo ${TOMCAT_VERSION} >/srv/TOMCAT_VERSION
tomcat_versions=$(find /srv/dotserver/ -type d -name tomcat-* | grep -oP "(?<=tomcat-)[0-9]{1}\.[0-9]{1}\.[0-9]+$")
echo "Found tomcat installations:
${tomcat_versions}"

if [[ -n "${tomcat_version}" ]]; then
echo "Provided Tomcat version: ${tomcat_version}"
if [[ -n $(echo "${tomcat_versions}" | grep -oP "${tomcat_version}") ]]; then
echo "Matched tomcat_version: ${tomcat_version} with installed"
else
echo "Provided tomcat_version: ${tomcat_version} does not matched installed, aborting"
exit 1
fi
else
tomcat_version=$(find /srv/dotserver/ -type d -name tomcat-* | grep -oP "(?<=tomcat-)[0-9]{1}\.[0-9]{1}\.[0-9]+$" | tail -n 1)
[[ -z "${tomcat_version}" ]] && echo "ERROR: Unable to determine Tomcat version" && exit 1
fi

echo "Using tomcat_version=${tomcat_version}"
echo ${tomcat_version} >/srv/TOMCAT_VERSION
}

case "${build_source}" in
case "${build_source}" in

"TARBALL_URL" )
"TARBALL_URL" )

get_by_url "${build_id}"
;;
get_by_url "${build_id}"
;;

"RELEASE" )
"RELEASE" )

get_by_url "http://static.dotcms.com/versions/dotcms_${build_id}.tar.gz"
;;
get_by_url "http://static.dotcms.com/versions/dotcms_${build_id}.tar.gz"
;;

"NIGHTLY" )
"NIGHTLY" )

echo "ERROR: Not implemented"
exit 1
;;
echo "ERROR: Not implemented"
exit 1
;;

"COMMIT" | "TAG" )
"COMMIT" | "TAG" )

build_by_commit "${build_id}"
;;
build_by_commit "${build_id}"
;;

*)
echo "Invalid option"
exit 1
;;
*)
echo "Invalid option"
exit 1
;;
esac

mv ${build_target_dir}/* /srv/

set_tomcat_dir


set_tomcat_dir

0 comments on commit 15157b9

Please sign in to comment.