BaseAnalyzer/Dockerfile
2025-10-10 15:37:44 +02:00

44 lines
No EOL
1.4 KiB
Docker

# Stage 1: Build the application using SBT
# We use a stable OpenJDK 8 base and install the specific SBT version needed,
# as public SBT images for older versions can be unreliable.
FROM openjdk:8-jdk-slim as builder
# SBT version from project/build.properties
ARG SBT_VERSION=0.13.11
ENV SBT_HOME=/usr/local/sbt
ENV PATH=${SBT_HOME}/bin:${PATH}
# Install required tools and the specific version of SBT
RUN apt-get update && \
apt-get install -y curl && \
curl -L -o sbt.tgz https://github.com/sbt/sbt/releases/download/v${SBT_VERSION}/sbt-${SBT_VERSION}.tgz && \
tar -xzf sbt.tgz -C /usr/local && \
rm sbt.tgz && \
apt-get purge -y --auto-remove curl
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