ARG SERVICE_MODULE=tenant-service

FROM maven:3.9.9-eclipse-temurin-21 AS build
ARG SERVICE_MODULE
WORKDIR /workspace

COPY pom.xml ./pom.xml
COPY common ./common
COPY tenant-service ./tenant-service
COPY im-service ./im-service
COPY push-service ./push-service
COPY update-service ./update-service
COPY demo-service ./demo-service
COPY file-service ./file-service

RUN mvn -pl ${SERVICE_MODULE} -am -DskipTests package

FROM eclipse-temurin:21-jre-jammy
WORKDIR /app
ARG SERVICE_MODULE

COPY --from=build /workspace/${SERVICE_MODULE}/target/${SERVICE_MODULE}-0.1.0-SNAPSHOT.jar /app/app.jar

ENTRYPOINT ["java", "-jar", "/app/app.jar"]
