Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dockerBuild fails for Apple silliconMac #794

Closed
sdelamo opened this issue Aug 4, 2023 · 13 comments · Fixed by #862
Closed

dockerBuild fails for Apple silliconMac #794

sdelamo opened this issue Aug 4, 2023 · 13 comments · Fixed by #862
Labels
info: workaround available A workaround is available for the issue type: bug Something isn't working

Comments

@sdelamo
Copy link
Contributor

sdelamo commented Aug 4, 2023

Generate an app with the defaults.

./gradlew dockerBuild

> Task :dockerfile
Dockerfile written to: /Users/sdelamo/Downloads/dockertest/build/docker/main/Dockerfile

> Task :dockerBuild
Building image using context '/Users/sdelamo/Downloads/dockertest/build/docker/main'.
Using Dockerfile '/Users/sdelamo/Downloads/dockertest/build/docker/main/Dockerfile'
Using images 'demo'.
Step 1/8 : FROM openjdk:17-alpine

> Task :dockerBuild FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':dockerBuild'.
> Could not build image: no matching manifest for linux/arm64/v8 in the manifest list entries

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to https://docs.gradle.org/8.2.1/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.

BUILD FAILED in 5s
6 actionable tasks: 6 executed

Environment Information

Operating system: MacOS Ventura
Architecture: Apple Silicon Mac
Micronaut Gradle Plugin 4.0.2

Example Application

No response

Version

4.0.2

@sdelamo sdelamo added the type: bug Something isn't working label Aug 4, 2023
@alvarosanchez
Copy link
Member

The default base image we use is not multi-platform.

We should change the default to eclipse-temurin:17-jre

@sdelamo
Copy link
Contributor Author

sdelamo commented Aug 4, 2023

The workaround would be to run dockerfile

copy the Dockerfile from build/docker/main/Dockerfile to the root of the project and replace:

FROM openjdk:17-alpine
WORKDIR /home/app
COPY layers/libs /home/app/libs
COPY layers/classes /home/app/classes
COPY layers/resources /home/app/resources
COPY layers/application.jar /home/app/application.jar
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "/home/app/application.jar"]

with:

FROM eclipse-temurin:17-jre
WORKDIR /home/app
COPY layers/libs /home/app/libs
COPY layers/classes /home/app/classes
COPY layers/resources /home/app/resources
COPY layers/application.jar /home/app/application.jar
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "/home/app/application.jar"]

@sdelamo sdelamo added the info: workaround available A workaround is available for the issue label Aug 4, 2023
@alvarosanchez
Copy link
Member

That's a brute-force workaround 😅 . You can simply do

tasks.named("dockerfile") {
    baseImage = 'eclipse-temurin:17-jre'
}

@sdelamo
Copy link
Contributor Author

sdelamo commented Aug 4, 2023

it does not work:

Could not determine the dependencies of task ':dockerBuild'.
> Could not create task ':dockerfile'.
   > Could not set unknown property 'baseImage' for task ':dockerfile' of type com.bmuschko.gradle.docker.tasks.image.Dockerfile.

@sdelamo
Copy link
Contributor Author

sdelamo commented Aug 4, 2023

it seems the config is:


tasks.named("dockerfile") {
    from 'eclipse-temurin:17-jre'
}

but the generated Dockerfile is incorrect.

it generates:

FROM openjdk:17-alpine
WORKDIR /home/app
COPY layers/libs /home/app/libs
COPY layers/classes /home/app/classes
COPY layers/resources /home/app/resources
COPY layers/application.jar /home/app/application.jar
EXPOSE 8080
FROM eclipse-temurin:17-jre
ENTRYPOINT ["java", "-jar", "/home/app/application.jar"]

@alvarosanchez
Copy link
Member

image

Pretty sure this worked in Micronaut 3. Perhaps the documentation is left behind @melix ?

@melix
Copy link
Collaborator

melix commented Aug 4, 2023

mmm, we do have baseImage :

but it seems that here the task type is the Docker plugin docker file, not ours 🤔, so I think it doesn't work because you still have a Dockerfile at the root.

@sdelamo
Copy link
Contributor Author

sdelamo commented Aug 4, 2023

Yeah, this works:

tasks.named("dockerfile") {
    baseImage = "eclipse-temurin:17-jre"
}

and setting the Dockerfile in the project root works as well.

I think we should change the base image to improve the user experience.

@melix
Copy link
Collaborator

melix commented Aug 4, 2023

There are many problems reported with Alpine in any case, so changing the base image makes sense to me. I don't have the context why this was chosen in the first place.

@alvarosanchez
Copy link
Member

Alpine became famous because it had small containers compared to that of the full distros.

But perhaps nowadays the situation is different. In fact, 17-jre is smaller than 17-alpine.

@sdelamo
Copy link
Contributor Author

sdelamo commented Aug 17, 2023

+1 for having a default base image with multi-platform support.

@joaquindiez
Copy link

I add this to my build.gradle.kts

tasks.named<io.micronaut.gradle.docker.MicronautDockerfile>("dockerfile") { baseImage.set( "eclipse-temurin:17-jre") }

and it is working in version 4.1.0

if this base image it the recomendend for multi-platform support I vote for having it as default base image

@joaquindiez
Copy link

But the above is not working when executing optimizedDockerBuild

`Step 1/8 : FROM openjdk:17-alpine

Task :app:optimizedDockerBuild FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:optimizedDockerBuild'.

Could not build image: no matching manifest for linux/arm64/v8 in the manifest list entries
`

melix added a commit that referenced this issue Nov 7, 2023
This is to fix Docker builds on Apple Silicon.

Fixes #794
@melix melix closed this as completed in #862 Nov 7, 2023
melix added a commit that referenced this issue Nov 7, 2023
This is to fix Docker builds on Apple Silicon.

Fixes #794
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info: workaround available A workaround is available for the issue type: bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants