Stream: hapi
Topic: hapiproject/hapi:base Docker file
Keerthivasan Ramanathan (Aug 12 2020 at 12:37):
Hi, May i know where can i get the Dockerfile for hapiproject/hapi:base?
Keerthivasan Ramanathan (Aug 12 2020 at 13:00):
@James Agnew Can you help with this?
James Agnew (Aug 12 2020 at 13:14):
https://github.com/hapifhir/hapi-fhir-jpaserver-starter/blob/master/Dockerfile
Keerthivasan Ramanathan (Aug 13 2020 at 06:09):
Thanks @James Agnew I have this one. It pulls another image, the base : FROM hapiproject/hapi:base as build-hapi
Do we have access to that base image's docker file?
James Agnew (Aug 13 2020 at 13:43):
@Sean McIlvenna this is above my pay grade.. :) do you know?
Sean McIlvenna (Aug 13 2020 at 15:05):
yes, I do
Sean McIlvenna (Aug 13 2020 at 15:05):
lemme dig it up
Sean McIlvenna (Aug 13 2020 at 15:06):
https://github.com/hapifhir/hapi-fhir-jpaserver-starter/blob/master/Dockerfile.base
Sean McIlvenna (Aug 13 2020 at 15:06):
@Keerthivasan Ramanathan
Keerthivasan Ramanathan (Aug 13 2020 at 15:10):
Wow.. thank you! :+1:
Sean McIlvenna (Aug 13 2020 at 15:27):
NP
Jens Villadsen (Aug 14 2020 at 08:00):
May I suggest that you convert those docker images into multistage build in a single Dockerfile ... @Sean McIlvenna - the current design of having ":base" separate makes it quite hard to bump the version of ":base"
Jens Villadsen (Aug 14 2020 at 10:20):
eg. something like this:
FROM ubuntu as build-hapi
ENV PATH="/tmp/apache-maven-3.6.0/bin:${PATH}"
ENV TZ=Etc/UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
WORKDIR /tmp
RUN apt-get update && \
apt-get install git -y && \
apt-get install sed -y && \
apt-get install wget -y && \
apt-get install openjdk-11-jdk -y
RUN wget https://downloads.apache.org/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz && tar xzf apache-maven-3.6.3-bin.tar.gz
RUN export PATH=/tmp/apache-maven-3.6.3/bin:${PATH}
WORKDIR /tmp/hapi-fhir-jpaserver-starter
COPY . .
RUN /tmp/apache-maven-3.6.3/bin/mvn clean install -DskipTests
FROM tomcat:9-jre11
RUN mkdir -p /data/hapi/lucenefiles && chmod 775 /data/hapi/lucenefiles
COPY --from=build-hapi /tmp/hapi-fhir-jpaserver-starter/target/*.war /usr/local/tomcat/webapps/
EXPOSE 8080
CMD ["catalina.sh", "run"]
Jens Villadsen (Aug 14 2020 at 10:29):
@Sean McIlvenna that simplifies the setup and keeps it in a single file
Frank Oemig (Aug 14 2020 at 13:48):
Is there a way to separate download and compilation from creating docker images? In the end only the war files afe needed...
Jens Villadsen (Aug 14 2020 at 14:32):
That is possible, yes
Sean McIlvenna (Aug 14 2020 at 15:10):
@Jens Villadsen why do you need to bump the version of base? I use :base because those dependencies never really change, and it adds extra time to the build process for the hapi image.
Sean McIlvenna (Aug 14 2020 at 15:11):
@Frank Oemig anyone can run mvn install
at any time to compile it on their own, without using Docker...
Frank Oemig (Aug 14 2020 at 15:14):
Yes, thx, I know, this is what I am doing and running. Just thinking about dockerization from that point onwards. Is a Dockerfile somewhere available?
Jens Villadsen (Aug 14 2020 at 15:14):
@Sean McIlvenna Docker caches those layers - as you mention they rarely change. And if they actually do, you would have a problem as your version is called 'base', hence it is VERY hard to know whether your cache is stale or not. Combining it to a multistage build takes advantages of the docker caching layer at keeps the file to a single version
Sean McIlvenna (Aug 14 2020 at 15:15):
docker's caching layer doesn't really apply in a CI build
Sean McIlvenna (Aug 14 2020 at 15:15):
but, I don't have a strong preference either way
Jens Villadsen (Aug 14 2020 at 15:16):
docker caching does apply to CI
Sean McIlvenna (Aug 14 2020 at 15:16):
so, I'll make the change you requested, and update each of the tagged versions
Jens Villadsen (Aug 14 2020 at 15:16):
that depends on your CI setup
Sean McIlvenna (Aug 14 2020 at 15:16):
every docker CI I've seen doesn't use cache
Sean McIlvenna (Aug 14 2020 at 15:17):
granted... that's not many
Sean McIlvenna (Aug 14 2020 at 15:17):
azure and docker hub
Sean McIlvenna (Aug 14 2020 at 15:17):
they all spawn a fresh vm to build the images
Sean McIlvenna (Aug 14 2020 at 15:17):
which don't have any caching history
Jens Villadsen (Aug 14 2020 at 15:17):
you can bootstrap your vm with a cache
Jens Villadsen (Aug 14 2020 at 15:20):
quick google search: https://dev.to/pst418/speed-up-multi-stage-docker-builds-in-ci-cd-with-buildkit-s-registry-cache-11gi
Jens Villadsen (Aug 14 2020 at 15:21):
but I'll look into it @Sean McIlvenna and check with my CI goto-guys monday
Sean McIlvenna (Aug 14 2020 at 15:24):
np. we were using the docker hub's CI, but I stopped yesterday because docker hub seems to freeze whenever building hapi
Sean McIlvenna (Aug 14 2020 at 15:24):
so, I'm forced to use a manual process as of recent anyways
Sean McIlvenna (Aug 14 2020 at 18:15):
@Jens Villadsen base image is removed and all tags in docker hub have been updated to use your suggested Dockerfile
Jens Villadsen (Aug 14 2020 at 18:59):
Fyi: the base image "froze" during build because the jdk requires a timezone set. Thats the reason for https://github.com/hapifhir/hapi-fhir-jpaserver-starter/blob/af6bd69db027c6632283d03947a1b3ac4eeac4d7/Dockerfile#L6
Sean McIlvenna (Aug 14 2020 at 22:09):
I'll re-enable the CI build in docker hub and see what happens
Sean McIlvenna (Aug 14 2020 at 22:27):
hmmm, still seems to be freezing on docker hub builds
Jens Villadsen (Aug 15 2020 at 05:55):
Where does it happen?
Jens Villadsen (Aug 15 2020 at 20:56):
Frank Oemig said:
Is there a way to separate download and compilation from creating docker images? In the end only the war files afe needed...
With https://github.com/hapifhir/hapi-fhir-jpaserver-starter/pull/124 - the entire fetchning of maven dependencies is cached as long as you don't change the pom. Change the rest of the sources all you want and the build will still be way more speedy ;)
Last updated: Apr 12 2022 at 19:14 UTC