Last active
December 28, 2022 20:17
-
-
Save isapir/c7ca224caa42cfb9b9b42d024d34cc14 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ARG TOMCAT_VERSION=9.0.70 | |
ARG BASE_JAVA_IMAGE=azul/zulu-openjdk-alpine:11-jre-latest | |
ARG TOMCAT_FILENAME="apache-tomcat-${TOMCAT_VERSION}" | |
ARG CATALINA_HOME_DIR=/srv/www/catalina-home | |
ARG CATALINA_HOME=${CATALINA_HOME_DIR}/${TOMCAT_FILENAME} | |
ARG CATALINA_BASE=/srv/www/catalina-base | |
## Image size 238MB | |
FROM ${BASE_JAVA_IMAGE} AS builder | |
## Inherit global args | |
ARG TOMCAT_VERSION | |
ARG TOMCAT_FILENAME | |
ARG CATALINA_HOME_DIR | |
ARG CATALINA_HOME | |
ARG CATALINA_BASE | |
ENV TOMCAT_FILENAME=${TOMCAT_FILENAME} | |
ENV CATALINA_HOME_DIR=${CATALINA_HOME_DIR} | |
ENV CATALINA_HOME=${CATALINA_HOME} | |
ENV CATALINA_BASE=${CATALINA_BASE} | |
RUN apk --update add bash curl vim \ | |
&& env \ | |
&& mkdir -p /usr/local/src ${CATALINA_HOME_DIR} \ | |
&& cd /usr/local/src \ | |
&& echo Downloading https://dlcdn.apache.org/tomcat/tomcat-9/v${TOMCAT_VERSION}/bin/${TOMCAT_FILENAME}.tar.gz \ | |
&& curl -sL https://dlcdn.apache.org/tomcat/tomcat-9/v${TOMCAT_VERSION}/bin/${TOMCAT_FILENAME}.tar.gz | tar xz -C . \ | |
&& mv /usr/local/src/${TOMCAT_FILENAME} ${CATALINA_HOME_DIR} \ | |
&& ${CATALINA_HOME}/bin/makebase.sh ${CATALINA_BASE} \ | |
&& echo "Hello Tomcat!" > ${CATALINA_BASE}/webapps/ROOT/index.html | |
## Image size 205MB | |
FROM ${BASE_JAVA_IMAGE} AS tomcat | |
## Inherit global args | |
ARG CATALINA_HOME | |
ARG CATALINA_BASE | |
ENV CATALINA_HOME=${CATALINA_HOME} | |
ENV CATALINA_BASE=${CATALINA_BASE} | |
COPY --chown=0:1000 --from=builder /srv/www /srv/www | |
## Use 'sh -c' to resolve environment variables | |
CMD [ "sh", "-c", "${CATALINA_HOME}/bin/catalina.sh run" ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment