|  | 
| 1 |  | -ARG BASE_IMAGE=tomcat:10.1.26-jdk21-temurin-jammy | 
| 2 |  | -#referencing a specific image digest pins our unidata tomcat-docker image to platform amd64 (good) | 
| 3 |  | -ARG UNIDATA_TOMCAT_IMAGE=unidata/tomcat-docker:10-jdk17@sha256:af7d3fecec753cbd438f25881deeaf48b40ac1f105971d6f300252e104e39fb2 | 
| 4 |  | -FROM ${UNIDATA_TOMCAT_IMAGE} AS unidata-tomcat-image | 
| 5 |  | -FROM ${BASE_IMAGE} | 
|  | 1 | +ARG ERDDAP_VERSION=v2.27.0 | 
|  | 2 | +ARG BASE_IMAGE=erddap/erddap:$ERDDAP_VERSION | 
|  | 3 | +FROM $BASE_IMAGE | 
| 6 | 4 | 
 | 
| 7 |  | -#use approaches and hardened files from https://github.com/Unidata/tomcat-docker | 
| 8 |  | -#note: we don't inherit directly from Unidata/tomcat-docker to allow more | 
| 9 |  | -#flexibility in building images using different tomcat base images, architectures, etc | 
| 10 |  | -RUN apt-get update && \ | 
| 11 |  | -    apt-get install -y --no-install-recommends  \ | 
| 12 |  | -        gosu \ | 
| 13 |  | -        zip \ | 
| 14 |  | -        unzip \ | 
| 15 |  | -        && \ | 
| 16 |  | -    # Cleanup | 
| 17 |  | -    apt-get clean && \ | 
| 18 |  | -    rm -rf /var/lib/apt/lists/* && \ | 
| 19 |  | -    # Eliminate default web applications | 
| 20 |  | -    rm -rf ${CATALINA_HOME}/webapps/* && \ | 
| 21 |  | -    rm -rf ${CATALINA_HOME}/webapps.dist && \ | 
| 22 |  | -    # Obscuring server info | 
| 23 |  | -    cd ${CATALINA_HOME}/lib && \ | 
| 24 |  | -    mkdir -p org/apache/catalina/util/ && \ | 
| 25 |  | -    unzip -j catalina.jar org/apache/catalina/util/ServerInfo.properties \ | 
| 26 |  | -        -d org/apache/catalina/util/ && \ | 
| 27 |  | -    sed -i 's/server.info=.*/server.info=Apache Tomcat/g' \ | 
| 28 |  | -        org/apache/catalina/util/ServerInfo.properties && \ | 
| 29 |  | -    zip -ur catalina.jar \ | 
| 30 |  | -        org/apache/catalina/util/ServerInfo.properties && \ | 
| 31 |  | -    rm -rf org && cd ${CATALINA_HOME} && \ | 
| 32 |  | -    # Setting restrictive umask container-wide | 
| 33 |  | -    echo "session optional pam_umask.so" >> /etc/pam.d/common-session && \ | 
| 34 |  | -    sed -i 's/UMASK.*022/UMASK           007/g' /etc/login.defs | 
| 35 |  | - | 
| 36 |  | -# Security enhanced web.xml | 
| 37 |  | -COPY --from=unidata-tomcat-image ${CATALINA_HOME}/conf/web.xml ${CATALINA_HOME}/conf/ | 
| 38 |  | - | 
| 39 |  | -# Security enhanced server.xml | 
| 40 |  | -COPY --from=unidata-tomcat-image ${CATALINA_HOME}/conf/server.xml ${CATALINA_HOME}/conf/ | 
| 41 |  | - | 
| 42 |  | -ARG ERDDAP_VERSION=2.25.1 | 
| 43 |  | -ARG ERDDAP_CONTENT_VERSION=1.0.0 | 
| 44 |  | -ARG ERDDAP_WAR_URL="https://github.com/ERDDAP/erddap/releases/download/v${ERDDAP_VERSION}/erddap.war" | 
| 45 |  | -ARG ERDDAP_CONTENT_URL="https://github.com/ERDDAP/erddapContent/archive/refs/tags/content${ERDDAP_CONTENT_VERSION}.zip" | 
| 46 |  | -ENV ERDDAP_bigParentDirectory=/erddapData | 
| 47 |  | - | 
| 48 |  | -RUN apt-get update && apt-get install -y unzip xmlstarlet \ | 
| 49 |  | -    && if ! command -v gosu &> /dev/null; then apt-get install -y gosu; fi \ | 
|  | 5 | +RUN apt-get update && apt-get install -y gettext-base xmlstarlet \ | 
| 50 | 6 |     && rm -rf /var/lib/apt/lists/* | 
| 51 | 7 | 
 | 
| 52 |  | -ARG BUST_CACHE=1 | 
| 53 |  | -RUN \ | 
| 54 |  | -    mkdir -p /tmp/dl && \ | 
| 55 |  | -    curl -fSL "${ERDDAP_WAR_URL}" -o /tmp/dl/erddap.war && \ | 
| 56 |  | -    unzip /tmp/dl/erddap.war -d ${CATALINA_HOME}/webapps/erddap/ && \ | 
| 57 |  | -    curl -fSL "${ERDDAP_CONTENT_URL}" -o /tmp/dl/erddapContent.zip && \ | 
| 58 |  | -    unzip /tmp/dl/erddapContent.zip -d /tmp/dl/erddapContent && \ | 
| 59 |  | -    find /tmp/dl/erddapContent -type d -name content -exec cp -r "{}" ${CATALINA_HOME} \; && \ | 
| 60 |  | -    rm -rf /tmp/dl && \ | 
| 61 |  | -    sed -i 's#</Context>#<Resources cachingAllowed="true" cacheMaxSize="100000" />\n&#' ${CATALINA_HOME}/conf/context.xml && \ | 
| 62 |  | -    rm -rf /tmp/* /var/tmp/* && \ | 
| 63 |  | -    mkdir -p ${ERDDAP_bigParentDirectory} | 
| 64 |  | - | 
| 65 |  | -# Java options | 
| 66 |  | -COPY files/setenv.sh ${CATALINA_HOME}/bin/setenv.sh | 
| 67 |  | - | 
| 68 |  | -# server.xml fixup | 
| 69 |  | -COPY update-server-xml.sh /opt/update-server-xml.sh | 
| 70 |  | -RUN /opt/update-server-xml.sh | 
| 71 |  | - | 
| 72 |  | -# Default configuration | 
| 73 |  | -# Note: Make sure ERDDAP_flagKeyKey is set either in a runtime environment variable or in setup.xml | 
| 74 |  | -#       If a value is not set, a random value for ERDDAP_flagKeyKey will be generated at runtime. | 
| 75 |  | -ENV ERDDAP_baseHttpsUrl="https://localhost:8443" \ | 
| 76 |  | -    ERDDAP_emailEverythingTo="[email protected]"  \ | 
| 77 |  | -    ERDDAP_emailDailyReportsTo="[email protected]"  \ | 
| 78 |  | -    ERDDAP_emailFromAddress="[email protected]"  \ | 
| 79 |  | -    ERDDAP_emailUserName="" \ | 
| 80 |  | -    ERDDAP_emailPassword="" \ | 
| 81 |  | -    ERDDAP_emailProperties="" \ | 
| 82 |  | -    ERDDAP_emailSmtpHost="" \ | 
| 83 |  | -    ERDDAP_emailSmtpPort="" \ | 
| 84 |  | -    ERDDAP_adminInstitution="Axiom Docker Install" \ | 
| 85 |  | -    ERDDAP_adminInstitutionUrl="https://github.com/axiom-data-science/docker-erddap" \ | 
| 86 |  | -    ERDDAP_adminIndividualName="Axiom Docker Install" \ | 
| 87 |  | -    ERDDAP_adminPosition="Software Engineer" \ | 
| 88 |  | -    ERDDAP_adminPhone="555-555-5555" \ | 
| 89 |  | -    ERDDAP_adminAddress="123 Irrelevant St." \ | 
| 90 |  | -    ERDDAP_adminCity="Nowhere" \ | 
| 91 |  | -    ERDDAP_adminStateOrProvince="AK" \ | 
| 92 |  | -    ERDDAP_adminPostalCode="99504" \ | 
| 93 |  | -    ERDDAP_adminCountry="USA" \ | 
| 94 |  | -    ERDDAP_adminEmail="[email protected]" | 
| 95 |  | - | 
| 96 |  | -COPY entrypoint.sh datasets.d.sh / | 
| 97 |  | -ENTRYPOINT ["/entrypoint.sh"] | 
| 98 |  | - | 
| 99 |  | -EXPOSE 8080 | 
| 100 |  | -CMD ["catalina.sh", "run"] | 
|  | 8 | +COPY datasets.d.sh / | 
|  | 9 | + | 
|  | 10 | +# advise users to use upstream offical ERDDAP docker image | 
|  | 11 | +# if they aren't using experimental features in this image | 
|  | 12 | +COPY --chmod=755 <<EOF /init.d/00-advise-upstream.sh | 
|  | 13 | +#/bin/sh | 
|  | 14 | +cat <<EOF2 | 
|  | 15 | + | 
|  | 16 | +███████ ██████  ██████  ██████   █████  ██████   | 
|  | 17 | +██      ██   ██ ██   ██ ██   ██ ██   ██ ██   ██  | 
|  | 18 | +█████   ██████  ██   ██ ██   ██ ███████ ██████   | 
|  | 19 | +██      ██   ██ ██   ██ ██   ██ ██   ██ ██       | 
|  | 20 | +███████ ██   ██ ██████  ██████  ██   ██ ██       | 
|  | 21 | + | 
|  | 22 | +NOTE: As of version v2.27.0 this image (axiom/docker-erddap) | 
|  | 23 | +is derived from the official ERDDAP Docker image (erddap/erddap). | 
|  | 24 | + | 
|  | 25 | +If you are not using any experimental functionality offered | 
|  | 26 | +by the axiom image (notably datasets.d), you are recommended | 
|  | 27 | +to use the official ERDDAP Docker image instead. | 
|  | 28 | + | 
|  | 29 | +See https://hub.docker.com/r/erddap/erddap for more details.                                                 | 
|  | 30 | + | 
|  | 31 | +EOF2 | 
|  | 32 | +EOF | 
|  | 33 | + | 
|  | 34 | +COPY --chmod=755 <<'EOF' /init.d/50-datasets.d.sh | 
|  | 35 | +#/bin/sh | 
|  | 36 | +### | 
|  | 37 | +# Add datasets in /datasets.d to datasets.xml | 
|  | 38 | +### | 
|  | 39 | +if [ -d "/datasets.d" ]; then | 
|  | 40 | +  echo "Creating datasets.xml from /datasets.d" | 
|  | 41 | +  ERDDAP_CONTENT_DIR="/usr/local/tomcat/content/erddap" | 
|  | 42 | +  DATASETS_XML="${ERDDAP_CONTENT_DIR}/datasets.xml" | 
|  | 43 | +  if [ -f "$DATASETS_XML" ]; then | 
|  | 44 | +    #datasets.xml exists, make sure we have a backup of it | 
|  | 45 | +    DATASETS_XML_MD5SUM=$(md5sum "$DATASETS_XML" | awk '{print $1}') | 
|  | 46 | +    if ! md5sum "${ERDDAP_CONTENT_DIR}/datasets.xml.*.bak" 2>/dev/null | grep -q "$DATASETS_XML_MD5SUM"; then | 
|  | 47 | +      #we don't have a backup of this version of datasets.xml yet, make one | 
|  | 48 | +      DATASETS_XML_BACKUP="${ERDDAP_CONTENT_DIR}"/datasets.xml.$(date -u +"%Y%m%dT%H%M%SZ").bak | 
|  | 49 | +      echo "Backing up "${DATASETS_XML}" to ${DATASETS_XML_BACKUP}" | 
|  | 50 | +      cp "$DATASETS_XML" "${DATASETS_XML_BACKUP}" | 
|  | 51 | +    fi | 
|  | 52 | +  fi | 
|  | 53 | +  /datasets.d.sh -o "$DATASETS_XML" -w | 
|  | 54 | +fi | 
|  | 55 | +EOF | 
|  | 56 | + | 
|  | 57 | +ENV ERDDAP_useHeadersForUrl=true \ | 
|  | 58 | +    ERDDAP_useSaxParser=true | 
0 commit comments