基於Java11最小化Spring Boot 2 的Docker映象檔案配置
使用Jigsaw模組, Dockerfile配置如下:
FROM alpine:3.8 AS builder WORKDIR /opt ARG JDK_TAR=openjdk-11+28_linux-x64-musl_bin.tar.gz ARG JDK_DOWNLOAD_PREFIX=https://download.java.net/java/early_access/alpine/28/binaries RUN wget -q "$JDK_DOWNLOAD_PREFIX/$JDK_TAR" && \ wget -q "$JDK_DOWNLOAD_PREFIX/$JDK_TAR.sha256" RUN cat $JDK_TAR.sha256 | xargs -I{} echo "{} $JDK_TAR" | sha256sum -c - && \ tar zxf "$JDK_TAR" && \ ln -s jdk-11 java && \ rm -f "$JDK_TAR" "$JDK_TAR.sha256" ENV JAVA_HOME=/opt/java ENV PATH="$PATH:$JAVA_HOME/bin" WORKDIR /root/dev ENV GRADLE_USER_HOME=/root/dev/.cache RUN mkdir -p /root/dev/.cache COPY build.gradle gradlew gradlew.bat settings.gradle gradle.properties /root/dev/ COPY gradle /root/dev/gradle RUN ./gradlew --no-daemon --refresh-dependencies --version COPY src ./src RUN ./gradlew --no-daemon build # Make sure only 1 jar file is assembled RUN test $(find ./build/libs -type f -name '*.jar' | wc -l) -eq 1 RUN jlink \ --verbose \ --module-path "$JAVA_HOME/jmods" \ --add-modules java.base,java.logging,java.xml,jdk.unsupported,java.sql,java.naming,java.desktop,java.management,java.security.jgss,java.instrument,jdk.management \ --compress 2 \ --no-header-files \ --no-man-pages \ --strip-debug \ --output /opt/jre FROM alpine:3.8 WORKDIR /usr/src/app ENV JAVA_HOME=/opt/jre ENV LANG=C.UTF-8 ENV PATH="$PATH:$JAVA_HOME/bin" ENV APP_TIMEZONE=UTC COPY --from=builder /opt/jre /opt/jre COPY --from=builder /root/dev/build/libs/*.jar dagger.jar COPY newrelic/newrelic.jar newrelic/newrelic.yml ./ EXPOSE 80 CMD ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "dagger.jar"] |
build.gradle配置點選標題見原文。
相關文章
- Spring Boot 配置檔案Spring Boot
- 基於Spring Boot 2.3以上版本方便建立分層Docker映象Spring BootDocker
- Spring Boot 建立 Docker 映象Spring BootDocker
- 結合SpEL使用@Value-基於配置檔案或非配置的檔案的值注入-Spring BootSpring Boot
- Docker配置檔案配置映象加速器Docker
- Spring Boot的配置檔案管理技巧Spring Boot
- spring boot基於Java的容器配置Spring BootJava
- spring boot配置檔案相關Spring Boot
- Spring Boot 配置檔案總結Spring Boot
- Spring Boot @PropertySource 載入指定配置檔案、@ImportResource 匯入Spring 配置檔案Spring BootImport
- 精進 Spring Boot 03:Spring Boot 的配置檔案和配置管理,以及用三種方式讀取配置檔案Spring Boot
- 基於 Docker 映象部署 go 專案DockerGo
- Spring Boot + MYSQL + Docker的配置 - DEVSpring BootMySqlDockerdev
- Spring Boot讀取配置檔案的幾種方式Spring Boot
- spring cloud+spring boot 電子商務spring boot獲取配置檔案的屬性CloudSpring Boot
- Spring Boot入門(一):使用IDEA建立Spring Boot專案並使用yaml配置檔案Spring BootIdeaYAML
- Spring Boot EL獲取配置檔案中的值的方式Spring Boot
- Spring boot學習(二) Spring boot基礎配置Spring Boot
- Dragonfly 基於 P2P 的檔案和映象分發系統Go
- Spring Boot第二彈,配置檔案怎麼造?Spring Boot
- spring boot 打war包後沒有配置檔案Spring Boot
- Spring Boot的檔案上傳Spring Boot
- docker 配置檔案Docker
- 使用 Docker 部署 Spring Boot 專案DockerSpring Boot
- 使用Docker部署Spring Boot專案DockerSpring Boot
- Spring Boot 框架中配置檔案 application.properties 當中的所有配置大全Spring Boot框架APP
- Idea下構建基於Gradle的Spring Boot專案IdeaGradleSpring Boot
- 正確映象檔案配置
- 基於Spring Batch的Spring Boot的教程 - BaeldungBATSpring Boot
- Spring Boot加密應用配置檔案敏感資訊(jasypt)Spring Boot加密
- Spring Boot、Nacos配置檔案properties、yml、yaml的優先順序Spring BootYAML
- spring-boot-route(二)讀取配置檔案的幾種方式Springboot
- 基於cloudflare workers自建docker映象CloudDocker
- 基於Jenkins自動化部署spring boot專案JenkinsSpring Boot
- 構建第一個基於 Gradle 的 Spring Boot 專案GradleSpring Boot
- 在Docker中部署Spring Boot專案DockerSpring Boot
- Spring Boot:Spring Boot配置MybatisSpring BootMyBatis
- Spring Boot:Spring Boot配置SwaggerSpring BootSwagger