0

I am trying to overwrite the entire bmuschko generated Dockerfile in my Gradle script. However, all I can seem to do it just append to the bottom of it. I have a custom Dockerfile that I want to use, but using the plugin (com.bmuschko.docker-spring-boot-application:6.1.2) overwrites it. I have tried adding a new entrypoint, instruction, and instructionsFromTemplate, but all these do is append them to the bottom of the generated file:

https://bmuschko.github.io/gradle-docker-plugin/api/com/bmuschko/gradle/docker/tasks/image/Dockerfile.html

tasks.withType<Dockerfile> {
    instructionsFromTemplate("src/main/resources/Dockerfile")
    entryPoint("top", "-b")
    instruction("FROM azul/zulu-openjdk-centos:latest")
}

Have also tried:

tasks.withType<DockerBuildImage> {
    dockerFile.set(File("src/main/resources/Dockerfile"))
}

gw dockerBuildImage says that it is actually using my Dockerfile, but then throws an error:

Using Dockerfile '/Users/meanwhileinhell/my-app/src/main/resources/Dockerfile'
Using images 'com.meanwhileinhell.app/meanwhileinhell-server:1.0.0-snapshot'.

Error during callback
com.github.dockerjava.api.exception.InternalServerErrorException: Cannot locate specified Dockerfile: /Users/meanwhileinhell/my-app/src/main/resources/Dockerfile
        at com.github.dockerjava.jaxrs.filter.ResponseStatusExceptionFilter.filter(ResponseStatusExceptionFilter.java:59)
        at com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.client.ClientFilteringStages$ResponseFilterStage.apply(ClientFilteringStages.java:133)
        at com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.client.ClientFilteringStages$ResponseFilterStage.apply(ClientFilteringStages.java:121)
        at com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.process.internal.Stages.process(Stages.java:171)
        at com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:283)
        at com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.client.JerseyInvocation.lambda$invoke$1(JerseyInvocation.java:767)
        at com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.internal.Errors.process(Errors.java:316)
        at com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.internal.Errors.process(Errors.java:298)
        at com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.internal.Errors.process(Errors.java:229)
        at com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:414)
        at com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:765)
        at com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:456)
        at com.bmuschko.gradle.docker.shaded.org.glassfish.jersey.client.JerseyInvocation$Builder.post(JerseyInvocation.java:357)
        at com.github.dockerjava.jaxrs.async.POSTCallbackNotifier.response(POSTCallbackNotifier.java:29)
        at com.github.dockerjava.jaxrs.async.AbstractCallbackNotifier.call(AbstractCallbackNotifier.java:50)
        at com.github.dockerjava.jaxrs.async.AbstractCallbackNotifier.call(AbstractCallbackNotifier.java:24)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)

The Dockerfile it says it cannot locate, is exactly in the location it says it can't find it.

How do I completely overwrite this file?

MeanwhileInHell
  • 6,780
  • 17
  • 57
  • 106
  • Normally you rely on extensions to customize your image: is https://bmuschko.github.io/gradle-docker-plugin/api/com/bmuschko/gradle/docker/DockerSpringBootApplication.html really not enough? – Alex Apr 28 '21 at 10:53

2 Answers2

0

try to use

tasks.withType<DockerBuildImage> {
    inputDir.set(file("src/main/resources/"))
}
KnockKnock
  • 123
  • 2
  • 11
0

I did the following:

dockerCreateDockerfile.doLast { 
    copy {
        from 'docker/Dockerfile'
        into dockerSyncBuildContext.destinationDir
    }
}