Getting Started with Oracle Application Container Cloud


Options



Before You Begin

Purpose

This tutorial shows you how to deploy, run, and manage an application on Oracle Application Container Cloud.

Time to Complete

30 minutes

Background

Oracle Application Container Cloud can deploy and run Java Platform, Standard Edition (Java SE) and Node.js applications. First, to deploy your application, you compress the application in a zip or Gzipped Tar (TGZ) archive file, which includes required configuration information. Then, you use the Oracle Application Container Cloud graphical user interface (GUI) or the REST API to deploy your application. With the application deployed, you can test and run your application and manage the application’s size.

In this tutorial, you use the provided sample embedded Tomcat web application as the archive file.

Context

This tutorial covers deploying, running, and managing applications on Oracle Application Container Cloud. To deploy your application correctly, you must first develop and package it according to specific guidelines, which are explained in the following learning series. Select the learning series that most closely matches the application and framework that you want to create.

What Do You Need?

Deploying Your Application: Web GUI

  1. Download the sample embedded Tomcat web application.

  2. Open the Oracle Application Container Cloud Service console.
  3. On the Applications page, click Create Application and select Java SE.
  4. In the Create Applications dialog box, enter EmployeeWebApp for the name of your application and click Choose File.
  5. In the File Upload dialog box, select the employees-web-app.zip file and click Open.
  6. In the Create Applications dialog box, click More Options.
  7. Enter or select the following values, leave the other fields with their default values, and then click Create:
    • Metering Frequency: Monthly
    • Notes: Sample Tomcat application
    Your application is created and deployed.

Exploring the Interface: Web GUI

After you configure and deploy the application through the web GUI, you’ll see configuration views that give you options and information about your current settings.

Overview View

This view is the default view for an application. It shows the number of running instances, instance memory size, instance metadata (for example, the time that the instance was started), and application metadata (for example, Java version, date and time deployed, and identity domain):

Oracle Application Container Cloud - Application Page showing Overview Tile
Description of this image

Deployments View

This view shows information about the current application’s deployment. The view focuses on configuration data which includes application metadata (for example, archive name and archive size), service bindings to other cloud services, global environment variables, the launch command for your instances, and the configuration files for each application instance (the manifest.json and deployment.json files are linked here).

Oracle Application Container Cloud - Deployments View
Description of this image

Administration View

The Administration View allows you to manage the underlying technology version you are using for your application. In this case, the tab allows you to choose the Java version you are using. You can upgrade to a new version of Java or roll back to an older version.

Oracle Application Container Cloud - Administration View
Description of this image

Logs & Recordings

This view stores application-related log and performance information.

On the Administration page, in the Logs tab, you can generate the log file from your instances and then download it to your local machine. You can also view a history of log captures.

Logs tab
Description of this image

On the Recordings tab, you can use Java Flight Recorder to record one minute of your application’s performance data, download the recording to your local machine, and analyze it in Java Mission Control.

Recordings tab
Description of this image

Working with Your Application: Web GUI

Testing Your Application

After you deploy your application, test it to ensure that it opens in your browser. In the Applications list view, scroll to EmployeeWebApp and click the link in the URL field.

Applications list view with URL generated for the application
Description of this image

The application opens in your browser.

Controlling Your Application

You can control your application's basic functionality from the main application list. Click Menu, and select one of the following options:

  • Open Application
  • View Metrics
  • Start
  • Stop
  • Restart
  • Delete
Application menu
Description of this image

Scaling the Application Instances

To increase or decrease the number of instances, simply select the number and then apply your changes. In this section, you increase the number of instances.

  1. Open your application's Overview view, and notice that the example displays 1 instance and 1 GB of memory.

  2. Overview page - instance and memory allocations
    Description of this image
  3. In the Instances field, click the up arrow once to increase the number of instances to 2, and click Apply.

  4. Overview page – changed instances allocation
    Description of this image
  5. In the confirmation dialog box, click Apply.

  6. At the bottom of the Application page, the In-Progress Activity section displays messages of the application scaling process.

    Overview page - In-Progress Activity section
    Description of this image

