Skip to content

Commit

Permalink
Fix empty RUN command (#757)
Browse files Browse the repository at this point in the history
Fixes #756
  • Loading branch information
melix authored Jun 30, 2023
1 parent b35f563 commit c0e0f27
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ private void setupInstructions(List<Instruction> additionalInstructions) {
if (baseImageProvider.get().getImage().contains("alpine-glibc")) {
return "apk --no-cache update && apk add libstdc++";
}
return "";
return null;
}));
exposePort(getExposedPorts());
getInstructions().addAll(additionalInstructions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -778,5 +778,44 @@ ENTRYPOINT ["java", "-jar", "/home/app/application.jar"]

}

@Issue("https://github.com/micronaut-projects/micronaut-gradle-plugin/issues/756")
def "should not generate empty RUN command"() {
given:
settingsFile << "rootProject.name = 'hello-world'"
buildFile << """
plugins {
id "io.micronaut.minimal.application"
id "io.micronaut.docker"
id "io.micronaut.graalvm"
}
micronaut {
version "3.4.0"
runtime "netty"
}
$repositoriesBlock
application {
mainClass.set("com.example.Application")
}
tasks.named("dockerfileNative") {
baseImage('ubuntu:22.04')
instruction 'RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*'
instruction 'HEALTHCHECK CMD curl -s localhost:8080/endpoints/health | grep \\'"status":"UP"\\''
}
"""

when:
def result = build('dockerfileNative')
def dockerFileNative = new File(testProjectDir.root, 'build/docker/native-main/DockerfileNative').readLines('UTF-8')
def emptyRunLines = dockerFileNative.findAll { it == "RUN " }

then:
emptyRunLines.isEmpty()
}

}

0 comments on commit c0e0f27

Please sign in to comment.