Skip to end of metadata
Go to start of metadata

Introduction

This topic describes how to create, Dockerize, and publish an API Builder Standalone application to the AMPLIFY Runtime Services (API Runtime Services) cloud. Prerequisites, instructions, and references are provided to help you successfully deploy and publish your application to the AMPLIFY Runtime Services cloud and to test your published application.

Prerequisites

You need to have the following installed:

  1. Docker - The installation of Docker is via a dedicated installer for your specific operating system. For additional Docker installation information, refer to the Docker documentation.
  2. API Builder CLI - The CLI is a node module published in the npm public repository. Basically, it is a one-line command as follows:

    For additional API Builder CLI installation information, refer to the API Builder Getting Started Guide.

Create and deploy an example application to AMPLIFY Runtime Services

To create and deploy your application to AMPLIFY Runtime Services, take the following steps:

Step 1: Create your application

To create and run your application, execute the following commands:

Once the test application is running, point your browser to http://localhost:8080/console to access the API Builder user interface (UI) console.

For additional information on the API Builder UI, refer to the API Builder Getting Started Guide.

Now, stop your application by using Ctrl + C in your terminal where the application is running and go to the next step.

The following variable placeholder is used in this section:

Variable PlaceholderDescription
<APPLICATION_NAME>

This is your chosen application name that the API Builder CLI is using. For example: test

It will create a folder with the chosen name and will place all the generated files in that folder.

Step 2: Set the port for your application (optional)

The port configuration is in the /conf/default.js file:

Optionally, you can set the PORT environment variable to the port on which the service should be running. The default value of 8080 is used when the PORT variable is not set.

Step 3: Build a Docker image of your application

To build the Docker image of your application, execute the following command from within your application directory:

Once the Docker image process is completed, execute the following command to verify the Docker image build.

Verify that your application image is listed.

The following variable placeholder is used in this section:

Variable PlaceholderDescription
<DOCKER_IMAGE_NAME>

This is your chosen Docker image name that Docker builds. For example: testapp

Step 4: Publish your Docker image to the AMPLIFY Runtime Services cloud

Caveat

Icon

 Logging will not work once the application is published because of the limitations of how AMPLIFY Runtime Services observes logs. To have access to the logging and analytics information displayed in the Dashboard user interface, refer to Create a logger for your published application.

To publish your Docker image to the AMPLIFY Runtime Services cloud, take the following steps:

  1. Log into your AMPLIFY Runtime Services account. Your AMPLIFY Runtime Services account username and password are identical to your AMPLIFY Platform account username and password.

    To log into your AMPLIFY Runtime Services cloud, execute the following command.

  2. Publish your application to the AMPLIFY Runtime Services cloud.

  3. Once the publication process is completed, your application will be available on the AMPLIFY Runtime Services cloud.

    Icon

    It can take up to 10 minutes for your project to be deployed and your APIs to be accessible. If your API is not responding and you run appclogcat and get a port 80 in use error, try setting the PORT to 8080 using:

The following variable placeholders are used in this section:

Variable PlaceholderDescription
<DOCKER_IMAGE_NAME>

This is your chosen Docker image name that Docker builds. For example: testapp

<PUBLISHED_APP_NAME>This is your chosen application name for your published application. For example: acsapp

Step 5: Test your published application

To test your published application, take the following steps:

  1. Get the APIKEY from the /conf/default.js file.
  2. To get the URL of your published application, execute the following command:

  3. Use the following command to ping the built-in Greet API:

The following variable placeholders are used in this section:

Variable PlaceholderDescription
<PUBLISHED_APP_NAME>This is your chosen application name for your published application. For example: acsapp

<YOUR_API_KEY>

Your APIKEY listed the /conf/default.js file.

<YOUR_URL>

The URL of your published application.

<YOUR_USER_NAME>

Your AMPLIFY Platform user name.

Step 6: Create a logger for your published application (optional)

To have access to the logging and analytics information displayed in the Dashboard user interface, use the appc-logger library in your application code. To create a default logger:

Default Logger

You should see:

You can also customize the logger with the following optional properties:

  • prefix - Boolean to indicate if the Log Level should be printed in the console. Defaults to true. Set to false to suppress the label.

  • showcr - Boolean to indicate if the log output displays a special carriage return symbol () to indicate a carriage return in the message. Defaults to true.

  • showtab - Boolean to indicate if the log output displays a special tab symbol () to indicate a tab in the message. Defaults to true.

To create a customized logger:

Custom Logger

You should see:

6 Comments

  1. If you log in using acs, you have to tell VPC users how to log in differently to their VPCs.

    1. Added the ARS cloud login command.

  2. Also note the top instructions still say to install appcelerator.

    1. Removed the appcelerator installation.

  3. Hi Chuck Jaynes,

    As discussed, could you please add :

    Customer application should use "appc-logger" library in their code if they want to have access log and analytics displayed in Dashboard UI.

     

    Bests,

    Yizhe LI

    1. Yizhe Li - Please review the additional optional step -  Step 6: (Optional) Create a logger for your published application and let me know if I need to make additional changes or provide additional information.