Deploy an API Builder application to AMPLIFY Runtime Services

Introduction

This topic describes how to create, Dockerize, and publish an API Builder application to the AMPLIFY 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

The following sections describe the prerequisites.

AMPLIFY Platform account

You need to have an account on https://platform.axway.com.

Docker

Docker is installed by a dedicated installer for your specific operating system. For additional Docker installation information, refer to the Docker documentation.

AMPLIFY CLI

Refer to the API Builder Getting Started Guide for details.

API Builder CLI

Refer to the API Builder Getting Started Guide for details.

AMPLIFY Cloud Services (ACS) CLI

The AMPLIFY Cloud Services (ACS) CLI is a node module published in the npm public repository

To install the AMPLIFY Cloud Services (ACS) CLI, execute the following command:

Install ACS
$ amplify pm install acs

For additional AMPLIFY Cloud Services (ACS) CLI information, refer to the AMPLIFY Runtime Services Command-Line Interface Reference.

Log Into the AMPLIFY Platform

Type the following command to log into the AMPLIFY platform. 

Log Into the AMPLIFY Platform
amplify auth login

With the amplify auth login command, your default browser should open up and prompt you to enter your AMPLIFY credentials to log into the AMPLIFY platform. 

Once you have successfully logged in to your AMPLIFY account, type the following command to show you the currently logged-in user and organizations to which you belong.

amplify acs whoami

You now have the prerequisite applications installed to use AMPLIFY Runtime Services (ARS).

Create your application

API Builder CLI usage can be found here. This the setup found in the API Builder Getting Started Guide. This will create a "myproject" sub-directory.

Create an API Builder project
$ amplify builder init myproject

Do not change directory into "myproject" when creating your platform application below.

Register your Platform application

Execute these commands in the parent directory immediately above "myproject".

Register a Platform application
$ amplify acs login
$ amplify acs new myproject --force
$ amplify acs config --set PORT=8080 myproject
$ amplify acs server --set Large myproject

The commands will log you in to the AMPLIFY Platform using your https://platform.axway.com username and password, and register a new project in the cloud called "myproject" (the same name as your API Builder project). Then, configure your project to use PORT 8080. This is because the container is built with PORT 8080 by default.  If you accidentally ran these commands in the "myproject" directory, it will create a new sub-folder "myproject/myproject" which can be deleted.

Important

Icon

You may already have an existing platform application in the cloud with the name "myproject". If you do, and you know that it is not being used and you wish to delete it, or if you want to delete this example project on ARS, you can execute: acs remove myproject.

Build a Docker image

To build a Docker image of your project, execute the following commands.

Build Docker image
$ cd ./myproject
$ docker build --tag demo-image ./

Publish image to Platform

To publish the Docker image of your project to the Platform, execute the following command.

Publish image
$ amplify acs publish myproject --delete_oldest --force --image demo-image --app_version 0.1

Important

Icon

It can take up to 10 minutes for your project to be deployed and your service to be accessible. You should Check publish status before trying to access your service in the cloud.

Once the image is written, note the URL, as you will use it to test your API, for example:

URL
App will be available at https://<guid>.cloudapp-enterprise.appcelerator.com

Check publish status

Even though your image was sent to ARS, it can take up to 10 minutes to start (for example, Status: Deploying). You should check the Status of your project before trying to access your service that is running in the cloud. The service will not be available until status shows Status: Active.

$ amplify acs list myproject

You can also check the log of your project to see if it started properly.

$ amplify acs logcat myproject

Try your application

To try your application in the cloud, you will require your API key, which can be found in "myproject/conf/default.js". On successful publication of your project, you also received a URL with a GUID prefix to access your application from the Internet. Replace the <key> and <guid> with the API key and GUID values in the following command.

$ curl -u "<key>:" https://<guid>.cloudapp-enterprise.appcelerator.com/api/greet?username=Bob

Related Links