In this section we will be building the application that used to scale our cluster. First, let’s download all the assets that we will need to build the application and image. Run the following command. We will use git to download the project and bring all the files needed to build our Monte Carlo microservice application:
cd ~/environment
git clone https://github.com/awslabs/ec2-spot-workshops.git
cd ~/environment/ec2-spot-workshops/workshops/karpenter
Great. We are now ready to build up our application, compile it first, build the docker image and finally push the image to Amazon ECR.
export APP_NAME=monte-carlo-sim
aws ecr get-login-password | docker login --username AWS --password-stdin $ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com
aws ecr create-repository --repository-name ${APP_NAME}
export MONTE_CARLO_REPO=$(aws ecr describe-repositories --repository-names ${APP_NAME} | jq -r '.repositories[0].repositoryUri')
echo "export MONTE_CARLO_IMAGE=$(echo ${MONTE_CARLO_REPO}:latest)" >> ~/.bash_profile
source ~/.bash_profile
docker build -f Dockerfile --tag ${MONTE_CARLO_IMAGE} .
docker push ${MONTE_CARLO_IMAGE}
echo "${MONTE_CARLO_IMAGE} image ready for use"
This process does take 2 to 3 minutes.
The steps above: