{"id":18276226,"url":"https://github.com/r4victor/my_django_docker_project_template","last_synced_at":"2026-04-19T14:02:33.788Z","repository":{"id":123903868,"uuid":"562806124","full_name":"r4victor/my_django_docker_project_template","owner":"r4victor","description":"🐳`🎸 A blueprint for Django + Postgres + Gunicorn + nginx + Docker web projects.","archived":false,"fork":false,"pushed_at":"2022-11-10T12:34:34.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-09T04:17:18.838Z","etag":null,"topics":["django","docker","nginx","template-project"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/r4victor.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-07T09:49:33.000Z","updated_at":"2022-11-07T09:59:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"0710532a-415e-425d-b15c-affb5a09f06c","html_url":"https://github.com/r4victor/my_django_docker_project_template","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/r4victor/my_django_docker_project_template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r4victor%2Fmy_django_docker_project_template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r4victor%2Fmy_django_docker_project_template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r4victor%2Fmy_django_docker_project_template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r4victor%2Fmy_django_docker_project_template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/r4victor","download_url":"https://codeload.github.com/r4victor/my_django_docker_project_template/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r4victor%2Fmy_django_docker_project_template/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32009239,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T20:23:30.271Z","status":"online","status_checked_at":"2026-04-19T02:00:07.110Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["django","docker","nginx","template-project"],"created_at":"2024-11-05T12:15:25.046Z","updated_at":"2026-04-19T14:02:33.758Z","avatar_url":"https://github.com/r4victor.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# my_django_docker_project_template\n\nThis repo is a blueprint for Django + Postgres + Gunicorn + nginx + Docker web projects to be deployed on a VPS. \n\n\n## Overview\n\nThe `backend` directory is the output of `django-admin startproject` with some additions:\n\n* Initialized `core` app.\n* Basic dependencies such as `psycopg2` and `gunicorn`.\n* Settings splitted for local and production environments and controlled by environment variables.\n* Initial HTML templates and SCSS pipeline. JS/SCSS files are processed (transpiled, bundled) by `django_compressor` and served with `whitenoise`.\n* Common utilities.\n\nThere is also a bunch of files for local development and deployment with Docker. \n\nAll local development is done with `docker compose` so it's easy to set up and doesn't require to install anything locally. The combination `-f docker-compose-base.yml -f docker-compose-dev.yml` defines a `postgres` service and a `web` service that runs Django dev server with the source code mounted as a volume.\n\nThe combination `-f docker-compose-base.yml -f docker-compose-prod.yml` defines a `postgres` service, an `nginx` service running [nginx-le](https://github.com/nginx-le/nginx-le), and a `web` service that runs Gunicorn.\n\n\n## Usage\n\n### Creating a new project\n\n1. Clone this repo:\n\n    ```\n    git clone https://github.com/r4victor/my_django_docker_project_template new_project \u0026\u0026 cd new_project\n    ```\n\n2. Init a new git folder:\n\n    ```\n    rm -rf .git \u0026\u0026 git init\n    ```\n\n3. Create an `.env` file from the template:\n\n    ```\n    mv backend/.env-template backend/.env \n    ```\n\n4. Rename `my_django_docker_project_template` to your project name in `docker-compose-base.yml`.\n\nThat's it! You have a new project set up!\n\n\n### Local development\n\nTo start a Django dev server, run:\n\n```\ndocker compose -f docker-compose-base.yml -f docker-compose-dev.yml up\n```\n\nOther Django commands can be run in the same way:\n\n```\ndocker compose -f docker-compose-base.yml -f docker-compose-dev.yml run --rm web ./manage.py migrate\n```\n\nIf you need to run a production setup with nginx and Gunicorn locally, then run\n\n```\ndocker compose -f docker-compose-base.yml -f docker-compose-prod.yml up --build\n```\n\nBefore that, ensure that your set `DJANGO_SETTINGS_MODULE=backend.settings.prod` in `.env` and generate a local https cert by running `./scripts/generate_local_cert.sh`.\n\n\n### Deployment\n\nTo deploy, you manually ssh into your server, pull the project and run `docker compose` just like locally:\n\n```\ndocker compose -f docker-compose-base.yml -f docker-compose-prod.yml up --build\n```\n\nThe only difference is that you need to change env variables to match your domain and set `LETSENCRYPT=true` to let nginx issue a certificate for your.\n\n\n## TODO\n\n* Zero downtime deployments. One option would be to make nginx buffer requests while we run migrations and restart the app.\n* Set up automatic deployments on tag releases.\n* We run `manage.py` in Dockerfile to bake static files into the image. To avoid passing dummy env vars there, Django prod settings allows all env vars to be optional. I don't like this since we may want to fail on app start if some env vars are not provided. Another solution would be to make a separate settings file for running in Dockerfile.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr4victor%2Fmy_django_docker_project_template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fr4victor%2Fmy_django_docker_project_template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr4victor%2Fmy_django_docker_project_template/lists"}