This guide describes how to create a Micronaut
application that runs natively on Oracle Cloud Infrastructure, Amazon Web Services, Google Cloud Platform, and Microsoft Azure without
any source code changes.
The application demonstrates how to store and retrieve user profile pictures in Oracle Cloud Infrastructure, Amazon Web Services, Google Cloud Platform, and Microsoft Azure using
the Micronaut Object Storage API.
Windows platform: The GDK guides are compatible with Gradle only. Maven support is coming soon.
Create a new project using the following selections. (Alternatively, use these shortcuts for Maven
or Gradle.)
Project Type: Application (Default)
Project Name: GettingStarted
Base Package: com.example (Default)
Clouds: OCI, AWS, GCP, andAzure
Language: Java (Default)
Build Tool: Gradle (Groovy) or Maven
Test Framework: JUnit (Default)
Java Version: 25 (Default)
Micronaut Version: (Default)
Cloud Services: Object Storage
Features: GraalVM Native Image (Default)
Sample Code: Yes (Default)
Click Generate Project and then click
Download Zip. The GDK Launcher creates an application with
the default package com.example in a directory named GettingStarted. The application ZIP
file will be downloaded to your default downloads directory. Unzip it, open it in your code editor, and
proceed to the next steps.
The GDK Launcher creates the following sample source code files that use the Micronaut
Object Storage API to create, read, and delete objects in the major cloud providers:
an interface describing the endpoints of the "profile pictures" microservice:
For this section, you will need an Oracle Cloud Infrastructure account and an Object Storage bucket created
already.
See how to create an Object Storage bucket from the Oracle Cloud Console.
Add the Oracle Cloud Infrastructure configuration file
(oci/src/main/resources/application.properties) with the name of the bucket and its namespace:
Replace OBJECT_STORAGE_BUCKET with the name of your bucket and
OBJECT_STORAGE_NAMESPACE with your namespace.
For this section, you will need an Amazon Web Services account and an S3 bucket already created. See the Amazon S3 Object Storage
Guide for assistance.
Update the Amazon Web Services configuration file (aws/src/main/resources/application.properties)
with the name of the bucket:
Replace OBJECT_STORAGE_BUCKET with the name of your bucket.
For this section, you will need a Google Cloud Platform account and an Object Storage bucket created already.
See GCP Object Storage
Guide for assistance.
Update the Google Cloud Platform configuration file (gcp/src/main/resources/application.properties)
with the name of the bucket:
Replace STORAGE_CONTAINER with the name of your container and
STORAGE_ENDPOINT with your storage endpoint (it will look like https://gdkstorage.blob.core.windows.net/).
4. Build a Native Executable of Your Application with GraalVM
To build a native executable of your application, you should install GraalVM with Native Image. Once your local
environment is setup, use the command below to build a native executable. Then run it and test it as above.
5. Deploy the Application as a Container on the Cloud
Next you can create a container with Native Image version of the application and deploy it
on a Kubernetes cluster on Oracle Cloud Infrastructure, Amazon Web Services, Google Cloud Platform, and Microsoft Azure.
With your AWS account ready and access to EKS configured, simply invoke this command:
Build ToolFilter
Gradle
Maven
All
./mvnw deploy -Dpackaging=docker-native -pl aws
./mvnw deploy -Dpackaging=docker-native -pl aws
./mvnw deploy -Dpackaging=docker-native -pl aws
./mvnw deploy -Dpackaging=docker-native -pl aws
./gradlew aws:dockerPushNative
./gradlew aws:dockerPushNative
./gradlew aws:dockerPushNative
./gradlew aws:dockerPushNative
This will build a native executable, package it as a container image and push the container image to the correct Amazon Web Services container registry.
When you setup your Kubernetes deployment for Amazon Web Services EKS, simply invoke the command:
kubectl apply -f deployment.yml
5.3. GCP
With your GCP account ready and access to GKE configured, simply invoke this command:
Build ToolFilter
Gradle
Maven
All
./mvnw deploy -Dpackaging=docker-native -pl gcp
./mvnw deploy -Dpackaging=docker-native -pl gcp
./mvnw deploy -Dpackaging=docker-native -pl gcp
./mvnw deploy -Dpackaging=docker-native -pl gcp
./gradlew gcp:dockerPushNative
./gradlew gcp:dockerPushNative
./gradlew gcp:dockerPushNative
./gradlew gcp:dockerPushNative
This will build a native executable, package it as a container image and push the container image to the correct Google container registry.
When you setup your Kubernetes deployment for GKE, simply invoke the command:
With your Azure account ready and access to AKS configured, simply invoke this command:
Build ToolFilter
Gradle
Maven
All
./mvnw deploy -Dpackaging=docker-native -pl azure
./mvnw deploy -Dpackaging=docker-native -pl azure
./mvnw deploy -Dpackaging=docker-native -pl azure
./mvnw deploy -Dpackaging=docker-native -pl azure
./gradlew azure:dockerPushNative
./gradlew azure:dockerPushNative
./gradlew azure:dockerPushNative
./gradlew azure:dockerPushNative
This will build a native executable, package it as a container image and push the container image to the correct Azure container registry.
When you setup your Kubernetes deployment for AKS, simply invoke the command:
kubectl apply -f deployment.yml
Next Steps
Learn
The Micronaut Fundamentals course covers core concepts of the Micronaut framework, application creation, HTTP development, and OpenAPI integration. It also introduces data validation, error handling, GraalVM native images, and deployment with the Graal Development Kit (GDK).
The GDK provides easy step-by-step guides, and companion sample applications,
for the developer to learn how to use a specific cloud service (such as Micronaut Data).
Browse the GDK site for list of modules and guides to learn more.