明壁幕府忍法帳 > Aptana Index > Home > Axway API Builder > AMPLIFY Runtime Services > ANPLIFY Runtime Services How-tos > Deploy an API Builder Standalone application to AMPLIFY Runtime Services

2019.03.25 Ver.5 (2019.4.12)

Deploy an API Builder Standalone application to AMPLIFY Runtime Services

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:

    npm install -g @axway/api-builder

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

  3. Appcelerator CLI - The Appcelerator CLI is available in the npm public repository. To install the Appcelerator CLI, execute the following command:

    npm install -g appcelerator


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:

api-builder init <APPLICATION_NAME>
cd <APPLICATION_NAME>
npm install --no-optional
npm start

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 Placeholder Description
<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: Modify the default configuration port for your application

The port configuration in the /conf/default.js file must be modified.

To modify the /conf/default.js file so that the port can be controlled by the environment variable PORT instead of being hard-coded to 8080, make the following change to the default.js file:

Change:

// This is the port the service will be bound to
port: 8080,

To:

// This is the port the service will be bound to
port: process.env.PORT || 8080,

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:

docker build -t <DOCKER_IMAGE_NAME> ./

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

docker images

Verify that your application image is listed.

The following variable placeholder is used in this section:

Variable Placeholder Description
<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 publish your Docker image to the AMPLIFY Runtime Services cloud, take the following steps:

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

    acs login

     

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

    acs publish <PUBLISHED_APP_NAME> --delete_oldest --force --image <DOCKER_IMAGE_NAME> --app_version 0.1

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

The following variable placeholders are used in this section:

Variable Placeholder Description
<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:

    appc list <PUBLISHED_APP_NAME>
  3. Use the following command to ping the built-in Greet API:

    curl -X GET -u <YOUR_API_KEY>: <YOUR_URL>/api/greet?username\=<YOUR_USER_NAME>

The following variable placeholders are used in this section:

Variable Placeholder Description
<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.
  • ラベルなし