# Dockerfile.app

ARG COMMON_IMAGE
FROM ${COMMON_IMAGE}

ARG BUILD_FOLDER
ARG MAIN_CLASS
ARG IMAGE_NAME
ARG IMAGE_TAG

ENV BUILD_FOLDER=${BUILD_FOLDER}
ENV MAIN_CLASS=${MAIN_CLASS}
ENV IMAGE_NAME=${IMAGE_NAME}
ENV IMAGE_TAG=${IMAGE_TAG}

# Log ARGs at build time
RUN echo "BUILD_FOLDER: ${BUILD_FOLDER}" && \
    echo "MAIN_CLASS: ${MAIN_CLASS}" && \
    echo "IMAGE_NAME: ${IMAGE_NAME}" && \
    echo "IMAGE_TAG: ${IMAGE_TAG}"

WORKDIR /app

# Copy artifacts (relative to /app)
COPY ${BUILD_FOLDER}/${IMAGE_NAME}-*.jar app.jar
COPY ${BUILD_FOLDER}/libs/ libs/

# Copy and set entrypoint (relative to /app)
COPY entrypoint.sh entrypoint.sh
RUN chmod +x entrypoint.sh

ENTRYPOINT ["./entrypoint.sh"]
