I am trying to set up a Docker container that builds and runs a small application. This is my Dockerfile:
#####################
# build the jar
#####################
FROM gradle:jdk11 as builder
COPY --chown=gradle:gradle application /application
WORKDIR /application
RUN gradle build
#####################
# run the app
#####################
# Use this on a non-arm machine
# FROM openjdk:11
# Use this on an arm machine, such as a raspberry pi
FROM arm32v7/adoptopenjdk:11
EXPOSE 8080
COPY --from=builder /application/build/libs/myjar.jar .
WORKDIR /
CMD java -jar ./myjar.jar
docker build -t myimage .
works without problems on my personal machine (a Macbook Pro). If I try to build the image on a Raspberry Pi 4B (which is ultimately the goal), it hangs at the RUN gradle build
step and never completes.
This is my terminal output:
pi@raspberrypi:~/development/my_test $ docker build -t test .
Sending build context to Docker daemon 15.92MB
Step 1/9 : FROM gradle:jdk11 as builder
---> 0924090a3770
Step 2/9 : COPY --chown=gradle:gradle application /application
---> Using cache
---> b702fc76b9cb
Step 3/9 : WORKDIR /application
---> Using cache
---> dbc2aac75c7c
Step 4/9 : RUN gradle --no-daemon build
---> Running in faec45c6cf01
OpenJDK Server VM warning: No monotonic clock was available - timed services may be adversely affected if the time-of-day clock changes
And that's it. Nothing further happens.
At first, I had ignored the OpenJDK warning since I had seen it with other images and had no problems running them. After every other option failed, I started to suspect it might be the culprit. How can this be resolved?