FROM liferay/jdk21:latest

# 构建参数
ARG env=pro

# 运行时环境变量
ENV ENVIRONMENT=${env:-pro} \
    TZ=Asia/Shanghai

# 设置时区
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

# 设置工作目录
WORKDIR /app
RUN mkdir logs

# 复制 jar 文件
COPY ./target/gdt-auto.jar app.jar

# 创建非 root 用户
RUN groupadd -r appgroup && useradd -r -g appgroup appuser
USER appuser

ENTRYPOINT ["sh", "-c", "java \
--add-opens java.base/java.lang=ALL-UNNAMED \
--add-opens java.base/java.util=ALL-UNNAMED \
--add-opens java.base/java.lang.reflect=ALL-UNNAMED \
-Dspring.profiles.active=${ENVIRONMENT} \
-jar app.jar"]