• 沒有找到結果。

Building the App

在文檔中 TIBCO Flogo® Enterprise User's Guide (頁 144-147)

After you have created your app, you have the option to either export the app (without building it) or build it. Exporting an app allows you to import it elsewhere, for example in TIBCO Cloud Integration - Flogo®. When you build the app, its deployable artifact gets created and downloaded to your local machine. Each operating system has its own build target. You must select the right target for your operating system when building the app. You can use the built artifact to run the app in Flogo Enterprise.

Be sure that you have Docker installed on your machine. Refer to the product Readme for the supported versions of Docker.

Follow these steps to build an app:

For app binaries that were created in Flogo Enterprise 2.5 or older versions, if the app binary was created using an <app>.json file and contains a flow starting with a trigger and the app binary was created from the CLI using the build tool, the app gets successfully built but throws an error at runtime.

Procedure

1. Open the Apps page in Flogo Enterprise.

2. Click the app that you want to build to open the page for that app.

3. Click the Validate button to explicitly validate the flows and activities in the app. Fix any errors before pushing the app.

4. Click Build.

You see the following build target options:

5. Click the build target option that is compatible with your operating system.

The app begins to build. When done, the deployable artifact gets downloaded to your local machine. In the case of Docker, a Docker image gets created in your Docker storage area.

Any uppercase letters in your app name get converted to lowercase in the Docker image name.

For instance, if your app is named MyApp, the Docker image that gets generated will be named

myapp.

6. To run the app, follow these steps:

On Macintosh and Linux

1. Open a terminal.

2. Run: chmod +x <app-file-name>

3. Run: ./<app-file-name>

For Docker Image

Any uppercase letters in your app name get converted to lowercase in the Docker image name.

For instance, if your app is named MyApp, the Docker image that gets generated will be named

myapp. So be sure to use all lowercase letters in the app-file-name in the command below.

1. Open a terminal.

2. Run: docker run -p <<host-port-number>>:<port-on-docker> flogo/<app-file-name>

Building the App From the CLI

You have the option to build an app using the Flogo Enterprise command line interface (CLI).

Prerequisites

Make sure that you have Go programming language version 1.11.4 or above installed on the machine from which you plan to run the build command.

Procedure

1. Open a command prompt or terminal window depending on your platform.

2. Navigate to the <FLOGO_HOME>/<version>/bin folder.

If you saved the Flogo Enterprise command line interface ( builder-<platform>) in a folder that is different from the default <FLOGO_HOME>/<version>/bin folder, you must export the

FLOGO_HOME environment variable before you run the command for the builder. Run the following:

export FLOGO_HOME=<FLOGO_HOME>/<version>

./builder-<platform> build <option(s)>

3. Run the following command (refer to the topic on the builder Command for details):

On Windows: builder-windows_amd64.exe help

On Macintosh: builder-darwin_amd64 help

On Linux: builder-linux_amd64 help

Builder Command

Use the builder command to build a Flogo Enterprise app from the command line.

Binary Types

You can build either one of these binary types from the command line:

Flogo app binary - contains the Flogo runtime + only those connectors used by that app.

Flogo engine binary - contains the Flogo runtime + all the connectors that are present in your Flogo Enterprise installation. The advantage of creating such a binary is that it can run any Flogo app that uses one or more connectors included as a part of the binary. This will help reduce the number of binaries per app.

To view arguments and options for the build command, open a terminal, navigate to the <FLOGO_HOME>

\bin folder, and run the following:

On Windows: builder-windows_amd64.exe help build

Build the Flogo app binary or the Flogo engine artifact.

Options Description

-docker

(or)

-d

Build a Docker image of the Flogo app. A Docker image is created as:

flogo/<AppName>:<Tag>

On some older versions of Linux, if you use a Cisco AnyConnect VPN client, you will see an error in the Flogo Enterprise command line interface when generating a Docker image. Either disconnect from the VPN and restart Docker or use another VPN client such as OpenConnect.

-f Path to the JSON file for the Flogo app. Use this option only if you want to build a Flogo app binary.

-n

(or)

-name

Name of the binary file generated. If a name is not provided, a binary is generated in the following format:

<APPNAME>-<OS_NAME>_<OS_ARCH>

-o Path to the output folder where binary is created. By default, the binary is created in the current folder.

-p Build binary for specific platform. Value must be specified as

<OS_NAME>/<OS_ARCHITECTURE>. For example, linux/386 or linux/

amd64. Refer to https://golang.org/doc/install/source#environment for all supported operating systems and architecture combinations.

-v Enable verbose progress and debug output.

-tag

(or)

-t

Tag to be used if a Docker image is to be created. If a tag is not provided, the default is the latest.

Examples for creating the Flogo app binary

builder_darwin_amd64 build -f MyAPP.json

This command creates a binary of MyAPP.json on the Macintosh platform.

builder_darwin_amd64 build -p linux/amd64 -f /home/tibco/MyApp/

MyAPP.json -n Routing -o /home/tibco/MyApp/binary

This command creates a binary called Routing in the /home/tibco/MyApp/binary

folder for MyAPP.json. This binary can be run on the linux/amd64 platform.

builder_linux_amd64 build -f MyAPP.json -docker -tag=V1

This command builds a Docker image of MyApp.json on Linux/amd64. The image is created as flogo/MyApp:V1.

Example for creating the Flogo engine binary

builder_darwin_amd64 build -o <path-to-flogoengine_binary>

If you do not provide any options the engine binary is built with the default name in the format engine-<platform>-<architecture>

To run any compatible app using the <flogoengine_binary_name>, run the following command:

./<flogoengine_binary_name> --app <app-name.json>

Alternatively, you can create the Flogo engine binary by following these steps:

1. Rename <app-name.json> to flogo.json

2. Place the flogo.json file in the same directory as <flogoengine_binary_name>

3. Run: ./<flogoengine_binary_name>

Overriding an App's JSON File in the App Binary

While running the app binary, you can override the app binary's embedded JSON file with another JSON file by using the -app option. This saves you the time and effort of creating a new app binary if you only want to make minor configuration or mapping changes in the app.

To do this, run the following command:

On Windows: <app-filename>-windows_amd64 -app <new JSON file.json>

On Macintosh: <app-filename>-darwin_amd64 -app <new JSON file.json>

On Linux: <app-filename>-linux_amd64 -app <new JSON file.json>

You can make changes in your activities, export the app.json again, and run it with the same binary using the -app option. For example, you can make changes in an existing activity. However, if you add a new activity (of the same category or a different category) and try to run it from the app binary, it will not work.

在文檔中 TIBCO Flogo® Enterprise User's Guide (頁 144-147)