Build and Run Bookstore Application Image
After you have generated the Bookstore application configuration YAML file from application DAA, you can build the Bookstore application Docker image. In this tutorial, you will build the Bookstore application Docker image and run it in the Docker or Kubernetes.
- Procedure
- Navigate to amsgce-runtime-<version>/runtime/build.
-
To build the bookstore application Docker image, run the following command. Specify the location of the folder or the
.zipfile that contains the YAML file, DAA, and optionally, the Log4j and JVM configuration files by using--app_locationargument. To check the options you can specify when running the command, run the following command:./build_amxce.sh --help
./build_amxce.sh --image_tag bookstore:1.0 --app_location amsgce-runtime-<version>/samples/bookstore/deployment/com.tibco.restbt.sample.bookstore.zip -
Execute the
docker runcommand on the machine where you have created the application Docker image.docker run -d -p 7777:7777 --name bookstore bookstore:1.0The external port must be a port number that is used at the time of resource template creation. If you want to map a different port other than the port used for the YAML file, you can specify it when running the docker run command. If there are two HTTP connectors in the DAA, then while creating the container, you need to specify both the ports.
-
Check whether the container is created or not by running the following command:
docker ps
- Access the application from
http://<hostname>:7777/bookstore/books. Here, port must be the port you mapped when running the container.
Running Bookstore Application in Kubernetes
After you have built the Bookstore application Docker image, you can deploy the application in Kubernetes.
- Create a Kubernetes deployment YAML file that is required to deploy an application. Sample YAML file is at
amsgce-runtime-<version>\samples\bookstore\deployment\bookstore-deployment.yaml. Ensure that the Kubernetes deployment file contains correct application image name and port. -
Run the
applycommand ofkubectlutility to deploy an application to Kubernetes.kubectl apply -f bookstore-deployment.yaml - Access this application at
http://<hostname>:31090/bookstore/books.
Bookstore application is now running in the Kubernetes. You can monitor the status of the running application and troubleshoot by using the Application Monitor. In the next step you will build and run the Application Monitor.