Code Monkey home page Code Monkey logo

grails-docker's Introduction

Optimized Grails Container

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).

Technologies / Versions Used

  • Grails 3.2.8 (by default; all versions from 2.0.0 up to 3.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)

Running Using Defaults

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).

Changing Behavior

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.

Image Tag / Version

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)

Environment Variables

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 than 3.0.0 you MUST use the image version tag with a value of 2 (e.g.: mozart/grails:2). If not, image building will fail!

Run Command

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

Building the Image

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}

Extra: How to use for your Grails apps

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:

  1. Create a Dockerfile for your app.
  2. Use this image as the FROM: image of your app's Dockerfile.
  3. Put your app's Dockerfile on the root of the app's folder.
  4. Build your image using your own custom Dockerfile.

An example of a Dockerfile for a Grails-Hello-World app could be:

For Grails 3:

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"]

For Grails 2:

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

References

Credits

This image was inspired by the niaquinto/grails image available in the Docker Registry Hub.

grails-docker's People

Contributors

mortizbey avatar saun4app avatar busches avatar yellowsnow avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.