How to use Gradle Build in Docker Image and Tomcat War Deployment?

30-12-2021

We can use following codes to run gradle build in docker image then copy generated war file to Tomcat directory

FROM gradle:7.3.3-jdk8 AS build
COPY --chown=gradle:gradle . /home/gradle/src
WORKDIR /home/gradle/src
RUN gradle build --no-daemon

FROM tomcat:8.5.73
WORKDIR /app
RUN rm -fr /usr/local/tomcat/webapps/ROOT
COPY --from=build home/gradle/src/build/libs/ktbyigm.war /usr/local/tomcat/webapps/ROOT.war
CMD ["catalina.sh", "run"]
EXPOSE 9090

© 2019 All rights reserved. Codesenior.COM