2.5 Deploying the Application

To deploy a Micronaut application you create a runnable JAR file by running ./gradlew assemble or ./mvnw package.

The constructed JAR file can then be executed with java -jar. For example:

  1. $ java -jar build/libs/hello-world-all.jar

The runnable JAR can be executed locally, deployed to a virtual machine or managed Cloud service that supports runnable JARs.

To publish a layered application to a Docker container registry you can configure your Docker image name in build.gradle for Gradle:

  1. dockerBuild {
  2. images = ["[REPO_URL]/[NAMESPACE]/my-image:$project.version"]
  3. }

Then use dockerPush to push a built image of the application:

  1. $ ./gradlew dockerPush

For Maven, define the following plugin in your POM:

  1. <plugin>
  2. <groupId>com.google.cloud.tools</groupId>
  3. <artifactId>jib-maven-plugin</artifactId>
  4. <configuration>
  5. <to>
  6. <image>docker.io/my-company/my-image:${project.version}</image>
  7. </to>
  8. </configuration>
  9. </plugin>

Then invoke the deploy lifecycle phase specifying the packaging type to either docker or docker-native:

  1. $ ./mvnw deploy -Dpackaging=docker