Deploying an Application on ECS
You can deploy an application on ECS and monitor the application logs by configuring the container with CloudWatch.
- Ensure that you have the TIBCO BusinessWorks Container Edition application EAR and Docker files in the same directory.
- In the Docker file, ensure that the EAR file name and path are correct.
- In the Docker file, ensure that the base image points to the TIBCO BusinessWorks™ Container Edition runtime base image, which is created by the CloudFormation template.
- Procedure
- To view the runtime base image, go to
.
The Repository URI is shown as
<AWS_account_id>.dkr.ecr.<region_name>.amazonaws.com/tibco-bwce
- Retrieve the docker login command that is used to authenticate your Docker client with your registry.
aws ecr get-login --no-include-email --region <region_name>
Note: If you receive an Unknown options: --no-include-email error, install the latest version of the AWS CLI. For more details, see Installing the AWS Command Line Interface. - Run the docker login command that was returned in the previous step.
If you are using Windows PowerShell, run the following command.
Invoke-Expression -Command (aws ecr get-login --no-include-email --region <region_name>)
- To generate the application image, navigate to the folder where the EAR and Docker files are stored and run the following command. For information about building a Docker file, see
Docker Basics.
docker build -t <application_name> .
Note: You can skip this step if your image is already built. - After the build is ready, tag the image to push it to the repository.
docker tag application_name:latest <AWS_account_id>.dkr.ecr.<region_name>.amazonaws.com/application_name:latest
- Run the following command, to push the image to your newly created AWS repository:
docker push <AWS_account_id>.dkr.ecr.<region_name>.amazonaws.com/application_name:latest
Note: Ensure that you replace the <region_name> with your region such as ap-northeast-1 and Repository URI with the URI. - Create the services and task definition in ECS. A task definition is required to run Docker containers on Amazon ECS. Create task definition for
TIBCO Cloud™ Integration - BusinessWorks™ application. For more details, see
Amazon ECS Task Definitions.
The following is a sample taskdef.json file for reference.
{ "family": "launch-test-app", "containerDefinitions": [ { "image": "<AWS-account_id>.dkr.ecr.<region_name>.amazonaws.com/<repo_name>:latest", "name": "bwce-test-app", "cpu": 10, "memory": 512, "essential": true, "portMappings": [ { "containerPort": 8080, "hostPort": 8080 } ], "environment": [ { "name": "BW_LOGLEVEL", "value": "DEBUG" } ], "logConfiguration": { "logDriver": "awslogs", "options": { "awslogs-group": "bwce-app-log", "awslogs-region": "<region_name>", "awslogs-stream-prefix": "bwce" } } } ] }
- Run the following command to tegister the task definition in the repository:
aws ecs register-task-definition --family <family_name_for_your_app> --cli-input-json file://<taskdef_path>.json/> --region <aws_region>
- Run the following command using the task definition to create a new service for your application. You can optionally configure your service to use load balancer to distribute traffic evenly across tasks in your service. For more details, see
Services in Amazon ECS Documentation.
aws ecs create-service --service-name <Your_service_name> --desired-count 1 --task-definition <your_family_name> --load-balancers targetGroupArn=<your_target_group_arn>,containerName=<container_name>,containerPort=<container_Port> --role <your_IAM_role_Arn> --cluster <your_cluster_name>
After the container is automatically configured with CloudWatch logs in taskdef, you can check your application logs in the service created in the ECS cluster.
You can also manually configure the CloudWatch. For more details, see Amazon Cloud watch Logs.
After the service is successfully running and the target group status is healthy, you can hit the load balancer URL according to the listener and target group configured in load balancers.