# 使用官方 OpenJDK 17 镜像
FROM openjdk:17-jdk

# 设置工作目录
WORKDIR /app
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

# 暴露端口
EXPOSE 8500

# 启动前检查挂载文件，缺失时快速失败
CMD ["sh", "-c", "PROFILE=${SPRING_PROFILES_ACTIVE:-test}; case \"$PROFILE\" in *,*) echo \"Unsupported comma-separated SPRING_PROFILES_ACTIVE: $PROFILE\"; exit 1 ;; esac; test -f /app/dcjxb-ability-center.jar || { echo 'Missing /app/dcjxb-ability-center.jar'; exit 1; }; test -f /app/application.yml || { echo 'Missing /app/application.yml'; exit 1; }; test -f \"/app/application-${PROFILE}.yml\" || { echo \"Missing /app/application-${PROFILE}.yml\"; exit 1; }; exec java -Xms256m -Xmx512m -Dspring.profiles.active=$PROFILE -jar /app/dcjxb-ability-center.jar --spring.config.location=/app/application.yml,/app/application-${PROFILE}.yml"]
