# syntax=docker/dockerfile:1
# Multi-stage build: compile with Maven, run on a slim JRE.
FROM maven:3.9-eclipse-temurin-17 AS build
WORKDIR /build
COPY pom.xml .
COPY src ./src
# Persist the Maven repo in a BuildKit cache so dependencies download once and are reused
# across rebuilds. (The old `dependency:go-offline` was dropped: it eagerly pulled every
# optional Flyway DB module  BigQuery/Redshift/etc.  that the app never uses.)
RUN --mount=type=cache,target=/root/.m2 \
    MAVEN_OPTS="-Djava.net.preferIPv4Stack=true" mvn -B -DskipTests clean package

FROM eclipse-temurin:17-jre-jammy
WORKDIR /app
RUN useradd --system --uid 1001 appuser
COPY --from=build /build/target/user-wallet-service-*.jar app.jar
USER appuser
EXPOSE 8085
ENTRYPOINT ["java", "-jar", "app.jar"]
