Git Product home page Git Product logo

django-template's Introduction

Django template

  1. Overview
  2. Running locally
    1. Running with Docker
      1. Build the Docker image
      2. Launch the Docker container
    2. Running without Docker
  3. Deploying to AWS ECS
  4. Setting up Continuous Delivery (CD)

Overview

A Pyclops template for running a Django project on ECS.

Features:

  • All infrastructure is mastered in CloudFormation
  • Working Dockerfile for production and development
  • Continuous delivery with Code Pipelines
  • Authentication with JWT

Running locally

Running with Docker

Build the Docker image

Before the Docker container can be run, the Docker image must be built. From the root of the repo, execute the following command:

./docker/build.sh

For a production-like build, set the STAGE environment variable to production:

STAGE=production ./docker/build.sh

Launch the Docker container

Once the image has been built, a Docker container can be launched with the following:

./docker/run.sh

For a production-like run, once again, set the STAGE environment variable to production:

STAGE=production ./docker/run.sh

Running without Docker

Note: you probably want to run the below commands within a Python virtual environment

To run without Docker, change into the app/ directory and run the following:

cd app
pip install -r requirements.txt
./run.sh python ./manage.py runserver

To run with gunicorn, set the STAGE environment variable to production:

STAGE=production ./run.sh

Deploying to AWS ECS

The following instructions depend on the pyclops CLI. Install pyclops with:

pip install pyclops

To deploy to AWS, first create an ECR docker repository:

pyclops aws ecr create-repo --repo-name pyclops/orchards-nutrition

If successful, the above command would have printed out the URI for the newly created repository. The URI would look something like {accountId}.dkr.ecr.{region}.amazonaws.com/pyclops/orchards-nutrition. Before moving forward, set the ecr_repo variable in your params.py file (located at the root of your generated project) to the printed out URI.

Now that we have a repository for our Docker image, we need to build the image and push it up to the repository.

pyclops aws ecr build --dockerfile docker/Dockerfile.prod --repository pyclops/orchards-nutrition --tag latest
pyclops aws ecr push --repository pyclops/orchards-nutrition --tag latest

You are now all set to build and deploy the project to AWS (ensure you have copied the ECR repo ARN into your params.py file as instructed above). In the base directry of your project, run the following commands:

pyclops aws cloudformation build --templates-dir cfn/service --params-file params.py --stage staging
pyclops aws cloudformation deploy --stack-name orchards-nutrition --template-file build/cfn/cfn.template.yml --template-config build/cfn/service.config.json --capabilities CAPABILITY_IAM

Setting up Continuous Delivery (CD)

Coming soon

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.