Created
March 18, 2025 06:11
-
-
Save kewalaka/7488d863d411f7a80e9224760eb6af9e to your computer and use it in GitHub Desktop.
A two stage Dockerfile for building Cocoon 2.1 from source & hosting on Tomcat 7.
This file contains hidden or 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
| # === STAGE 1: Build Cocoon === | |
| FROM openjdk:8 as builder | |
| # Set environment variables | |
| ENV JAVA_HOME=/usr/local/openjdk-8 | |
| ENV PATH="$JAVA_HOME/bin:$PATH" | |
| # Set working directory | |
| WORKDIR /usr/src/cocoon | |
| # Download and extract Cocoon 2.1.13 source | |
| RUN apt-get update && apt-get install -y wget \ | |
| && wget -qO- https://archive.apache.org/dist/cocoon/2.1/cocoon-2.1.13-src.tar.gz | tar xz --strip-components=1 \ | |
| && wget -qO- https://archive.apache.org/dist/cocoon/2.1/cocoon-2.1.13-deps.tar.gz | tar xz --strip-components=1 \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Run the build process | |
| RUN chmod +x build.sh && ./build.sh | |
| # Install ICU4J dependency **before** packaging the WAR, as the older version doesn't work with java 8. | |
| RUN mkdir -p build/webapp/WEB-INF/lib && \ | |
| wget -O build/webapp/WEB-INF/lib/icu4j-4.8.1.1.jar \ | |
| https://repo1.maven.org/maven2/com/ibm/icu/icu4j/4.8.1.1/icu4j-4.8.1.1.jar && \ | |
| rm -f build/webapp/WEB-INF/lib/icu4j-2*.jar | |
| # After building Cocoon, package it into a WAR file | |
| RUN cd /usr/src/cocoon/build/webapp && \ | |
| jar -cvf /usr/src/cocoon/build/cocoon.war . | |
| # === STAGE 2: Deploy Cocoon in Tomcat === | |
| FROM tomcat:7-jdk8 | |
| # Set environment variables | |
| ENV CATALINA_HOME /usr/local/tomcat | |
| ENV PATH "$CATALINA_HOME/bin:$PATH" | |
| # Copy built Cocoon WAR file from builder stage to Tomcat's webapps directory | |
| COPY --from=builder /usr/src/cocoon/build/cocoon.war $CATALINA_HOME/webapps/ | |
| # Modify the Tomcat default web.xml to remove the welcome-file-list (the default set of files such as index.html) | |
| RUN sed -i '/<welcome-file-list>/,/<\/welcome-file-list>/d' /usr/local/tomcat/conf/web.xml | |
| # Expose Tomcat port | |
| EXPOSE 8080 | |
| # Start Tomcat | |
| CMD ["catalina.sh", "run"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment