# Report Service Dockerfile
FROM openjdk:17-slim

# 设置时区
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
    echo 'Asia/Shanghai' > /etc/timezone

# 安装必要工具
RUN apt-get update && apt-get install -y \
    curl \
    vim \
    && rm -rf /var/lib/apt/lists/*

# 创建应用目录
RUN mkdir -p /app && mkdir -p /data/exports

# 设置工作目录
WORKDIR /app

# 复制构建产物
COPY target/report-service-1.0.0-SNAPSHOT.jar /app/report-service.jar

# 设置环境变量
ENV JAVA_OPTS="-Xms512m -Xmx1024m -XX:+UseG1GC"
ENV EXPORT_BASE_PATH="/data/exports"
ENV SPRING_PROFILES_ACTIVE=prod

# 暴露端口
EXPOSE 8084

# 健康检查
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
    CMD curl -f http://localhost:8084/actuator/health || exit 1

# 启动命令
ENTRYPOINT ["sh", "-c", "java $JAVA_OPTS -jar /app/report-service.jar"]
