Step 1

Access AWS!!!

  • access aws

  • Set your region to Ohio

  • Find EC2, should be there.

  • Navigate to instances

  • Find NCS.cf Yeung CSP or NCS.gq Mort CSP and click connect.

  • Type in cd ~

  • Run the commands below:

First you type in: $ virtualenv -p /usr/bin/python3 webapp

Then type: $ source webapp/bin/activate

Step 2

PORTS!!!

  1. Run sudo docker ps

You should see a huge list of ports regarding your project name.

Select a port that is not in use, anything in the 8000s.

Then go to your backend repo, this is your flask.

Make sure your Dockerfile matches what it says below:

Now Type in sudo docker-compose up in your terminal

After that type in the link in your browser: something like https://localhost:PORTNUMBER.. if this works, push your changes and your good.

Step 3

AWS!!!

In the AWS terminal;

  • go to your repo by cding

  • git clone your flask

  • run $ pip install -r requirements.txt

  • go to main.py file and run python3 main.py, if it works, good job.

  • now type in docker-compose up -d --build

  • now curl your site by typing - curl localhost:PORTNUMBER

  • If it shows you a bunch of HTML, this is a good sign and now your almost done.

NGINX stuff via Azeem Khan & Jeffery F.

So it turns out Jeffery created a pretty good guide for nginx stuff, here is a link to access it: Jeffrey's guide to duckdns

make sure to create your own config file: you can type in $ sudo nano PROJECTNAME

My friend Azeem did a great job by including how your config file should look like so here it is:

  • save changes - CTRL X

  • create a link:

$ cd /etc/nginx/sites-enabled

$ ln -s /etc/nginx/sites-available/PROJECTNAME/etc/nginx/sites-enabled

then type $ sudo nginx -t

  • now you have to restart so run:

sudo systemctl restart nginx

  • check if it works on chrome or your preferred browser.

Step 4

Certification stuff

Certbot allows your site to be HTTPS, this is good.

Run commands below

$ cd

$ sudo snap install core; sudo snap refresh core

$ sudo snap install --classic certbot

$ sudo ln -s /snap/bin/certbot

$ sudo certbot --nginx

My friend Azeem helped me understand why we need https and a valid certificate, he taught me to run these commands.

Final Step

What if I wanted to change code or any other stuff?

  • cd to your project

  • type:

sudo docker-compose ps

  • now type:

sudo docker ps

  • run: git status (to see if there are changes)

  • type in:

sudo docker-compose kill

now it should say 502 BAD GATEWAY

  • make sure to git pull

  • type in:

sudo docker-compose up -d --build

  • restart:

sudo systemctl restart nginx

  • cd into your project and type in curl localhost:PORTNUMBER

You can probably see changes saving

  • now type in your url in browser and see if the changes saved.

If it did, good job, it worked!

Acknowledgements

Azeem Khan helped me understand a few steps regarding this blog, Jeffery also made a good nginx guide, so I am willing to acknowledge them for helping me develop this guide.

Thank you