# Built on the build machine's own platform; the final stage only copies, so an arm64 image for
# the Pi needs no emulation.
FROM --platform=$BUILDPLATFORM maven:3.9-eclipse-temurin-21 AS build
WORKDIR /src
COPY pom.xml .
RUN mvn -B -q dependency:go-offline
COPY src src
RUN mvn -B -q package -Dmaven.test.skip=true

FROM eclipse-temurin:21-jre
# The release tag, shown in /health; the release workflow passes it.
ARG VERSION=dev
ENV VERSION=$VERSION
COPY --from=build /src/target/home-pump-1.0.0.jar /app/gateway.jar
# Config, spool, restore file and token live on the Pi under the same path (compose.yaml).
ENTRYPOINT ["java", "-jar", "/app/gateway.jar"]
CMD ["/home/pi/home-pump/gateway.json"]
