FROM eclipse-temurin:17-jre-alpine

LABEL maintainer="weather-data"
LABEL description="Weather Data System - Admin Service"

RUN apk add --no-cache tzdata curl && \
    cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
    echo "Asia/Shanghai" > /etc/timezone

WORKDIR /app

EXPOSE 8080

ARG JAR_FILE=target/system-admin.jar
COPY ${JAR_FILE} /app/app.jar

ENV JAVA_OPTS="-Xms256m -Xmx512m -XX:+UseG1GC -Djava.security.egd=file:/dev/./urandom"
ENV SPRING_PROFILES_ACTIVE=prod

HEALTHCHECK --interval=30s --timeout=10s --retries=3 --start-period=60s \
  CMD curl -f http://localhost:8080/system-admin/actuator/health || exit 1

ENTRYPOINT exec java ${JAVA_OPTS} -jar /app/app.jar
