简体   繁体   English

如何在 IDE 中的 docker 镜像中在 Intellij IDEA 中构建 spring boot 应用程序?

[英]How to build spring boot app in Intellij IDEA in a docker image within the IDE?

I need to replicate the build in our CI/CD tool in the dev workstations of the developers by making Intellij IDEA build within a docker container instead of the current system.我需要通过在 docker 容器而不是当前系统中构建 Intellij IDEA 来在开发人员的开发工作站中复制我们的 CI/CD 工具中的构建。 Is this doable?这可行吗? I find similar threads with launching the app inside (that i don't need), i need it only as a build environment.我发现在内部启动应用程序时有类似的线程(我不需要),我只需要它作为构建环境。 I already have the Docker plugin installed but i fail to see how to make it as a build environment.我已经安装了 Docker 插件,但我看不出如何将其作为构建环境。

I have installed the docker plugin, prepared the image.我已经安装了 docker 插件,准备了图像。 I have docker installed on the workstation.我在工作站上安装了 docker。

You are expecting something like this?你期待这样的事情吗?

FROM eclipse-temurin:17-jdk-alpine as build
WORKDIR /workspace/app

COPY mvnw .
COPY .mvn .mvn
COPY pom.xml .
COPY src src

RUN ./mvnw package -DskipTests

FROM eclipse-temurin:17-jdk-alpine
ARG JAR_FILE=target/*.jar
VOLUME /tmp
ARG DEPENDENCY=/workspace/app/target/dependency
COPY --from=build  /workspace/app/${JAR_FILE} /app/
ENTRYPOINT ["sh", "-c", "java ${JAVA_OPTS} -jar /app.jar ${0} ${@}"]

You can use the maven container as a build container to save maven installation time in case it takes.您可以将 maven 容器用作构建容器,以节省 maven 安装时间,以备不时之需。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM