In this module, you will transform your application with app2container. The Extract and Containerize phase activities depends on whether you are running all steps on the application server, or are using the application server for the analysis and a worker machine for containerization and deployment. In this scenario ( Containerize your java app), you will be running all below steps on the application server.
Separating containerization environment using worker machine is a best practice and provides you security and functional benefits. Worker machine option is used In the next scenario Containerize your .NET app.
Run the following commands to start the containerization process, replace <java-app-id> with your Java Application ID.
app2container containerize --application-id <java-app-id>
root@ip-10-0-0-129:/home/ubuntu# app2container containerize --application-id java-tomcat-21fb1eb0 ✔ AWS prerequisite check succeeded ✔ Docker prerequisite check succeeded ✔ Extracted container artifacts for application ✔ Entry file generated ✔ Dockerfile generated under /root/app2container/java-tomcat-21fb1eb0/Artifacts ✔ Generated dockerfile.update under /root/app2container/java-tomcat-21fb1eb0/Artifacts ✔ Generated deployment file at /root/app2container/java-tomcat-21fb1eb0/deployment.json 👍 Containerization successful. Generated docker image java-tomcat-21fb1eb0 💡 You're all set to test and deploy your container image. Next Steps: 1. View the container image with "docker images" and test the application. 2. When you're ready to deploy to AWS, please edit the deployment file as needed at /root/app2container/java-tomcat-21fb1eb0/deployment.json. 3. Generate deployment artifacts using "app2container generate app-deployment --application-id java-tomcat-21fb1eb0"
Now, you have your docker image ready. You can verify this by running the command below.
root@ip-10-0-0-129:/home/ubuntu# docker images REPOSITORY TAG IMAGE ID CREATED SIZE java-tomcat-21fb1eb0 latest 5e382c3f2e6a 3 minutes ago 715MB ubuntu 18.04 2c047404e52d 6 weeks ago 63.3MB
With this step, you have successfully containerized your application. It is now ready to be deployed on AWS.
When you run “App2container containerize” command, it automatically creates a deployment.json file. This file includes AWS deployment configuration. You can update this file to customize the deployment in your AWS environment. E.g. You can select specific VPC for your target environment or define cpu/memory allocation setting for your container..
In this workshop, you will need to check 2 places.
Ensure “createEcsArtifacts” is set to “true”.
Notice that “deployTarget” is set to “FARGATE” below. You can set this to “EC2” if you want the control to manage the ec2 instances that host your containers.
Enter your Target vpc-id to deploy your application into your target network.
Exit from the file with “ctrl+x” and type “y” and hit enter to save the file with the same name.
If you dont update your VPC-ID in deployment.json file, app2container will deploy your application into the Default VPC.
Congratulations! You have defined all your target AWS configuration settings and ready to deploy your application.
In the next section you will create deployment artifacts for your deployment.