FHIR Chat · hapiproject/hapi:base Docker file · hapi

Stream: hapi

Topic: hapiproject/hapi:base Docker file


view this post on Zulip Keerthivasan Ramanathan (Aug 12 2020 at 12:37):

Hi, May i know where can i get the Dockerfile for hapiproject/hapi:base?

view this post on Zulip Keerthivasan Ramanathan (Aug 12 2020 at 13:00):

@James Agnew Can you help with this?

view this post on Zulip James Agnew (Aug 12 2020 at 13:14):

https://github.com/hapifhir/hapi-fhir-jpaserver-starter/blob/master/Dockerfile

view this post on Zulip 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?

view this post on Zulip James Agnew (Aug 13 2020 at 13:43):

@Sean McIlvenna this is above my pay grade.. :) do you know?

view this post on Zulip Sean McIlvenna (Aug 13 2020 at 15:05):

yes, I do

view this post on Zulip Sean McIlvenna (Aug 13 2020 at 15:05):

lemme dig it up

view this post on Zulip Sean McIlvenna (Aug 13 2020 at 15:06):

https://github.com/hapifhir/hapi-fhir-jpaserver-starter/blob/master/Dockerfile.base

view this post on Zulip Sean McIlvenna (Aug 13 2020 at 15:06):

@Keerthivasan Ramanathan

view this post on Zulip Keerthivasan Ramanathan (Aug 13 2020 at 15:10):

Wow.. thank you! :+1:

view this post on Zulip Sean McIlvenna (Aug 13 2020 at 15:27):

NP

view this post on Zulip 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"

view this post on Zulip 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"]

view this post on Zulip Jens Villadsen (Aug 14 2020 at 10:29):

@Sean McIlvenna that simplifies the setup and keeps it in a single file

view this post on Zulip 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...

view this post on Zulip Jens Villadsen (Aug 14 2020 at 14:32):

That is possible, yes

view this post on Zulip 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.

view this post on Zulip 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...

view this post on Zulip 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?

view this post on Zulip 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

view this post on Zulip Sean McIlvenna (Aug 14 2020 at 15:15):

docker's caching layer doesn't really apply in a CI build

view this post on Zulip Sean McIlvenna (Aug 14 2020 at 15:15):

but, I don't have a strong preference either way

view this post on Zulip Jens Villadsen (Aug 14 2020 at 15:16):

docker caching does apply to CI

view this post on Zulip Sean McIlvenna (Aug 14 2020 at 15:16):

so, I'll make the change you requested, and update each of the tagged versions

view this post on Zulip Jens Villadsen (Aug 14 2020 at 15:16):

that depends on your CI setup

view this post on Zulip Sean McIlvenna (Aug 14 2020 at 15:16):

every docker CI I've seen doesn't use cache

view this post on Zulip Sean McIlvenna (Aug 14 2020 at 15:17):

granted... that's not many

view this post on Zulip Sean McIlvenna (Aug 14 2020 at 15:17):

azure and docker hub

view this post on Zulip Sean McIlvenna (Aug 14 2020 at 15:17):

they all spawn a fresh vm to build the images

view this post on Zulip Sean McIlvenna (Aug 14 2020 at 15:17):

which don't have any caching history

view this post on Zulip Jens Villadsen (Aug 14 2020 at 15:17):

you can bootstrap your vm with a cache

view this post on Zulip 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

view this post on Zulip Jens Villadsen (Aug 14 2020 at 15:21):

but I'll look into it @Sean McIlvenna and check with my CI goto-guys monday

view this post on Zulip 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

view this post on Zulip Sean McIlvenna (Aug 14 2020 at 15:24):

so, I'm forced to use a manual process as of recent anyways

view this post on Zulip 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

view this post on Zulip 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

view this post on Zulip Sean McIlvenna (Aug 14 2020 at 22:09):

I'll re-enable the CI build in docker hub and see what happens

view this post on Zulip Sean McIlvenna (Aug 14 2020 at 22:27):

hmmm, still seems to be freezing on docker hub builds

view this post on Zulip Jens Villadsen (Aug 15 2020 at 05:55):

Where does it happen?

view this post on Zulip 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