Build the Flogo Application Docker Image

Build the application docker image by extending the runtime base docker image and copying the app binary into it.

To do this, follow the steps below:

Procedure

  1. Tag the Flogo Runtime Docker Image. For example, use flogo-runtime:<version>
  2. Create a Docker file in the directory containing the Flogo app binary and add the following commands to the Docker file.
    FROM <FLOGO_RUNTIME_IMAGE>:<TAG> 
    ADD <FLOGO_APP_BINARY_NAME> flogoapp
    Note: You must configure the application binary as flogoapp before you can run it.
    For example:
    FROM flogo-runtime:latest 
    ADD hello_world-linux_amd64 flogoapp
    FROM flogo-runtime:2.7.0 
    ADD hello_world-linux_amd64 flogoapp
  3. Run the docker build command to build the app docker image.
    docker build -t <APP_IMAGE_NAME>:<TAG>
  4. Tag the image using the Docker tag command:
    docker tag application_name:latest
    <AWS_account_id>.dkr.ecr.<region_name>.amazonaws.com/application_name:latest
  5. Push the app docker image to the newly created AWS repository using the Docker push command:
    docker push <AWS_account_id>.dkr.ecr.<region_name>.amazonaws.com/
    application_name:latest

    For more information about ECR, see the ECR documentation.

  6. Run the app container in ECS using Fargate.
    1. Download the following deployment templates:
      • Set up a Fargate Stack for Flogo app deployment
      • Run Flogo app on Fargate

      For more information about deployment templates, refer to About AWS Deployment Templates.

    2. On AWS, navigate to CloudFormation in Services.
    3. Using the Create Stack option, create a stack for the Set up a Fargate Stack for Flogo app deployment template. Upload the Set up a Fargate Stack for Flogo app deployment template. Provide a unique name for the stack, continue clicking Next, and then click Create Stack.
    4. Using the Create Stack option, create another stack for the Run Flogo app on Fargate template. Upload the Run Flogo app on Fargate template. Provide a unique name for the stack in the Stack name field. Provide the ECR image URL in the ImageURL field. In the StackName field, use the same name that was used in step c (for Set up a Fargate Stack for Flogo app deployment template). Continue clicking Next and click Create Stack.
    5. On AWS, navigate to ECS in Services. The cluster you created is displayed.
    6. Navigate to the service in the cluster. After the service is successfully running, you can access the load balancer URL.
  7. For ECS and ECR, while configuring the task definition, set and attach the following policy to the IAM role configured for the task. Otherwise, the app will not start:
    {  
      "Version":"2012-10-17",
      "Statement":[
         {
           "Action":[
             "aws-marketplace:RegisterUsage"
          ],
           "Effect":"Allow",
           "Resource":"*"
          }
       ]
    }

    See the Amazon website for more information regarding the use and licensing of the Amazon Linux Docker Image.