What was used to build this site

Python, Flask, Docker & Docker Compose, HTML, BootStrap, AWS Lightsail


Personal website has been stale for a while, needed refresh. For the fun it decided to use Python, Flask, Docker, Bootstrap and a pre-made template and AWS Lightsail for hosting. Caveat, I'm on Mac, most of the instructions should be OS agnostic.


Create Website

This is beyond the scope of this, all you really need to do just see something is create your typical Hello World

Create AWS Lightsail container

Assuming you have AWS CLI installed and your Access Key ID and Secret set along with region, you might run into the region error if just include the --region parameter and indicate the region of your choice.

aws lightsail create-container-service --service-name jasonlam604-website --power nano --scale 1 --region us-east-1

You will then see a response similar to this one:

    "containerService": {
        "containerServiceName": "jasonlam604-website",
        "arn": "arn:aws:lightsail:us-east-1:007085163428:ContainerService/ed8986a4-1623-4811-862a-7507e0f42a0c",
        "createdAt": "2022-02-19T18:55:45-08:00",
        "location": {
            "availabilityZone": "all",
            "regionName": "us-east-1"
        "resourceType": "ContainerService",
        "tags": [],
        "power": "nano",
        "powerId": "nano-1",
        "state": "PENDING",
        "scale": 1,
        "isDisabled": false,
        "principalArn": "",
        "privateDomainName": "jasonlam604-website.service.local",
        "url": "https://jasonlam604-website.m6lof1uganufc.us-east-1.cs.amazonlightsail.com/"


Push Container

Now push your docker image up

aws lightsail push-container-image --region us-east-1 --service-name [name-of-your-service] --label [your-label] --image [docker-image-name] In AWS under lightsail you should soon see your image, noticed the version assuming this is your first image will have suffix of "1". This is important for when deciding which image to deploy.

Deploy Container

There are 2 files you need to create prior to deploying, one of which is containers.json file, it will contain the following:

    "jasonlam604-website": {
        "image": ":jasonlam604-website.jasonlam604-website.1",
        "ports": {
            "5000": "HTTP"
Note of course you will need the change label to your label and the image name that matches the image name you assigned your docker container to.

The second file you need to add is public-endpoint.json, only required if you intend to expose the container externally in this case I am:
    "containerName": "jasonlam604-website",
    "containerPort": 5000
Rename the containerName according to your container name.

Now execute the following, with your settings: aws lightsail create-container-service-deployment --region us-east-1 --service-name jasonlam604-website --containers file://containers.json --public-endpoint file://public-endpoint.json