{"id":18668062,"url":"https://github.com/rririanto/docker-compose-django","last_synced_at":"2025-09-11T11:34:05.240Z","repository":{"id":140962819,"uuid":"289642373","full_name":"rririanto/docker-compose-django","owner":"rririanto","description":"Docker-compose for Python Django web framework with SSL/HTTPS support and MySQL database.","archived":false,"fork":false,"pushed_at":"2020-10-03T15:11:33.000Z","size":629,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-17T10:39:51.283Z","etag":null,"topics":["django","docker","docker-compose","mysql-database","nginx-proxy"],"latest_commit_sha":null,"homepage":"","language":"Makefile","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/rririanto.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":"2020-08-23T08:03:52.000Z","updated_at":"2024-03-11T16:58:22.000Z","dependencies_parsed_at":"2024-07-16T18:45:13.359Z","dependency_job_id":null,"html_url":"https://github.com/rririanto/docker-compose-django","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rririanto/docker-compose-django","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rririanto%2Fdocker-compose-django","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rririanto%2Fdocker-compose-django/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rririanto%2Fdocker-compose-django/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rririanto%2Fdocker-compose-django/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rririanto","download_url":"https://codeload.github.com/rririanto/docker-compose-django/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rririanto%2Fdocker-compose-django/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274625138,"owners_count":25319820,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-11T02:00:13.660Z","response_time":74,"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","docker-compose","mysql-database","nginx-proxy"],"created_at":"2024-11-07T08:41:10.653Z","updated_at":"2025-09-11T11:34:05.177Z","avatar_url":"https://github.com/rririanto.png","language":"Makefile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# docker-compose-django\nThis is a Docker setup for a web application based on Django.\n\n- The Django application is served by Gunicorn (WSGI application).\n- We use nginx-proxy as reverse proxy and static files server. \n- SSL/HTTPS automatic generate and renew using [letsencrypt-nginx-proxy-companion](https://hub.docker.com/r/jrcs/letsencrypt-nginx-proxy-companion/)\n- Static and media files are persistently stored in volumes.\n- Python dependencies are managed through pip requirement.txt\n- Use [Django version LTS 2.2](https://www.djangoproject.com/download/)\n\n## Motivation\nI've been using docker in most of my Django projects. There's a lot starter or example to use docker to run the Django web framework available on Github. However, to have the proper configuration that fits my project requirement is a little tricky. So the way I created my own configuration is by observing at other configurations and read the documentation from an official docker site. So I hope someone could get inspired!\n\n## Prerequisite\n- Docker \u0026 Docker-compose: [Linux](https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-18-04) or [Windows](https://runnable.com/docker/install-docker-on-windows-10)\n\n## Configurations\nThis project has a default host localhost, if you like to deploy it to your server you need to update this configuration:\n1. HTTPS settings on [docker-compose file](https://github.com/rririanto/docker-compose-django/blob/master/docker-compose.yaml)\n\n```\nVIRTUAL_HOST: yourdomain.com\nVIRTUAL_PORT: 80\nLETSENCRYPT_HOST: yourdomain.com\n# Email use to register yourdomain.com to Letsencrypt\nLETSENCRYPT_EMAIL: youremail@gmail.com\n```\nNote: \n- Once you enable LETSENCRYPT_HOST \u0026 LETSENCRYPT_EMAIL the nginx-proxy will be automaticly generate https cert for you. simple right?\n- Ignore this settings if you just want to run it in your localhost\n- Ignore this if you want to use Cloudflare because Cloudflare already has its own https generated; otherwise, you will get redirect looping. \n\n2. [Dock-gen](https://github.com/jwilder/docker-gen) for nginx configuration\n\nI'm using dock-gen to generate Nginx settings from the template. So whenever I want to create demo, test, production, implement DTAP software development or create any subdomain with other containers, I don't need to do it manually. If you want to edit \u0026 add new route, caching config and etc, please do it on [nginx.tmpl](https://github.com/rririanto/docker-compose-django/blob/master/nginx-proxy/nginx.tmpl#L384)\n\n3. Use Alpine-linux\n\nThe default configuration is not using Alpine. However, if you want to use Alpine and reduce the size of your container, you can change the DockerFile to [Dockerfile-alpine](https://github.com/rririanto/docker-compose-django/blob/master/Dockerfile-alpine). Take a look on [docker-compose](https://github.com/rririanto/docker-compose-django/blob/master/docker-compose.yaml#L19) and change Dockerfile to Dockerfile-alpine\n```\n  web:\n    build:\n      context: .\n      dockerfile: Dockerfile-alpine\n\n```\n\n4. Replace \"dev\" with your project name or you can just use the dev project by:\n```\ngit submodule update --init --recursive\n```\n\nMake sure to replace \"example\" with your project directory name in [nginx.tmpl](https://github.com/rririanto/docker-compose-django/blob/master/nginx-proxy/nginx.tmpl), [Nginx docker-compose](https://github.com/rririanto/docker-compose-django/blob/master/nginx-proxy/docker-compose.yaml), [docker-compose web \u0026 mysql](https://github.com/rririanto/docker-compose-django/blob/master/docker-compose.yaml) and also [DockerFile](https://github.com/rririanto/docker-compose-django/blob/master/Dockerfile) or [DockerAlpine](https://github.com/rririanto/docker-compose-django/blob/master/Dockerfile-alpine)\n\n5. Database and django .env\n\nIf you would like to change the database and django env settings please see [.env](https://github.com/rririanto/docker-compose-django/tree/master/.envs)\n\n\n## How to use\nWe use Makefile to make our life easy. You can see the command list on [Makefile](https://github.com/rririanto/docker-compose-django/blob/master/Makefile) file. \nHowever, the first things to do to run this project is by: \n\n1. Create nginx-proxy network\n```sh\nmake create-network\n```\n2. Create volumes to store files persistently.\n```sh\nmake create-volume\n```\n3. Run nginx-proxy \n```\nmake up-nginx\n```\n4. Build the Django web\n```\nmake build\n```\n5. Migrate\n```\nmake migrate\n```\n6. Collectstatic files\n```\nmake collectstatic\n```\n7. Create Super User\n```\nmake createsuperuser\n```\n\n## Tips\nYou can update your code on container by using this command \n```\nmake rebuild.sh\n```\n\n## Issues\n***1. Static file or media not found***\n\nPlease make sure you have correct directory path files of static and media in your settings. Also check on [nginx.tmpl](https://github.com/rririanto/docker-compose-django/blob/master/nginx-proxy/nginx.tmpl#L384) \n \n## Thank you\nThis project was inspired from:\n- [nginx-proxy](https://github.com/nginx-proxy/nginx-proxy)\n- [pawamoy](https://github.com/pawamoy/docker-nginx-postgres-django-example)\n- [testdriven](https://testdriven.io/blog/dockerizing-django-with-postgres-gunicorn-and-nginx/)\n\n## Contact me\nrahmat.ramadhaniriyanto@gmail.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frririanto%2Fdocker-compose-django","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frririanto%2Fdocker-compose-django","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frririanto%2Fdocker-compose-django/lists"}