isaac-jordan / django-production-quickstart

A quick-start repository that sets you up with a production-ready Django site deployed on AWS Lambda

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

django-production-quickstart

A quick-start repository that sets you up with a production-ready Django site deployed on AWS Lambda

Getting Started

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.

Prerequisites

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

Installing

A step by step series of examples that tell you how to get a development env running.

  1. Fork the Django Production Quick-Start repository.

  2. Choose and set a name for your project (letters and spaces only, keep it short):

    export DJANGO_PROD_QUICKSTART_NAME="My New Website"
    
  3. 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"
    
  4. 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
    
  5. Install required dependencies

    pip install -r requirements.txt
    
  6. Apply the database migrations locally

    python manage.py migrate
    

Each development session

  1. 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
    
  2. Run the dev server locally

    python manage.py runserver
    # Now open localhost:8000 on your browser
    
  3. Open localhost:8000 in your browser

    1. When first opening, you should see your chosen name as the page title

TODO: Running the tests

Explain how to run the automated tests for this system

Break down into end to end tests

Explain what these tests test and why

Give an example

And coding style tests

Explain what these tests test and why

Give an example

Deployment

  1. (If using GitHub) Get a GitHub personal access token with repo scope permission

    export GITHUB_OAUTH_TOKEN=<your token>
    
  2. Set environment variables pointing to your repository (examples below)

    export GITHUB_USER=Sheepzez
    export GITHUB_REPO=django-production-quickstart
    
  3. Set up some AWS credentials

    aws configure
    
  4. 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

  5. Replace secret variables with production values

    1. Sign into AWS Console
    2. Find your new lambda
    3. 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.

Built With

  • Django - The web framework used

TODO: Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

TODO: Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

  • Isaac Jordan - Initial work - Website

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

About

A quick-start repository that sets you up with a production-ready Django site deployed on AWS Lambda

License:MIT License


Languages

Language:Python 51.6%Language:HTML 29.3%Language:Shell 19.0%