We build docker images with tomcat services within our CI as follows:
- PLATFORMS: linux/amd64,linux/arm64/v8
- gradle build …
# Switch to use different docker driver which supports multiplatform builds
- docker buildx create --use
- docker buildx build --push --platform=$PLATFORMS -t $image -f infra/Dockerfile .
This works and pushes the image which can easily be run on linux/amd64 platforms.
However when running this image on Apple Silicon, it fails with:
org.apache.catalina.startup.ContextConfig
Failed to detect ServletContainerInitializers for context with name [] service
java.net.MalformedURLException: no !/ found in url spec:file:/usr/local/tomcat/lib/tomcat-websocket.jar!/META-INF/services/javax.servlet.ServletContainerInitializer
Full stack trace here: https://gist.github.com/knyttl/c8f2c24ac3d94a91911ca08f08eff668
What surprises me a bit is:
org.apache.catalina.startup.VersionLoggerListener Architecture: amd64
I guess the architecture should be linux/arm64/v8
, so why does it run the wrong one?
In the end, I abandoned the CI way of building M1 images.
Instead, I have written a bash script (to be run locally on M1) which extracts the CI-built image and rebuilds an M1 image with the CI-built image contents. Not exactly nice, but it works.