# Stage 1: Build the application using SBT FROM sbtscala/sbt:11.0.11_1.5.5_2.13.6 as builder WORKDIR /app # Copy project definition files and resolve dependencies first for better layer caching COPY project/ ./project/ COPY build.sbt . # This step will download all the dependencies RUN sbt update # Copy the rest of the source code COPY . . # Package the application into a WAR file RUN sbt package # Stage 2: Create the runtime image with Tomcat FROM tomcat:9.0-jdk11-openjdk-slim # Remove the default webapps RUN rm -rf /usr/local/tomcat/webapps/* # Copy the WAR file from the builder stage to Tomcat's webapps directory # The WAR file will be automatically deployed by Tomcat on startup COPY --from=builder /app/target/scala-2.11/coc-base-analyser_2.11-0.1.war /usr/local/tomcat/webapps/ROOT.war EXPOSE 8080