In the previous step, we pushed the Docker image to ECR. Now, we will pull the Docker image from ECR to build a Docker container.
Reconnect via SSH to the EC2 instance in the production environment from the EC2 instance in the development environment.
To pull the Docker image, we need the URI of the Docker image. Go to the details of the Docker image in the repository on ECR and copy the URI.
Login to Docker, using the same command from the previous step.
The Docker image has now been successfully pulled.
After pulling the image, we will start the Docker container using this Docker image.
There are several prompts where you need to select options:
The script will continue running for a while, and there may be additional prompts requiring confirmation. Once everything is downloaded and set up, the web server will start using pm2.
Now, when checking the target status in the Load Balancer imga-nlb
, you should see that the target (the EC2 instance in the production environment) is healthy with the status Healthy.
Go to API Gateway, retrieve the API endpoint, and test it to see the result.
The reason the API can be tested through a request to the server is that we set Access-Control-Allow-Origin to *.
This means our web server is now operational.