#pulling from github

FROM alpine/git:v2.30.1 AS code
ARG BUILD_ID
ARG GITEA_USER
ARG GITEA_PASS
RUN echo $BUILD_ID
LABEL stage=builder
LABEL build_id=$BUILD_ID
RUN mkdir repo
WORKDIR /repo
RUN git clone http://$GITEA_USER:$GITEA_PASS@157.66.191.31:3000/risadmin_prod/calculator_app_20250925_065100.git
#************* Stage 2 - Maven Build **************
FROM maven:3.9.3 AS mvn
LABEL stage=builder
LABEL build=$BUILD_ID
WORKDIR /workspace/app
COPY --from=code /repo/calculator_app_20250925_065100/calculator_app_20250925_065100-calculator_app_20250925_065100-b-b/authsec_springboot/backend/ /workspace/app
RUN mkdir builder/
RUN mvn install -Dmaven.test.skip

#******** Stage 3 - Docker Build *********

#FROM java:8-jdk-alpine
FROM openjdk:8-jdk-alpine
LABEL stage=app
LABEL build=$BUILD_ID
RUN mkdir /usr/app
RUN mkdir /data
COPY --from=mvn /workspace/app/target/*jar /usr/app/gtest.jar
RUN mkdir /usr/app/sureops
WORKDIR /usr/app
EXPOSE 9292
ENTRYPOINT ["java", "-jar", "gtest.jar"]