Skip to content

Commit

Permalink
WMS ID 11721 - Build a Java application with Graal Cloud Native and O…
Browse files Browse the repository at this point in the history
…racle Cloud Infrastructure Email Delivery (#382)

* Adding gdk-oci-email workshop

* Add more changes

* Add build-and run sections

* Update git-clone.md

* Update git-clone

* Follow Sachin P. comments

* Follow Sachin P. comments

* Update configure-app.md

* Add more changes

* Push more changes

* Update manifest.json

* Add more changes

* Update git-clone.md

* Additional changes

* Minor updates

* Update prepare-setup.md

* Add minor changes

* Update git-clone.md

* minor fix

* Add minor changes

* Change OCI menu images

* Change manifest.json files

* Update configure-app.md

* Update configure-app.md

* Minor updates

---------

Co-authored-by: Sachin Pikle <[email protected]>
  • Loading branch information
LesiaChaban and sachin-pikle authored Aug 1, 2024
1 parent 1955935 commit edb4526
Show file tree
Hide file tree
Showing 29 changed files with 1,279 additions and 0 deletions.
62 changes: 62 additions & 0 deletions gdk-oci-email/00-introduction/introduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Introduction

## About this Workshop

This workshop takes you step by step through the process of building a Java application to send emails with Oracle Cloud Infrastructure (OCI) Email Delivery using the Graal Development Kit for Micronaut (GDK). You'll use GraalVM Native Image to package and run the application as a native executable.

It is aimed at application developers and DevOps engineers with a basic knowledge of Java.

Estimated Workshop Time: 75 minutes

### What is Graal Development Kit for Micronaut?

The [Graal Development Kit for Micronaut (GDK)](https://graal.cloud/gdk) is an Oracle build of the open source Micronaut® framework. The GDK provides a curated set of Micronaut framework modules that simplify cloud application development, are designed for ahead-of-time compilation with GraalVM Native Image, and are fully supported by Oracle. The GDK also provides project creation utilities, VS Code and IntelliJ extensions to simplify application development and deployment.

### What is Micronaut?

The [Micronaut® framework](https://micronaut.io/) is a modern, JVM-based framework to build modular, easily testable microservice and serverless applications. By avoiding runtime reflection in favor of annotation processing, Micronaut improves the Java-based development experience by detecting errors at compile time instead of runtime, and improves Java-based application startup time and memory footprint. Micronaut includes a persistence framework called Micronaut Data that precomputes your SQL queries at compilation time making it a great fit for working with databases like MySQL, Oracle Autonomous Database, etc.

> Micronaut® is a registered trademark of Object Computing, Inc. Use is for referential purposes and does not imply any endorsement or affiliation with any third-party product.
### What is GraalVM Native Image?

[GraalVM Native Image](https://www.graalvm.org/) technology compiles Java applications ahead-of-time into self-contained native executables that are small in size, start almost instantaneously, provide peak performance with no warmup, and require less memory and CPU. Only the code that is required at run time by the application gets added into the executable file. Native Image is perfect for containerized workloads and microservices — which is why it has been embraced by Micronaut, Spring Boot, Helidon, and Quarkus.

The GDK modules are designed for ahead-of-time compilation with GraalVM Native Image to produce native executables that are ideal for microservices: they have a small memory footprint, start instantly, and provide peak performance with no warmup.

> Graal Development Kit for Micronaut, and Oracle GraalVM are available at no additional cost on Oracle Cloud Infrastructure (OCI).
### Objectives

In this workshop, you will:

* Use Visual Studio Code (VS Code) from a remote desktop running in an OCI Compute Instance
* Review the application source code developed with the Graal Development Kit for Micronaut
* Configure OCI Email Delivery:
* Generate SMTP Credentials
* Set the SMTP server as the public endpoint
* Create an Approved Sender
* Change the "to" Email Address
* Build a native executable for the application using GraalVM Native Image
* Send emails from your application using OCI Email Delivery

### Prerequisites

This workshop assumes you have:

* Some familiarity with Oracle Cloud Infrastructure (OCI)
* Understanding of the Java programming language
* Oracle GraalVM for JDK 17
* Visual Studio Code (VS Code)
* A browser with access to the internet
* An Oracle Cloud Infrastructure (OCI) account with adequate permissions

## Learn More

* [Graal Development Kit for Micronaut](https://graal.cloud/gdk/)

## Acknowledgements

* **Author** - [](var:author)
* **Contributors** - [](var:contributors)
* **Last Updated By/Date** - [](var:last_updated)
85 changes: 85 additions & 0 deletions gdk-oci-email/01-prepare-setup/prepare-setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Prepare Setup

## Introduction

This lab will show you how to download the Oracle Resource Manager (ORM) stack zip file needed to set up the resources needed to run this workshop.

*Estimated Lab Time:* 5 minutes

### Objectives

* Download ORM stack
* (*Optional*) Configure an existing Virtual Cloud Network (VCN)
* Select a Compartment for the workshop

### Prerequisites

This lab assumes you have:

* An Oracle Cloud account

## Task 1: Download Oracle Resource Manager (ORM) stack zip file

1. Click on the link below to download the Resource Manager zip file you need to build your environment:

* [gdk-oci-email-ll-orm.zip](https://c4u04.objectstorage.us-ashburn-1.oci.customer-oci.com/p/EcTjWk2IuZPZeNnD_fYMcgUhdNDIDA6rt9gaFj_WZMiL7VvxPBNMY60837hu5hga/n/c4u04/b/livelabsfiles/o/oci-library/gdk-oci-email-ll-orm.zip)

2. Save it in your downloads folder.

3. (*Recommended*) We strongly recommend using this stack to create a new self-contained/dedicated VCN along with your instance. Skip to **Task 3** to follow the recommendation.

4. Alternatively, if you would rather use an existing VCN then proceed to the next task to update your existing VCN with the required network security rules.

## Task 2: Add Network Security Rules to an Existing VCN

This workshop requires a certain number of ports to be available, a requirement that is automatically met by using the default ORM stack execution that creates a new dedicated VCN.

However, if you would rather use an existing VCN/subnet, follow these steps to add the following rules to the network security list.

1. From the Oracle Cloud Console navigation menu, go to **Networking >> Virtual Cloud Networks**.
2. Choose your network.
3. Under **Resources**, select **Security Lists**.
4. Click on **Default Security Lists** under the **Create Security List** button.
5. Click **Add Ingress Rules** button.
6. Create a rule for each row in the *Ingress* table below:

| Stateless | Source Type | Source CIDR | IP Protocol | Source Port Range | Destination Port Range | Description |
| :------------- | :---------: | :---------: | :---------: | :---------------: | :--------------------: | :------------------------- |
| No (unchecked) | CIDR | 0.0.0.0/0 | TCP | All | 80 | Remote Desktop using noVNC |
| No (unchecked) | CIDR | 0.0.0.0/0 | TCP | All | 6080 | Remote Desktop using noVNC |
{: title="Network Ingress Security Rules"}

7. Select **Egress Rule** from the left panel.
8. Click **Add Egress Rule** button
9. Create a rule for each row in the *Egress* table below:

| Stateless | Source Type | Destination CIDR | IP Protocol | Source Port Range | Destination Port Range | Description |
| :------------- | :---------: | :--------------: | :---------: | :---------------: | :--------------------: | :-------------------- |
| No (unchecked) | CIDR | 0.0.0.0/0 | TCP | All | 80 | Outbound HTTP access |
| No (unchecked) | CIDR | 0.0.0.0/0 | TCP | All | 443 | Outbound HTTPS access |
{: title="Network Egress Security Rules"}

## Task 3: Select a Compartment for the Workshop

We recommend you use a single compartment for the workshop. We will refer to this as your workshop compartment. This is the compartment where you will provision all the resources - Oracle Resource Manager (ORM) Stack, Compute Instance, VCN/Subnet, Instance Principals, Policies, Object Storage Buckets - needed for the workshop.

1. From the Oracle Cloud Console navigation menu, go to **Identity & Security >> Identity >> Compartments**.
2. Go to your workshop compartment.
3. Make a note of the compartment name and OCID. You will need this information in subsequent labs.

## Task 4: Setup Compute

Using the details from the above Tasks, proceed to the **Environment Setup** lab to set up your workshop environment using Oracle Resource Manager (ORM) with one of the following options:

* (*Recommended*) Create Stack: **Compute + Networking**
* Create Stack: **Compute only** with an existing VCN where security lists have been updated as per **Task 2** above

The ORM stack will provision a compute instance with 4 OCPUs, 64 GB RAM and a Remote Desktop environment.

You may now **proceed to the next lab**.

## Acknowledgements

* **Author** - [](var:author)
* **Contributors** - [](var:contributors)
* **Last Updated By/Date** - [](var:last_updated)
54 changes: 54 additions & 0 deletions gdk-oci-email/02-git-clone/git-clone.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Clone the Sample Application Source Code

## Introduction

This lab describes the steps to download the sample application source code used in the workshop.

Estimated Lab Time: 5 minutes

### Objectives

In this lab, you will:

* Clone the sample application source code

## Task 1: Clone the Sample Application Source Code

1. From the **Activities** menu, start a new **Terminal** window.

2. Clone the sample application source code.

```bash
<copy>
git init lab
cd lab
git remote add origin https://github.com/sachin-pikle/gdk-oci-samples.git
git config core.sparsecheckout true
echo "gdk-oci-email-mvn/*">>.git/info/sparse-checkout
git pull --depth=1 origin main
</copy>
```

3. Open the sample application source code from the _gdk-oci-email-mvn_ directory in **Visual Studio Code**.

```bash
<copy>
code gdk-oci-email-mvn
</copy>
```

4. VS Code may show a dialog box with the message "Do you trust the authors of the files in this folder?". Select **Trust the authors of all files in the parent folder 'oracle'** and click **Yes, I trust the authors**.

5. VS Code may ask you to choose a password for new keyring. Press **Cancel** twice to close the prompt.

6. VS Code may show a dialog box with the message "A git repository was found in the parent folders of the workspace or the open file(s). Would you like to open the repository?". Click **Never**.

![VS Code Question Icon](images/vs-code-question-icon.jpg#input)

You may now **proceed to the next lab**.

## Acknowledgements

* **Author** - [](var:author)
* **Contributors** - [](var:contributors)
* **Last Updated By/Date** - [](var:last_updated)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit edb4526

Please sign in to comment.