Files
aiot-platform-cloud/docker/Dockerfile.deps
lzh 4223c6b8da
Some checks failed
Java CI with Maven / build (11) (push) Has been cancelled
Java CI with Maven / build (17) (push) Has been cancelled
Java CI with Maven / build (8) (push) Has been cancelled
fix(ci): Docker 构建优化 — 修复 Maven 安装超时、启用 BuildKit、优化层缓存
- Dockerfile.deps/template: 改用阿里云镜像手动安装 Maven,避免 apk maven
  拉入冗余 openjdk25(600MB+)导致构建超时
- Jenkinsfile: 添加 DOCKER_BUILDKIT=1,使层缓存真正生效
- Dockerfile.deps: framework/dependencies 源码在 COPY . . 前单独复制并预编译,
  提升缓存命中率;mvn install 去掉 || true,编译失败立即报错
- .dockerignore: 补充 .git/、docs/、sql/、scripts/ 等目录,构建上下文从
  60MB 降至 ~5MB

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 11:23:44 +08:00

53 lines
3.1 KiB
Docker
Raw 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.

# ============================================
# Maven 依赖基础镜像
# 预下载所有依赖,供服务构建时复用
# ============================================
FROM eclipse-temurin:17-jdk-alpine
# 安装 Maven从阿里云镜像下载避免 apk maven 包拉入冗余 JDK
ARG MAVEN_VERSION=3.9.9
RUN wget -q https://mirrors.aliyun.com/apache/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.tar.gz -O /tmp/maven.tar.gz \
&& tar xzf /tmp/maven.tar.gz -C /opt \
&& ln -s /opt/apache-maven-${MAVEN_VERSION}/bin/mvn /usr/bin/mvn \
&& rm /tmp/maven.tar.gz
WORKDIR /build
# 复制所有 pom 文件
COPY pom.xml .
COPY viewsh-dependencies/pom.xml viewsh-dependencies/
COPY viewsh-framework/pom.xml viewsh-framework/
COPY viewsh-gateway/pom.xml viewsh-gateway/
COPY viewsh-server/pom.xml viewsh-server/
COPY viewsh-module-system/pom.xml viewsh-module-system/
COPY viewsh-module-system/viewsh-module-system-api/pom.xml viewsh-module-system/viewsh-module-system-api/
COPY viewsh-module-system/viewsh-module-system-server/pom.xml viewsh-module-system/viewsh-module-system-server/
COPY viewsh-module-infra/pom.xml viewsh-module-infra/
COPY viewsh-module-infra/viewsh-module-infra-api/pom.xml viewsh-module-infra/viewsh-module-infra-api/
COPY viewsh-module-infra/viewsh-module-infra-server/pom.xml viewsh-module-infra/viewsh-module-infra-server/
COPY viewsh-module-iot/pom.xml viewsh-module-iot/
COPY viewsh-module-iot/viewsh-module-iot-core/pom.xml viewsh-module-iot/viewsh-module-iot-core/
COPY viewsh-module-iot/viewsh-module-iot-api/pom.xml viewsh-module-iot/viewsh-module-iot-api/
COPY viewsh-module-iot/viewsh-module-iot-server/pom.xml viewsh-module-iot/viewsh-module-iot-server/
COPY viewsh-module-iot/viewsh-module-iot-gateway/pom.xml viewsh-module-iot/viewsh-module-iot-gateway/
COPY viewsh-module-ops/pom.xml viewsh-module-ops/
COPY viewsh-module-ops/viewsh-module-ops-api/pom.xml viewsh-module-ops/viewsh-module-ops-api/
COPY viewsh-module-ops/viewsh-module-ops-biz/pom.xml viewsh-module-ops/viewsh-module-ops-biz/
COPY viewsh-module-ops/viewsh-module-environment-biz/pom.xml viewsh-module-ops/viewsh-module-environment-biz/
COPY viewsh-module-ops/viewsh-module-security-biz/pom.xml viewsh-module-ops/viewsh-module-security-biz/
COPY viewsh-module-ops/viewsh-module-facilities-biz/pom.xml viewsh-module-ops/viewsh-module-facilities-biz/
COPY viewsh-module-ops/viewsh-module-service-biz/pom.xml viewsh-module-ops/viewsh-module-service-biz/
COPY viewsh-module-ops/viewsh-module-ops-server/pom.xml viewsh-module-ops/viewsh-module-ops-server/
# 下载所有依赖到本地仓库(部分依赖可能无法离线解析,允许失败)
RUN mvn dependency:go-offline -B || true
# 先单独复制 framework 和 dependencies 源码并预编译(变动频率低,缓存命中率高)
COPY viewsh-dependencies/ viewsh-dependencies/
COPY viewsh-framework/ viewsh-framework/
RUN mvn install -pl viewsh-dependencies,viewsh-framework -am -DskipTests -B -q
# 最后复制全部源码(此层之后的缓存会随源码变动而失效)
COPY . .