spring-petclinic / spring-petclinic-microservices

Distributed version of Spring Petclinic built with Spring Cloud
Apache License 2.0
1.7k stars 2.18k forks source link

Support for Docker and Podman build on mac silicon (ARM) #242

Closed zubcevic closed 11 months ago

zubcevic commented 11 months ago

This makes it possible to run the container builds on MacOS with silicon chips as well as other platforms that have either podman or docker installed.

To use: unchanged: ./mvnw clean install -PbuildDocker

or if you prefer podman: ./mvnw clean install -PbuildDocker -Dcontainer.executable=podman

zubcevic commented 11 months ago

180

arey commented 11 months ago

Thank you for your contribution René

arey commented 11 months ago

Hi @zubcevic

I recovered these changes. Building docker image on my Intel Macbook and Docker Machine is working. But I've got the follwing error while starting the discovery-server

arey:~$docker-compose up                 
grafana-server is up-to-date
prometheus-server is up-to-date
config-server is up-to-date
tracing-server is up-to-date
Starting discovery-server ... error

ERROR: for discovery-server  Cannot start service discovery-server: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "./dockerize": stat ./dockerize: no such file or directory: unknown

Do you have any idea?

Image build is successful with the exec-maven-plugin:

mvn clean install -P buildDocker -X
[DEBUG] Executing command line: [docker, build, -f, Dockerfile, --build-arg, ARTIFACT_NAME=spring-petclinic-discovery-server-3.0.9, --build-arg, EXPOSED_PORT=8761, --build-arg, DOCKERIZE_VERSION=v0.6.1, -t, springcommunity/spring-petclinic-discovery-server, /Users/arey/Dev/GitHub/spring-petclinic/spring-petclinic-microservices/spring-petclinic-discovery-server/target]
time="2023-12-22T19:04:53+01:00" level=warning msg="No output specified for docker-container driver. Build result will only remain in the build cache. To push result image into registry use --push or to load image into docker use --load"
#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 951B 0.0s done
#1 DONE 0.0s
...
...
#15 [stage-1 7/7] COPY --from=builder application/application/ ./
#15 DONE 0.0s
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------

With the docker images command line I detect my local Docker image has not been build.

If I return to the docker-maven-plugin build I can see the image hash and the image tag:

...
 ---> 1689d15fa2a2
Step 20/20 : ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]

 ---> Running in 31249573a91a
Removing intermediate container 31249573a91a
 ---> 2e778a7379c2
ProgressMessage{id=null, status=null, stream=null, error=null, progress=null, progressDetail=null}
Successfully built 2e778a7379c2
Successfully tagged springcommunity/spring-petclinic-discovery-server:latest
[INFO] Built springcommunity/spring-petclinic-discovery-server
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
$docker --version
Docker version 20.10.11, build dea9396

Maybe adding a --load flag

arey:~$docker build -f ../docker/Dockerfile --load --build-arg ARTIFACT_NAME=spring-petclinic-discovery-server-3.0.9 --build-arg EXPOSED_PORT=8761 --build-arg DOCKERIZE_VERSION=v0.6.1 -t springcommunity/spring-petclinic-discovery-server /Users/arey/Dev/GitHub/spring-petclinic/spring-petclinic-microservices/spring-petclinic-discovery-server/target
arey commented 11 months ago

Fixed by https://github.com/spring-petclinic/spring-petclinic-microservices/pull/246