Home / DevOps / Deploying a Grails App in a standalone Tomcat Docker container

Deploying a Grails App in a standalone Tomcat Docker container

Print Friendly, PDF & Email

Recently, I have written the post to keep how to dockerise Grails apps with an embedded Tomcat. However, we are entirely able to run Grails apps in a standalone Tomcat, particularly deployed in Kubernetes or Docker environment. In this post, we continue working around the topic of deploying a Grails app in a standalone Tomcat Docker container.

Introduction

Containerising Grails apps cannot stand out the racing of deploying applications on cloud-based environments. In this post, we’ll discuss how to deploy your Grails application as a WAR file into a containerized Tomcat server.

Docker is a platform to build and run distributed applications. We can use Docker to package our Grails application, including all dependencies, as a Docker image. We can then use that image to run the application on the Docker platform. This way the only dependency for running our Grails applications is the availability of a Docker engine. And with Grails 3 it is very easy to create a runnable JAR file and use that JAR file in a Docker image. Because Grails 3 now uses Gradle as a build system we can even automate all the necessary steps by using the Gradle Docker plugin.

Dockerise Grails apps in a standalone Tomcat Docker container

Dockerise Grails apps in a standalone Tomcat Docker container

How to build Docker images

As introduced earlier, the foremost step is to build Docker images of Grails apps which are runnable in Docker. I don’t make a lot of redundant codes in my work here as there is a post sharing with you how to deploy the first web-based app in a Tomcat running on a Docker container where I show the way of building Docker images. Having said that, below is the Dockerfile file of BioModels repository to build the image running in a standalone Tomcat Docker container.

# tomcat 7.0.104
FROM tomcat:7-jdk8-openjdk
LABEL maintainer="biomodels-developers@lists.sf.net"

# copy jummp-biomodels from target/
# target/ was added to .dockerignore so docker cannot see
# target/jummp-biomodels.war
ADD jummp-biomodels.war /usr/local/tomcat/webapps

EXPOSE 4372
EXPOSE 8080

CMD ["catalina.sh", "run"]

Summary

I have represented how to dockerise a Grails app to able to run it in a standalone Tomcat running on a Docker container. All constructive feedback is always welcomed. If you are interested in this post, please consider donating us by following either of the instructions below.

References

  1. Deploying a Grails App in a Tomcat Docker container accessed on 29/05/2020
  2. Docker image for tomcat 7.0.55 accessed on 29/05/2020
  3. Dockerfile for tomcat accessed on 29/05/2020
  4. Error while trying to dockerize a Grails application accessed on 29/05/2020
  5. Deploying Grails Apps To Docker accessed on 31/05/2020

About Nguyen Vu Ngoc Tung

I love making new professional acquaintances. Don't hesitate to contact me via nguyenvungoctung@gmail.com if you want to talk about information technology, education, and research on complex networks analysis (i.e., metabolic networks analysis), data analysis, and applications of graph theory. Specialties: researching and proposing innovative business approaches to organizations, evaluating and consulting about usability engineering, training and employee development, web technologies, software architecture.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

*

code

This site uses Akismet to reduce spam. Learn how your comment data is processed.