-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use copy instead of unzip for war in Dockefiler
- Loading branch information
Showing
1 changed file
with
15 additions
and
29 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,30 @@ | ||
# Use an official Tomcat image as a base image | ||
FROM tomcat:10.1-jdk17-corretto | ||
|
||
# Install unzip at the top layer to ease caching issues for devs | ||
RUN yum update -y && \ | ||
yum install -y unzip && \ | ||
yum clean all | ||
# Remove the default webapps to avoid conflicts | ||
RUN rm -rf /usr/local/tomcat/webapps/* | ||
|
||
# Define build arguments | ||
ARG WAR_FILE=*.war | ||
ARG CONTAINER_NAME=wfprev-api | ||
ARG CONTAINER_NAME=wfprev-war | ||
ENV CATALINA_HOME /usr/local/tomcat | ||
|
||
# Set environment variables | ||
ENV CATALINA_HOME=/usr/local/tomcat \ | ||
# Copy the WAR file to the Tomcat webapps directory with the new name | ||
COPY target/wfprev-api-1.0.0-SNAPSHOT.war /usr/local/tomcat/webapps/pub#wfprev-api.war | ||
|
||
ENV TOMCAT_HOME=/usr/local/tomcat \ | ||
CATALINA_HOME=/usr/local/tomcat \ | ||
CATALINA_OUT=/usr/local/tomcat/logs \ | ||
TOMCAT_MAJOR=10 \ | ||
JAVA_OPTS="$JAVA_OPTS -Xss200k" | ||
|
||
# Add WAR file | ||
ADD ${WAR_FILE} . | ||
|
||
# Set up directories and permissions | ||
RUN rm -rf /usr/local/tomcat/webapps/ROOT && \ | ||
for i in $(ls *.war); do \ | ||
export TEMPNAME="$(echo $i | sed -E 's/(.*)((-api)|(-war))-.*/\1\3/')" && \ | ||
unzip $i -d /usr/local/tomcat/webapps/pub#$TEMPNAME; \ | ||
done && \ | ||
chmod -R 770 ${CATALINA_HOME} && \ | ||
mkdir -p /usr/local/tomcat/temp && \ | ||
mkdir -p ${CATALINA_HOME}/webapps/pub#${CONTAINER_NAME} && \ | ||
chmod 766 /usr/local/tomcat/logs && \ | ||
chmod 766 /usr/local/tomcat/work && \ | ||
chmod 766 /usr/local/tomcat/temp && \ | ||
chmod 766 ${CATALINA_HOME}/webapps/pub#${CONTAINER_NAME} && \ | ||
echo org.apache.tomcat.util.digester.PROPERTY_SOURCE=org.apache.tomcat.util.digester.EnvironmentPropertySource >> /usr/local/tomcat/conf/catalina.properties | ||
|
||
# Define volumes for logs, work, and temp directories | ||
VOLUME /usr/local/tomcat/logs /usr/local/tomcat/work /usr/local/tomcat/temp | ||
# Set permissions for logs, work, and temp directories | ||
RUN chmod 766 /usr/local/tomcat/logs && chmod 766 /usr/local/tomcat/work && chmod 766 /usr/local/tomcat/temp | ||
|
||
# Define volumes for logs, work, temp, and webapps directories | ||
VOLUME /usr/local/tomcat/logs /usr/local/tomcat/work /usr/local/tomcat/temp /usr/local/tomcat/webapps | ||
|
||
# Expose the Tomcat port (default is 8080) | ||
EXPOSE 8080 | ||
|
||
# Start Tomcat when the container | ||
# Start Tomcat when the container starts | ||
CMD ["catalina.sh", "run"] |