Changing the Application Memory

To increase or decrease the memory, simply select the size and then apply your changes. In this section, you increase the container size for two running instances.

  1. In the Memory field, click the up arrow once to increase the container size to 2 GB, and click Apply.

  2. Overview page - instance and memory allocations
    Description of this image
  3. In the confirmation dialog box, click Apply.

  4. At the bottom of the Application page, the In-Progress Activity section displays messages of the application scaling process.

    Confirmation dialog box - In-Progress Activity section
    Description of this image

Redeploying Your Application

Once you update your application, you can redeploy the new version. To redeploy a new application archive file follow these steps.

  1. Open the Applications page and click on your application name.

  2. Click Deployments.

  3. On the Deployments page, click Update.

  4. Click Choose File. In the File Upload dialog box, select your application file and click Open.

  5. Click the Apply Edits.

  6. In the Apply Changes dialog box, click Restart.

  7. Click Applications.
  8. On the Applications page, the apaas-deploy-release-rolling status is displayed until the deployment is complete.

    Applications page - Redeploying application
    Description of this image

Deploying Your Application: REST API

In this section, you deploy your Java SE application to Oracle Application Container Cloud by using the REST API. For this deployment, use the cURL command-line tool, which runs on any major operating system (Windows, Mac OS X, or Linux). Download the sample embedded Tomcat web application, if you haven’t already downloaded it.

Here are the steps needed to deploy your application:

  1. Upload your application to the storage service.
  2. Deploy your application to Oracle Application Container Cloud.

Uploading Your Application to the Storage Service

Before you can deploy your application, you must copy it to the storage service. You need your Oracle Cloud service credentials (User ID, password, ID domain) to use the REST API. With your credentials, you create cURL scripts to upload your application to the storage service.

Here are sample values that are used in the cURL script examples that follow:

  • App Name: EmployeeWebApp
  • Archive File Name: employees-web-app.zip
  • Path to Local File: target/employees-web-app.zip
  • User Name: johndoe
  • Password: johnpassword
  • Identity Domain: john-acct01
  • Host Name: apaas.us.oraclecloud.com

This example shows the script structure that creates a storage container:

# CREATE STORAGE CONTAINER
curl -i -X PUT \
  -u User-Name:Password \
  https://hostname/v1/Storage-Identity-Domain/App-Name

After you create the storage container, you can upload your application archive to the storage container.

This example shows the script structure that uploads your application archive to the storage container:

# PUT ARCHIVE IN STORAGE CONTAINER
curl -i -X PUT \
-u User-Name:Password \
https://hostname/v1/Storage-Identity-Domain/App-Name/Archive-File-Name -T Path-to-local-file/Archive-File-Name

This example script uses the provided sample values to create the storage container:

# CREATE STORAGE CONTAINER
curl -i -X PUT \
  -u johndoe:johnpassword \
  https://storage.oraclecloud.com/v1/john-acct01/EmployeeWebApp

This example script uses the provided sample values to upload the sample application to the storage service:

# PUT ARCHIVE IN STORAGE CONTAINER
curl -i -X PUT \
  -u johndoe:johnpassword \
  https://storage.oraclecloud.com/v1/john-acct01/EmployeeWebApp/employees-web-app.zip -T target/employees-web-app.zip

Deploying Your Application to Oracle Application Container Cloud

To deploy your application, you need to include standard information in your script. The following example script shows placeholders for the required information:

# Mock Deployment Script
url -i -X POST  \
  -u User-Name:Password \
  -H "X-ID-TENANT-NAME:Identity-Domain" \
  -H "Content-Type: multipart/form-data" \
  -F "name=App-Name" \
  -F "runtime=java" \
  -F "subscription=Monthly" \
  -F "deployment=@deployment.json" \
  -F "archiveURL=App-name/Archive-File-Name" \
  -F "notes=Your Notes here" \
  https://hostname/paas/service/apaas/api/v1.1/apps/Identity-Domain

