AWS Docker
Objective
Learn how to set up an EC2 machine on AWS.
Steps
- Create an AWS account
- Create a new EC2 instance
- Specify which image to use
- Create & Download a certificate
- Create and associate an IP address
- Connect to the Machine using the AWS certificate
Download the pre-requisites, the installer & run the Installer pre script on Amazon EC2
Step 1: Create an AWS account
- Begin by Creating an AWS account → Click Here.
- Follow the steps of the AWS wizard
Step 2: Create a new EC2 Instance
- Under the Services dropdown list pick EC2 then click on Launch Instance.
- Specify Community AMIs from the left side bar menu, then pick ubuntu.
- Pick the instance's Image
- Select ubuntu/images/hvm-ssd/ubuntu-xenial-16.04-amd64-server-20170721
- Choose an instance type
- t2.medium to deploy SOAJS
- t2.large to deploy SOAJS with Analytics
- In step 6 Configure security groups, add 5 rules:
- Type: HTTP, Port Range: 30080, Source: 0.0.0.0/0
- Type: Custom TCP, Port Range: 2376, Source: 0.0.0.0/0
- Type: Custom TCP, Port Range: 2377, Source: 0.0.0.0/0
- Type: Custom TCP, Port Range: 32017, Source: 0.0.0.0/0
- Click Review and Launch so that the new instance starts.
- Create & Download a Certificate
- From the left sidebar click on Key Pairs under NETWORK & SECURITY
- Create a new Key Pair and give it a name
- AWS will ask you to download and save the certificate
- Create and Associate an IP address
- In the left menu click on Elastic IPs under NETWORK & SECURITY
- Click on Allocate new address
- Link it to the machine instance created
Choose an Image for your Instance |
---|
Update Firewall Rules |
---|
Choose Instance Resource Flavor |
---|
Instance Options Menu |
---|
Step 3: Connect to the Machine on your Local Machine
Add the downloaded certificate my-key-pair.pem file of Step 2 to your local .ssh folder:
Connect to the Machine
# copy certificate to your ssh folder > mv my-key-pair.pem ~/.ssh/my-key-pair.pem > cd ~/.ssh/ > chmod 400 my-key-pair.pem # connect to the machine using certificate > ssh -i my-key-pair.pem ubuntu@machine-ip-address
Step 4: Download the pre-requisites, the installer & run the Installer pre script on Amazon EC2
Once you SSH to the machine, you can download and run the installer pre installation script to get all the dependencies so that cloud deployment works.
Prepare the machine
Download & Run SOAJS Installer pre scripts
# download update apt-get, download nodejs-legacy, npm and zip > sudo su > apt-get update && apt install nodejs-legacy npm zip # download installer > mkdir -p /opt/soajs/node_modules > cd /opt/soajs/node_modules > sudo npm install soajs.installer # run installer pre script > cd soajs.installer/scripts/pre > sudo /opt/soajs/node_modules/soajs.installer/scripts/pre/docker-linux.sh <%YOUR_CUSTOM_DOMAIN%>
Download Docker Certificates
Zip and Download the generated docker certificates from the above step to your local machine.
zip certificates on EC2
> cd ~ > zip -r certs.zip certs/* > mv ~/certs.zip /home/ubuntu/
From here on, use the installer from your local machine to deploy SOAJS on the remote EC2 machine you created.