{"id":23363141,"url":"https://github.com/aliahadmd/template-django-docker-postgresql-memcached","last_synced_at":"2026-05-06T04:07:29.836Z","repository":{"id":268821962,"uuid":"905532120","full_name":"aliahadmd/template-django-docker-postgresql-memcached","owner":"aliahadmd","description":"A Django application template configured with Docker for both development and production environments, including PostgreSQL, Memcached, and Nginx.","archived":false,"fork":false,"pushed_at":"2024-12-27T14:32:19.000Z","size":180,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-13T23:18:41.334Z","etag":null,"topics":["development","django","docker","memcached","postgresql","production","python","software"],"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/aliahadmd.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":"2024-12-19T02:52:35.000Z","updated_at":"2024-12-27T14:32:22.000Z","dependencies_parsed_at":"2024-12-19T05:28:08.666Z","dependency_job_id":"f6604e4e-0ece-4ba4-a507-633a864d727e","html_url":"https://github.com/aliahadmd/template-django-docker-postgresql-memcached","commit_stats":null,"previous_names":["aliahadmd/template-django-docker-postgresql-memcached"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aliahadmd%2Ftemplate-django-docker-postgresql-memcached","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aliahadmd%2Ftemplate-django-docker-postgresql-memcached/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aliahadmd%2Ftemplate-django-docker-postgresql-memcached/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aliahadmd%2Ftemplate-django-docker-postgresql-memcached/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aliahadmd","download_url":"https://codeload.github.com/aliahadmd/template-django-docker-postgresql-memcached/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247737740,"owners_count":20987718,"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","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":["development","django","docker","memcached","postgresql","production","python","software"],"created_at":"2024-12-21T12:37:45.153Z","updated_at":"2026-05-06T04:07:29.818Z","avatar_url":"https://github.com/aliahadmd.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Django Project with Docker\n\nThis project is a Django application configured with Docker for both development and production environments. It includes PostgreSQL for the database, Memcached for caching, and Nginx as a reverse proxy in production.\n\n## Project Structure\n\n```\n.\n├── core/                   # Django project core\n│   ├── settings-dev.py    # Development settings\n│   ├── settings-prod.py   # Production settings\n│   └── urls.py            # URL configurations\n├── nginx/                 # Nginx configuration\n│   ├── Dockerfile        # Nginx Dockerfile\n│   └── nginx.conf        # Nginx server configuration\n├── templates/            # HTML templates\n│   └── home.html        # Homepage template\n├── user/                 # Django app\n├── docker-compose.dev.yml   # Docker Compose for development\n├── docker-compose.prod.yml  # Docker Compose for production\n├── Dockerfile.dev          # Development Dockerfile\n├── Dockerfile.prod         # Production Dockerfile\n├── manage.py              # Django management script\n└── requirements.txt       # Python dependencies\n```\n\n## Development Environment\n\n### Prerequisites\n- Docker\n- Docker Compose\n\n### Setup and Running\n\n1. Clone the repository:\n   ```bash\n   git clone \u003crepository-url\u003e\n   cd \u003cproject-directory\u003e\n   ```\n\n2. Start the development environment:\n   ```bash\n   docker compose -f docker-compose.dev.yml up --build\n   ```\n\n3. Access the development server:\n   - Application: http://localhost:8000\n   - Admin interface: http://localhost:8000/admin\n\n### Development Features\n- Hot-reload enabled (code changes reflect immediately)\n- Debug mode enabled\n- PostgreSQL database (not exposed to host)\n- Memcached for caching\n- All logs visible in console\n\n### Development Ports\n- Django: 8000 (exposed)\n- PostgreSQL: 5432 (internal only)\n- Memcached: 11211 (internal only)\n\n## Production Environment\n\n### Prerequisites\n- Docker\n- Docker Compose\n- Ubuntu Server\n\n### Setup and Running\n\n1. Clone the repository on your production server:\n   ```bash\n   git clone \u003crepository-url\u003e\n   cd \u003cproject-directory\u003e\n   ```\n\n2. Configure environment variables:\n   Create a `.env` file in the project root with the following variables:\n   ```env\n   DJANGO_SECRET_KEY=your-secret-key-here\n   POSTGRES_DB=django_db_prod\n   POSTGRES_USER=django_user_prod\n   POSTGRES_PASSWORD=your-secure-password\n   EMAIL_HOST_USER=your-email@example.com\n   EMAIL_HOST_PASSWORD=your-email-password\n   ```\n\n3. Start the production environment:\n   ```bash\n   docker compose -f docker-compose.prod.yml up --build -d\n   ```\n\n4. Access the production server:\n   - Application: http://localhost\n   - Admin interface: http://localhost/admin\n\n### Production Features\n- Nginx as reverse proxy\n- Gunicorn as WSGI server\n- PostgreSQL database (not exposed)\n- Memcached for caching\n- Static/Media files served through Nginx\n- SMTP email configuration\n- Debug mode disabled\n- Optimized for performance\n\n### Production Ports\n- Nginx: 80 (exposed)\n- Gunicorn: 8000 (internal only)\n- PostgreSQL: 5432 (internal only)\n- Memcached: 11211 (internal only)\n\n## Database Management\n\n### Creating Migrations\n```bash\n# Development\ndocker compose -f docker-compose.dev.yml exec web python manage.py makemigrations\n\n# Production\ndocker compose -f docker-compose.prod.yml exec web python manage.py makemigrations\n```\n\n### Applying Migrations\n```bash\n# Development\ndocker compose -f docker-compose.dev.yml exec web python manage.py migrate\n\n# Production\ndocker compose -f docker-compose.prod.yml exec web python manage.py migrate\n```\n\n### Creating Superuser\n```bash\n# Development\ndocker compose -f docker-compose.dev.yml exec web python manage.py createsuperuser\n\n# Production\ndocker compose -f docker-compose.prod.yml exec web python manage.py createsuperuser\n```\n\n## Static and Media Files\n\n### Development\n- Static files are automatically served by Django's development server\n- Media files are stored in the `media` directory\n\n### Production\n- Static files are collected to the `static` directory and served by Nginx\n- Media files are stored in the `media` directory and served by Nginx\n- Run collectstatic manually if needed:\n  ```bash\n  docker compose -f docker-compose.prod.yml exec web python manage.py collectstatic --noinput\n  ```\n\n## Maintenance\n\n### Viewing Logs\n```bash\n# All services\ndocker compose -f docker-compose.prod.yml logs\n\n# Specific service (e.g., web, nginx, db)\ndocker compose -f docker-compose.prod.yml logs web\n```\n\n### Backup Database\n```bash\ndocker compose -f docker-compose.prod.yml exec db pg_dump -U django_user_prod django_db_prod \u003e backup.sql\n```\n\n### Restore Database\n```bash\ncat backup.sql | docker compose -f docker-compose.prod.yml exec -T db psql -U django_user_prod -d django_db_prod\n```\n\n## Security Notes\n\n1. In production:\n   - Database port is not exposed outside Docker network\n   - All services communicate through Docker's internal network\n   - Debug mode is disabled\n   - Secure passwords are used for database and email\n\n2. Environment Variables:\n   - Never commit `.env` files\n   - Use strong, unique passwords\n   - Regularly rotate secrets\n\n## Troubleshooting\n\n1. If static files are not serving:\n   ```bash\n   docker compose -f docker-compose.prod.yml exec web python manage.py collectstatic --noinput\n   ```\n\n2. If database connections fail:\n   - Check if PostgreSQL container is running\n   - Verify database credentials in settings\n   - Ensure migrations are applied\n\n3. If Nginx returns 502 Bad Gateway:\n   - Check if Gunicorn is running\n   - Verify Nginx configuration\n   - Check logs for both services\n\n## Contributing\n\n1. Create a new branch for your feature\n2. Make your changes\n3. Test in development environment\n4. Submit a pull request\n\n## License\n\n[Your License Here]\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faliahadmd%2Ftemplate-django-docker-postgresql-memcached","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faliahadmd%2Ftemplate-django-docker-postgresql-memcached","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faliahadmd%2Ftemplate-django-docker-postgresql-memcached/lists"}