Skip to content

Multistage dockerFile #1733

@bramlihamza

Description

@bramlihamza

Hi, thank you for the fast response.

I want to reproduce some think like this .

# First stage:  **build environment**
FROM maven:3.5.0-jdk-8-alpine **AS builder**

# add pom.xml and source code
ADD ./pom.xml pom.xml
ADD ./src src/

# package jar
RUN mvn clean package

# Second **stage: minimal runtime environment**
From openjdk:8-jre-alpine

# copy jar from the first stage
COPY **--from=builder** target/my-app-1.0-SNAPSHOT.jar my-app-1.0-SNAPSHOT.jar

EXPOSE 8080

CMD ["java", "-jar", "my-app-1.0-SNAPSHOT.jar"]

So I want to create a first stage to build the project, then create a second stage to copy the artifact from the first stage and run it.

I tried to do this, but I was blocked in the second stage.

 new DockerFileBuilder()
        .basedir("/")
        .baseImage("**maven:3.5.0-jdk-8-alpine** ### **AS** **builder**")
        .expose(Collections.singletonList("8080"))
			/////
			/////
        .entryPoint(a)
        
        
        .write(javaProject.getWorkDir().toFile());

thank you .

Originally posted by @bramlihamza in #1708 (reply in thread)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @bramlihamza

      Issue actions

        Multistage dockerFile · Issue #1733 · eclipse-jkube/jkube