Files
java-template/docker/base-images/Dockerfile.java-maven-base
2025-11-28 13:49:45 +08:00

37 lines
961 B
Docker
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Java Maven 基础镜像 - 只需构建一次
# 用途:避免每次业务构建都 apk add maven
FROM eclipse-temurin:21-jdk-alpine
LABEL maintainer="[email protected]"
LABEL description="Java 21 + Maven 基础镜像,用于加速业务镜像构建"
# 一次性安装 Maven 和常用工具
RUN apk add --no-cache \
maven \
tzdata \
curl \
bash \
&& ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& echo "Asia/Shanghai" > /etc/timezone
# 配置 Maven settings.xml(使用 Maven Central)
RUN mkdir -p /root/.m2 && \
cat > /root/.m2/settings.xml <<'EOF'
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<localRepository>/root/.m2/repository</localRepository>
<!-- 使用 Maven Central 官方仓库,无需额外镜像配置 -->
</settings>
EOF
WORKDIR /build
# 验证安装
RUN mvn --version && java --version
# 元数据
ARG BUILD_DATE
ARG VERSION
LABEL build-date=$BUILD_DATE
LABEL version=$VERSION