Implemented a multistage Docker build, separating build and runtime stages to reduce the final image size and improve security. Adjusted `.dockerignore` to exclude unnecessary files from the build context and updated the base JRE image to use the build output efficiently.
26 lines
613 B
Docker
26 lines
613 B
Docker
FROM eclipse-temurin:25-jdk AS build
|
|
|
|
WORKDIR /build
|
|
|
|
COPY .mvn .mvn
|
|
COPY mvnw pom.xml checkstyle.xml ./
|
|
RUN chmod +x mvnw && ./mvnw -B -q dependency:go-offline
|
|
|
|
COPY src src
|
|
RUN ./mvnw -B -q package -DskipTests
|
|
|
|
FROM eclipse-temurin:25-jre@sha256:ff82c74a630c08b417502c4c18189e62074edbb28eb1f2d31b799ac138c01058
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends netcat-openbsd curl && rm -rf /var/lib/apt/lists/*
|
|
|
|
WORKDIR /app
|
|
|
|
ARG API_PORT=9000
|
|
EXPOSE ${API_PORT}
|
|
|
|
COPY startup.sh ./
|
|
COPY --from=build /build/target/netneutrality.jar ./
|
|
|
|
RUN ["chmod", "+x", "./startup.sh"]
|
|
CMD ["./startup.sh"]
|