Work in teams to build and deploy your first containerised application to the Cloud!
Goals for the week
Can you, with only a specification to guide you, work as part of a team to build and deploy a containerised web app?
Finally, you should be also able to understand what the following concepts are and in which ways they are helpful for applications running on the cloud: logging
and telemetry
โข One member in your group, create a GitHub repo for your Hello Cloud World!
project.
โข Add the other members of your group as collaborators.
โข Create a simple Node.js
project using Express.
The idea is for you to choose what you would like to render on the page and see on the web when your application is on the cloud. Choose something that you'd like to show to your friends!
โข See our Trello Board for more information: Group2-Hello-Cloud-World-Week-1
FORMULAS
What things you need to install the software and how to install them.
-
Embedded below is essentially the simplest Express app you can create. It is a single file app โ not what youโd get if you use the Express generator, which creates the scaffolding for a full app with numerous JavaScript files, Jade templates, and sub-directories for various purposes.
-
As for planning, the team agreed on creating something fun, engaging, and interactive! We were also concerned with time and the amount of DevOps concepts we'll be squeezing in this week to learn from. We decided by focusing on a simple, MVP ( Minimal Viable Product)- this would allow us enough wiggle room to assess and process our findings while researching on
containers
,telemetry
,logging
, andAWS EBS
First, create a directory named myapp
, change to it and run
npm init
Then, install express as a dependency, as per the installation guide
In the myapp directory, create a file named app.js
and copy in the code from the example above.
The req (request) and res (response) are the exact same objects that Node provides, so you can invoke req.pipe()
, req.on('data'
, callback)
, and anything else you would do without Express involved.
Run the app with the following command:
$ node app.js
Then, load http://localhost:3000/ in a browser to see the output.
const express = require('express')
const app = express()
const path = require('path')
const port = 3000
app.use(express.static(__dirname + '/public')); // tells express to look at everything in the public folder
// renders the index.html (homepage)
app.get('/', (req, res) => {
res.sendFile('index.html');
//res.send('Hello World!')
})
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`)
})
We then set up the Docker file: Please follow tutorial here, docker
Create the Dockerfile:
// tells Docker what base image we would like to use for our application.
Docker images can be inherited from other images. Therefore, instead of
creating our own base image, weโll use the official Node.js image that
already has all the tools and packages that we need to run a Node.js application. //
FROM node:12.18.1
ENV NODE_ENV=production
WORKDIR /Hello-Cloud-World
COPY ["package.json", "package-lock.json*", "./"]
RUN npm install --production
# The COPY command takes all the files located in the current directory and copies them into the image.
COPY . .
EXPOSE 3000
CMD ["node", "app.js"]
How to get AWS Elasticbeanstalk up and running.
To help you understand how AWS Elastic Beanstalk works, this tutorial walks you through creating, exploring, updating, and deleting an Elastic Beanstalk application. It takes less than an hour to complete.
There is no cost for using Elastic Beanstalk, but the AWS resources that it creates for this tutorial are live (and don't run in a sandbox). You incur the standard usage fees for these resources until you terminate them at the end of this tutorial. The total charges are typically less than a dollar. For information about how to minimize charges, see AWS free tier.
Topics
- Setting up: Create an AWS account
- Step 1: Create an example application
- Step 2: Explore your environment
- Step 3: Deploy a new version of your application
- Step 4: Configure your environment
- Step 5: Clean up
- Next steps
If you're not already an AWS customer, you need to create an AWS account. Signing up enables you to access Elastic Beanstalk and other AWS services that you need.
To sign up for an AWS account
-
Open the Elastic Beanstalk console, and in the Regions list, select your AWS Region.
-
Follow the instructions shown.
End with an example of getting some data out of the system or using it for a little demo.
Explain how to run the automated tests for this system.
Explain what these tests test and why
Explain what these tests test and why
-------------------------------------------|-----------------------|
docker run -dp 3000:3000 hello-cloud-world | Runs code |
-------------------------------------------|-----------------------|
docker ps (lists) | Lists |
-------------------------------------------| ----------------------|
docker ps -a | (lists all commands) |
-------------------------------------------|-----------------------|
For a full list of docker commands visit:docker list of commands
Dont forget to turn off/stop the container images when running, deleting, adding or editing files.
Please find DevOps cheat sheets for the command line here:
{
"AWSEBDockerrunVersion": "1",
"Image": {
"Name": "cgloker/hello-cloud-world-v3"
},
"Ports": [
{
"ContainerPort": "3000"
}
]
}
Bootstrap 4 - 'Sketchy' Theme docker desktop MacOS dockerfile GitHub Actions - Docker and Node.Js Packages Docker+Github Actions - BuildX CSS HTML Jquery ElasticBeanstalk(AWS) IAM Account
- Express - Web/Server Framework
- docker - Server Framework
- Bootstrap - Some modals We took for Styling
- NodeJs - Server Environment
- DEPLOYED
- EBS - Cloud
GitHub Actions + Docker and Node.Js Packages
IAM ACCOUNTS - EBS [AWS]