Starting from the end of the month, Heroku will dismiss its free tier, so I'm looking for a way to deploy my Java apps elsewhere, namely on Render. Render doesn't support Java natively like Heroku does, but support Docker which should be fine even if I have little to no experience with it.
So, let's begin. I've created a MVP with Quarkus and pushed everything on GitHub. Quarkus comes with the following preconfigured Dockerfile.
FROM registry.access.redhat.com/ubi8/openjdk-17:1.14
ENV LANGUAGE='en_US:en'
COPY --chown=185 target/quarkus-app/lib/ /deployments/lib/
COPY --chown=185 target/quarkus-app/*.jar /deployments/
COPY --chown=185 target/quarkus-app/app/ /deployments/app/
COPY --chown=185 target/quarkus-app/quarkus/ /deployments/quarkus/
EXPOSE 8080
USER 185
ENV JAVA_OPTS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
ENV JAVA_APP_JAR="/deployments/quarkus-run.jar"
Then, I've created a new Render project, connecting the GitHub repo and specifying the custom path for the Dockerfile (./src/main/docker/Dockerfile.jvm
).
After that, the build started and failed shorty after with the following error:
error: failed to solve: failed to compute cache key: failed to calculate checksum of ref ybv5ya8wywl2vxh03tp4kiw9y::xq421txz9uzdcqymi3ygmk6xb: failed to walk /home/user/.local/tmp/buildkit-mount4168277661/target/quarkus-app: lstat /home/user/.local/tmp/buildkit-mount4168277661/target/quarkus-app: no such file or directory
I'm unsure on what that does exactly mean.
I feel the problem is that it expects to find something in the target
dir, which doesn't exists because I never did something like ./mvnw package
anywhere in the Dockerfile.
Therefore, on a second attempt, I've added the following line
RUN ./mvnw package
in the Dockerfile, just before those four COPY
lines, but the issue persists so maybe I'm off track.
Any help on how can I fix this?
CodePudding user response:
The Dockerfile shipped with the Quarkus Quickstart assumes you already have compiled your sources.
In order to compile the sources in the container, I had to change my Dockerfile as listed here.
Also, it's important to remove that *
from the .dockerignore
file.