Docker image that will bootstrap an environment for running a Grails application using Docker optimized base images. By default, it will run the Grails app using the prod run-app
(or prod run-war
for Grails 2) directive which is the most optimized way of running Grails for production environments. However, you can easily change the default behaviour for your specific uses (see the Changing Behaviour section for more details on this).
- Grails 3.2.8 (by default; all versions from
2.0.0
up to3.2.8
can be specified) - Java JDK 7+ (for Grails 2) or 8+ (for Grails 3)
- Tomcat 7+ (for Grails 2) or 8+ (for Grails 3)
By default, the container will start inside Grails interactive mode. From here, you can run the app by simply typing run-app
or execute any other valid Grails commands you may want to.
Use the following command to run on default mode (remember to ALWAYS specify your app folder in the -v
command):
docker run --rm -v /path/to/your/project:/app:rw -p 80:8080 --name grails mozart/grails
Note: This command will run the Grails container using the latest stable version of Grails 3.
This default behavior can be altered by using the tag modifier for specifying the Grails image version (see the Image Tag version), by modifying the command when running the image (see the Run Command version) or by editing the default environment variables (see the Environment Variables section).
You can change the default behavior of the image by either changing some environment variables or executing a command rather than entering the default Grails interactive mode.
You can change the default behaviour of the image when building and running it by specifying a different Grails image version using the tag (e.g.:{repository}/{imageName}:{tag}
) modifier at the end of the image identifier (e.g.: docker run --rm -v /path/to/your/project:/app:rw -p 80:8080 --name grails mozart/grails:2
)
The image contains the following customizable Grails related environment variables that can be changed inside the image's Dockerfile.
GRAILS_VERSION
: Specifies the version of Grails to download (default:3.2.8
; min:2.0.0
; max:3.2.8
).
IMPORTANT: When using the
GRAILS_VERSION
env var to specify a version less than3.0.0
you MUST use the image version tag with a value of2
(e.g.: mozart/grails:2). If not, image building will fail!
You can execute a different Grails command rather than the interactive mode that is run by default, by specifying the command after the mozart/grails
image name in the following form: {grails-command}
. For example:
docker run --rm -v /path/to/your/project:/app:rw -p 80:8080 --name grails mozart/grails:3 run-app
You can build the image by yourself by executing:
docker build https://raw.githubusercontent.com/mozart-analytics/grails-docker/master/grails-3/Dockerfile
Or by downloading directly from the registry:
docker pull mozart-analytics/grails:{version|latest}
You can also leverage the use of this image for your internal apps if you want more freedom of customization and speed of initialization. To do this:
- Create a Dockerfile for your app.
- Use this image as the
FROM:
image of your app's Dockerfile. - Put your app's Dockerfile on the root of the app's folder.
- Build your image using your own custom Dockerfile.
An example of a Dockerfile for a Grails-Hello-World app could be:
FROM mozart/grails:3
MAINTAINER Manuel Ortiz Bey <[email protected]>
# Copy App files
COPY . /app
# Run Grails dependency-report command to pre-download dependencies but not
# create unnecessary build files or artifacts.
RUN grails dependency-report
# Set Default Behavior
ENTRYPOINT ["grails"]
CMD ["run"]
FROM mozart/grails:2
MAINTAINER Manuel Ortiz Bey <[email protected]>
# Copy App files
COPY . /app
# Run Grails refresh-dependencies command to
# pre-download dependencies but not create
# unnecessary build files or artifacts.
RUN grails refresh-dependencies
# Set Default Behavior
ENTRYPOINT ["grails"]
CMD ["run-app"]
Then build your Docker image by executing:
docker build -t "{repo-name}/Grails-Hello-World" .
And finally run your app as a Docker container by executing:
docker run -it -p 8080:8080 {repo-name}/Grails-Hello-World
- More info about phusion/baseimage.
- More info about Grails.
This image was inspired by the niaquinto/grails image available in the Docker Registry Hub.