raunak-r / django-AWS

Plain simple deployment of a Django project to an EC2 instance, using S3 for storage & RDS (Postgres) for the DB.

Home Page:https://stackabuse.com/deploying-django-applications-to-aws-ec2-with-docker/

Repository from Github https://github.comraunak-r/django-AWSRepository from Github https://github.comraunak-r/django-AWS

HitCount

Django EC2

This repository contains the code for this blogpost.

Getting Started

Prerequisites

Kindly ensure you have the following installed on your machine:

Running the Application

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.

Setting Up EC2

  1. Launch EC2 instance as outlined in this article
  2. Download .pem file (this is the private key for the ec2)
  3. 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

OLD COMMANDS FROM Ro6ley's README

Setting up everything for your development

  1. Clone the repository
$ git clone https://github.com/ro6ley/django_ec2.git
  1. Check into the cloned repository
$ cd django_ec2
  1. If you are using Pipenv, setup the virtual environment and start it as follows:
$ pipenv install && pipenv shell
  1. Install the requirements
$ pip install -r requirements.txt
  1. Start the Django API
$ python manage.py runserver
  1. Navigate to http://localhost:8000

  2. Build the Docker image:

$ docker build . -t django_ec2
  1. Publish the Docker image to Dockerhub:
$ docker tag django_ec2 <DOCKERHUB_USERNAME>/django_ec2
$ docker push <DOCKERHUB_USERNAME>/django_ec2
  1. Deploy on AWS EC2 as outlined in this article

About

Plain simple deployment of a Django project to an EC2 instance, using S3 for storage & RDS (Postgres) for the DB.

https://stackabuse.com/deploying-django-applications-to-aws-ec2-with-docker/

License:Apache License 2.0


Languages

Language:Python 89.2%Language:Dockerfile 10.8%