This repository contains the code for this blogpost.
Kindly ensure you have the following installed on your machine:
Running the App
> git clone https://github.com/raunak-r/django_ec2.git
Open Docker (WINDOWS, See DockerFile first 3 lines.)
> cd <path>/django_ec2/
> docker build -t django_ec2 -f .\deployment\dockerfile .
> docker run -p 8000:8000 django_ec2
Visit localhost:8000 on Chrome.
- Launch EC2 instance as outlined in this article
- Download .pem file (this is the private key for the ec2)
- Open WSL
> cp private key to the wsl .ssh folder
> chmod 400
> ssh -i private-key.pem ec2-username@ec2-link.amazonaws.com
> sudo yum upgrade
> sudo yum install git
> git clone https://github.com/raunak-r/django_ec2.git
> docker build -t django_ec2 -f ./deployment/dockerfile .
> docker run -p 8000:8000 django_ec2
Visit ip-addr:8000/ on Chrome on Local
- Clone the repository
$ git clone https://github.com/ro6ley/django_ec2.git
- Check into the cloned repository
$ cd django_ec2
- If you are using Pipenv, setup the virtual environment and start it as follows:
$ pipenv install && pipenv shell
- Install the requirements
$ pip install -r requirements.txt
- Start the Django API
$ python manage.py runserver
-
Navigate to
http://localhost:8000 -
Build the Docker image:
$ docker build . -t django_ec2
- Publish the Docker image to Dockerhub:
$ docker tag django_ec2 <DOCKERHUB_USERNAME>/django_ec2
$ docker push <DOCKERHUB_USERNAME>/django_ec2
- Deploy on AWS EC2 as outlined in this article