A simple web application that serves different content according to a given environment variable.
4.2K
A simple web application which serves different content according to a given environment variable.
Used for testing micro-services architectures.
Image is available at Dockerhub - unfor19/docker-cats
Available APP_NAME:
docker run --name cats --rm -p 8080:8080 -d -e APP_NAME=baby unfor19/docker-cats
Change the author
docker run --name cats --rm -p 8080:8080 -d -e APP_NAME=dark -e FROM_AUTHOR=darker unfor19/docker-cats
View the app in local browser via http://localhost:8080
docker build -t unfor19/docker-cats .
Before we even start, this is how the website should look like after a successful deployment - https://docker-cats-stg.meirg.co.il.
Create the following AWS resources in the AWS console
docker-cats-stgdocker-cats-stgecsTaskExecutionRole exists; The role is required by the AWS ECS Service to manage ECS Tasks, that includes pulling private images from ECR if necessary123456789012 with the relevant AWS account numberFARGATEdocker-cats-stg, Revision: select latest (previosuly created)docker-cats-stg-vpcdocker-cats-stg1docker-cats-stg (previosuly created)docker-cats-stg-subnet-publicAllow inbound from Cloudflare only, according to the following list - https://www.cloudflare.com/ips-v4
docker-cats and get the Security group ID# Requires AWS CLI and curl
export \
SECURITY_GROUP_ID="sg-0d7209c7061234567"
AWS_REGION="eu-west-1"
./scripts/set_inbound_cidr.sh
By default, Cloudflare proxies to known HTTPS ports.
I've set the app to listen on port 80 and allowed inbound access to port 80 only from Cloudflare's servers CIDR Ranges
Currently, there's an ECS Task which runs docker-cats and has a public IP. To access the application, add your IP address to the Security Group inbound rules on port 80 to check if it's running properly
APP_PUBLIC_IP="123.123.123.123"
curl -L "$APP_PUBLIC_IP"
If you see <html lang="en">... in the response, you're good to go.
Next up, mapping Cloudflare DNS record to the task's public IP with an A record. The downside, is that each time the ECS task restarts/stops, the public IP changes, we'll get to that.
docker-cats-stgpublic IP of ECS Task (keep the Proxied ON)docker-cats*.SELECTED_DOMAIN_NAME/* (my SELECTED_DOMAIN_NAME is meirg.co.il)Finally, docker-cats-stg.meirg.co.il is mapped in Cloudflare to proxy traffic to the public IP of the ECS task.
Final result - https://docker-cats-stg.meirg.co.il
Cloudflare --> meets AWS security group rules --> ECS Task public IP
Created and maintained by Meir Gabay
This project is licensed under the MIT License - see the LICENSE file for details
Content type
Image
Digest
sha256:84063a70a…
Size
61.6 MB
Last updated
about 4 years ago
docker pull unfor19/docker-cats