Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Dockerfile #155

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 34 additions & 9 deletions server/wfprev-api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,44 @@
# Use an official Tomcat image as a base image
FROM tomcat:10.1-jdk17-corretto
# Remove the default webapps to avoid conflicts
RUN rm -rf /usr/local/tomcat/webapps/*
# Copy the WAR file to the Tomcat webapps directory
COPY *.war /usr/local/tomcat/webapps/ROOT.war
ENV TOMCAT_HOME=/usr/local/tomcat \
CATALINA_HOME=/usr/local/tomcat \

# Install unzip at the top layer to ease caching issues for devs
RUN yum update -y && \
yum install -y unzip && \
yum clean all

# Define build arguments
ARG WAR_FILE=target/wfprev-api-1.0.0-SNAPSHOT.war
ARG CONTAINER_NAME=wfprev-api

# Set environment variables
ENV CATALINA_HOME=/usr/local/tomcat \
CATALINA_OUT=/usr/local/tomcat/logs \
TOMCAT_MAJOR=10 \
JAVA_OPTS="$JAVA_OPTS -Xss200k"
# 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

# 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

# Expose the Tomcat port (default is 8080)
EXPOSE 8080
# Start Tomcat when the container starts

# Start Tomcat when the container
CMD ["catalina.sh", "run"]
Loading