Build a shared maven repository running on a docker container and being used by Grails based instances

5/20/2020

I am deploying my web application based on grails 2.5.x to Kubernetes. The application is started by using grails wrapper. Below is the partial content of Dockerfile.

COPY --chown=$USERNAME:$USERNAME . $APP_HOME

# Change to the app user.
USER $USERNAME
WORKDIR $APP_HOME
RUN ["chmod", "+x", "grailsw"]
ENTRYPOINT ["/bin/bash", "-lc", "./grailsw prod run-app --non-interactive --stacktrace"]

Because of the complexity and largeness of the application, now it takes about 25 minutes to complete deployment to K8s. It is much longer then the traditional deployment which goes with war file and uploading it to Tomcat web server.

My approaches are

  1. Is this possible to speed deployment by sharing the same maven repository accommodated inside another container? Going this route, I have put <localRepository>${user.home}/devtools/m2repo</localRepository> to ~/.m2/settings.xml, however, my Grails 2.5.5 application still loads libraries from ~/.m2/repository. I guessed there is a conflict in the integration Grails and maven.
  2. Could we build a docker base image containing the majority of the latest dependencies? Then, using this base image to build an docker image for the application. What are benefits and drawbacks if going this approach?

Many thanks guys for discussion on this topic!

-- Tung
dependencies
docker
grails
kubernetes
maven

0 Answers