Code Monkey home page Code Monkey logo

docker-nginx-postgres-django-example's Introduction

Example using Docker, Django, multiple Postgres databases, NginX, Gunicorn, pipenv, GitLab CI and tox

This is a Docker setup for a web application based on Django.

  • The Django application is served by Gunicorn (WSGI application).
  • We use NginX as reverse proxy and static files server. Static and media files are persistently stored in volumes.
  • Multiple Postgres databases can be used. Data are persistently stored in volumes.
  • Python dependencies are managed through pipenv, with Pipfile and Pipfile.lock.
  • Support for multiple environment settings (variable DJANGO_SETTINGS_MODULE is passed to the djangoapp service).
  • Tests are run using tox, pytest, and other tools such as safety, bandit, isort and prospector.
  • Continuous Integration is configured for GitLab with .gitlab-ci.yml. CI follows a Build-Test-Release flow. WARNING: this part is not fully functional yet.

Also a Makefile is available for convenience. You might need to use sudo make instead of just make because docker and docker-compose commands often needs admin privilege.

Requirements

You need to install Docker and Docker-Compose.

Build

docker-compose build or make build.

Migrate databases

docker-compose run --rm djangoapp hello/manage.py migrate or make migrate.

Collect static files

docker-compose run --rm djangoapp hello/manage.py collectstatic --no-input' or make collectstatic.

Run

docker-compose up or make run.

Tests

  • make checksafety
  • make checkstyle
  • make test
  • make coverage

Related blog post

Docker Compose with NginX, Django, Gunicorn and multiple Postgres databases

License

Software licensed under the ISC license.

docker-nginx-postgres-django-example's People

Contributors

dependabot[bot] avatar pawamoy avatar

Watchers

 avatar

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.