Here are a few key points about this example:

  • -H specifies headers that are added to the HTTP request.
  • -F allows cURL to submit data like it's coming from a form (so, POST as the HTTP method).
  • archiveURL specifies where your archive file is located. The URL consists of your application's name, a slash, and the archive's file name.

Note: Rather than using default values for your application, you can specify the deployment.json file at deployment.

Here's a sample deployment script that contains actual data, including the deployment.json file:

# Deployment Script
url -i -X POST  \
  -u johndoe:johnpassword \
  -H "X-ID-TENANT-NAME:john-acct01" \
  -H "Content-Type: multipart/form-data" \
  -F "name=EmployeeWebApp" \
  -F "runtime=java" \
  -F "subscription=Monthly" \
  -F "deployment=@deployment.json" \
  -F "archiveURL=EmployeeWebApp/employees-web-app.zip" \
  -F "notes=REST app for testing" \
  https://apaas.us.oraclecloud.com/paas/service/apaas/api/v1.1/apps/john-acct01
 

After your application is deployed to Oracle Application Container Cloud, view any application details in the web GUI.

Specifying the deployment.json File

When you deploy your application, you can reference a deployment.json file. The file provides configuration settings for the container that your application runs in. The settings include the memory size of the application and specific information about the environment.

Example deployment.json File

{
    "memory": "2G",
    "instances": "1",  
    "environment": {
        "NO_OF_CONNECTIONS":"25",
        "TWITTER_ID":"JAVA"
    },
    "services": [{
        "identifier": "ProdService",
        "name": "Jaas Service",
        "type": "JAAS"
        "username": "username",
        "password": "***"  
    }]
}

JSON Fields

  • memory defines the size of the applications container. Valid values are 1G to 7G.
  • instances are the number of application instances to run.
  • notes are notes about the deployment plan.
  • environment:
    • key is the name of an environment variable that the application uses.
    • value is the value of the environment variable that the application uses.
  • services:
    • identifier is the user-defined name.
    • name is the name of the service.
    • type is the type of service.
    • username is the name used to access the service (optional).
    • password is the password for the service (optional).

Here's the actual deployment.json file used for an application:

{
    "memory": "2G",
    "instances": "1",
    "environment":{
        "TEST_ENV_VAR": "TestValue"
    }
}

When you deploy the application, just reference the file in the cURL script. Then the file's settings are used to deploy the application.

Updating Your Application: REST API

Updating Your Configuration with deployment.json

To update your application's deployment configuration, execute a command like the following:

curl -X PUT \
-u johndoe:johnpassword \
-H "X-ID-TENANT-NAME:john-acct01" \
-H "Content-Type: multipart/form-data"\
-F deployment=@deployment.json" \
-F "notes=notes for deployment" \
	https://apaas.us.oraclecloud.com/paas/service/apaas/api/v1.1/apps/john-acct01/EmployeeWebApp

In the URL, the identity domain and the application’s name specify what is updated. The deployment.json file contains your changes to the configuration. Changes restart your application or start new instances.

Redeploying Your Application

To update the entire application, use the following command:

curl -X PUT \
-u johndoe:johnpassword \
-H "X-ID-TENANT-NAME:john-acct01" \
-H "Content-Type: multipart/form-data"\
-F "deployment=@deployment.json" \
-F "archiveURL=/path-to-myapp/employees-web-app.zip" \
-F "notes=notes for deployment" \
https://apaas.us.oraclecloud.com/paas/service/apaas/api/v1.1/apps/john-acct01/EmployeeWebApp

In the URL, the identity domain and the application’s name specify what is updated. The deployment.json file contains your changes to the configuration, but the file isn’t required. If you don’t want to change the deployment settings, don’t specify a file. In this case, your application restarts.

Want to Learn More?

Credits

Curriculum Developer: Michael Williams