A quick-start repository that sets you up with a production-ready Django site deployed on AWS Lambda
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
This repository assumes Python 3, and running on Mac or Linux for now.
sudo add-apt-repository ppa:deadsnakes/ppa # For Python3.7 PPA
sudo apt update
sudo apt install build-essential python3.7 python3.7-venv python3.7-dev awscli
A step by step series of examples that tell you how to get a development env running.
-
Fork the Django Production Quick-Start repository.
-
Choose and set a name for your project (letters and spaces only, keep it short):
export DJANGO_PROD_QUICKSTART_NAME="My New Website"
-
Rename the Django app module and mentions of Django Production Quick-Start:
./set_up_new_project.sh && git add -A && git commit -m "Finish set-up using Django Production Quick-Start"
-
Create a Python virtual environment to use:
# Uses an environment variable set up when you ran ./set_up_new_project.sh python3.7 -m venv ~/envs/$PYTHON_MODULE_QUICKSTART_NAME && source ~/envs/$PYTHON_MODULE_QUICKSTART_NAME/bin/activate
-
Install required dependencies
pip install -r requirements.txt
-
Apply the database migrations locally
python manage.py migrate
-
At the start of each development session, enable the virtual environment in your terminal.
# Specific env name will have been printed when you first ran ./set_up_new_project.sh source ~/envs/"$PYTHON_MODULE_QUICKSTART_NAME"/bin/activate
-
Run the dev server locally
python manage.py runserver # Now open localhost:8000 on your browser
-
Open localhost:8000 in your browser
- When first opening, you should see your chosen name as the page title
Explain how to run the automated tests for this system
Explain what these tests test and why
Give an example
Explain what these tests test and why
Give an example
-
(If using GitHub) Get a GitHub personal access token with
repo
scope permissionexport GITHUB_OAUTH_TOKEN=<your token>
-
Set environment variables pointing to your repository (examples below)
export GITHUB_USER=Sheepzez export GITHUB_REPO=django-production-quickstart
-
Set up some AWS credentials
aws configure
-
Create the CodePipeline pipeline, and commit the definition file
./create_pipeline.sh && git add -A && git commit -m "Update pipeline stack definition"
Future pipeline changes required can be made directly to pipeline.yml, and just re-run
./create_pipeline.sh
to update the CFN stack -
Replace secret variables with production values
- Sign into AWS Console
- Find your new lambda
- Remove "PLACEHOLDER_" from environment variable names, and fill out values for production
During the next deploy, the "PLACEHOLDER_" variables will re-appear, but these can just be left. Your custom values will be left untouched.
- Django - The web framework used
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
We use SemVer for versioning. For the versions available, see the tags on this repository.
- Isaac Jordan - Initial work - Website
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE.md file for details
- PurpleBooth for this README template
- symphoniacloud for CloudFormation/CodePipeline examples
- mdjnewman for https://gist.github.com/mdjnewman/b9d722188f4f9c6bb277a37619665e77