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.
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.
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="firstname.lastname@example.org" # 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"]
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.
- Deploying a Grails App in a Tomcat Docker container accessed on 29/05/2020
- Docker image for tomcat 7.0.55 accessed on 29/05/2020
- Dockerfile for tomcat accessed on 29/05/2020
- Error while trying to dockerize a Grails application accessed on 29/05/2020
- Deploying Grails Apps To Docker accessed on 31/05/2020