Skip to content

angest/DevOpsTest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Web Server

Overview

A simple web server that responds to GET /hello and responds with OK and a 200 status code.

Use on Local

Prerequisites

  • Node.js

Run

Start the server locally:

node ./app/server.js

Test

Send a request locally:

curl -v http://localhost:8080/hello

Use with Docker

Prerequisites

  • Docker

Build

Build the image locally:

docker build -t devops-test ./app

Run

Run the container with optional PORT environment variable (default 8080):

docker run -e PORT=8080 -p 8080:8080 devops-test

Test

Send a request locally:

curl -v http://localhost:8080/hello

Use in Cloud

Prerequisites

  • AWS CLI configured
  • Docker
  • Terraform

Infrastructure

terraform -chdir=infra init
terraform -chdir=infra apply

Get ecr_repository_url and lb_dns_name from output. For example:

ecr_repository_url = "022514024772.dkr.ecr.ap-southeast-2.amazonaws.com/devops-test"
lb_dns_name = "devops-test-1688647813.ap-southeast-2.elb.amazonaws.com"

Deploy

Push the image to ECR based on ecr_repository_url.

aws ecr get-login-password --region ap-southeast-2 | docker login --username AWS --password-stdin 022514024772.dkr.ecr.ap-southeast-2.amazonaws.com
docker buildx build --platform linux/amd64 -t devops-test ./app
docker tag devops-test:latest 022514024772.dkr.ecr.ap-southeast-2.amazonaws.com/devops-test:latest
docker push 022514024772.dkr.ecr.ap-southeast-2.amazonaws.com/devops-test:latest

Test

Send a request to ELB based on lb_dns_name.

curl -v http://devops-test-1688647813.ap-southeast-2.elb.amazonaws.com/hello

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published