ARG TOMCAT_HASH_TAG=':8.0.51-jre8'
FROM tomcat${TOMCAT_HASH_TAG}

# Need to add nc for healthcheck.
# Base image is Debian Stretch (EOL), use archive.debian.org and allow unauthenticated
# packages (archive signing keys have expired).
RUN printf "deb http://archive.debian.org/debian stretch main\n\
    deb http://archive.debian.org/debian-security stretch/updates main\n" \
    > /etc/apt/sources.list && \
    rm -f /etc/apt/sources.list.d/* && \
    apt-get update && \
    apt-get install -y --allow-unauthenticated netcat-openbsd && \
    apt-get clean -yq && \
    apt-get autoremove -yq && \
    rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
    truncate -s 0 /var/log/*log 2>/dev/null || true

# Tomcat config: empty webapps, listen on port 80 for healthcheck
RUN rm -rf /usr/local/tomcat/webapps/* && \
    sed -i 's/port="8080"/port="80"/' /usr/local/tomcat/conf/server.xml

ADD log4shell-1.0-SNAPSHOT.war /usr/local/tomcat/webapps/ROOT.war

EXPOSE 80
CMD ["catalina.sh", "run"]
