The following instructions describe how to deploy an extended user authentication Django web application using an AWS CloudFormation stack and docker-compose.
- Create cloudformation stack
- Edit .env values
- Build and push docker image to DockerHub
- Launch docker-compose to run container on AWS
- Clone github repository to a new directory on local machine
- Create EC2 key pair in AWS management console and save to project folder directory
- Open
fullstack.yml
and replace theMyKeyName
parameter with your KeyPair (line 26) - Run aws cloudformation command in
proj_commands.sh
- Once completed, open the
Outputs
tab on the CloudFormation page in AWS console. Save the access key id and secret access key in a text editor. - Open RDS instance on console, save RDS endpoint address to text file.
- Open EC2 instance next, and save Public IP address and Public DNS address to text.
- Open
.env.example
file in text editor and rename file to.env
- Replace
aws_s3_access_key_id
andaws_s3_secret_access_key
with the values from CloudFormation Outputs - Replace
RDS Host
with RDS endpoint obtained from previous step. - (optional) Replace
django_key
with a random secret key that can be generated from https://www.miniwebtool.com/django-secret-key-generator/ - Save changes and exit
.env
- Open
proj_commands.sh
and replace all instances ofbaraka215/docker-aws
withyourdockerhubname/[yourprojectname]
- Also, in
proj_commands.sh
replace DOCKER_HOST ip address with your EC2 ip address obtained from AWS console - Open
docker-compose.yml
and replacebaraka215/docker-aws
withyourdockerhubname/[yourprojectname]
- Run docker build, docker image tag and docker image push commands
- Run the remainder of docker-compose commands in
proj_commands.sh
(enter yes when prompted during collectstatic) - After
docker-compose up -d
is executed, go to EC2 public DNS address and baraka_docker_aws website will be up and running. - Explore site: register new users, subscribe to plans, change passwords, edit user profiles, view home page and pricing plans
- To stop and remove containers, networks, volumes, and images created by up:
docker-compose down -v --rmi all
- Create a django superuser to access Django's admin interface:
docker exec -it <container id> bash
- Once inside the running container type:
python manage.py createsuperuser
- Fill out usrname, email, password
- Access admin page and login as new superuser:
ec2publicDNS/admin