Comments (6)
Make a fork and lets have a look at it.
It would need launcher scripts instead of letting docker compose spin everything up. I wouldn't use it, but there's still value for users new to django in making a template for the exact example from the django docs introductory app, but with postgres, nginx and traefik etc. working out of the box, using containers. That would be a perfect opportnuity to trim out some of the hacks in cookiecutter-django too (like the non-standard directory structure, copying everything in the repo into the node container right at the start of the Django dockerfile meaning the docker cache is hardly ever useful, and the python script in a string inside a bash script, that waits for a postgres connection).
But for the core mission of cookiecutter-django, and promise it makes to help: "jump start production-ready Django projects quickly", containerising the django run time has the following advantages:
-
Currently local/production.yml is a great reference for what's running in your cookiecutter-django stack.
-
Containerising Django allows the env it's in to be easily reproduced for celery, or for the user's custom services that need to use Django.
-
Containerising makes the stack more portable and cloud agnostic (unlike running locally, it doesn't necessarily need a server. It could run on a container run time PAAS like fly.io)
-
One extra security layer - if there's a vulnerability in Django, attackers are straight into the host OS, not just the container under the non-root user
django
. I would not assume a container is bullet proof, but it does raise the cost to an attacker. -
The docker network is a little nicer to work with than localhost ports, and avoids having to double check the ports of services running at OS level, against the firewall and network table.
-
Easily upgrade or switch Python versions.
Plus others that don't immediately spring to mind.
from cookiecutter-django.
My proposal is to use a local interpreter for development instead of the containerized one. So the production environment wouldn't change.
Your bullets are valid points and should left untouched. The only change I'm proposing is to use a system interpreter so tests are running faster :)
from cookiecutter-django.
The tests will indeed run faster, which would be nice I agree. Is there a second route to running the tests directly in the repo, or can they be reorganised?
But the subset of tests that can run locally outside a container, will not definitively test any interaction with the container, which is what will actually be deployed. So it could lead to false confidence, or late discovery of bugs.
from cookiecutter-django.
Is there a second route to running the tests directly in the repo, or can they be reorganised?
What are you thinking of?
In my thinking it is straightforward: an interpreter is juist interacting with services. Where those services are living isn't important as long as they available through the network. The docker layer gives me a performance penalty when I'm running tests, so I can better remove it and enjoy an improved DX.
Theoretically this can lead to false confidence or late discovery of bugs, especially when you are developing under windows or osx. But these issues will popup in the pipeline or on the staging/test environment.
from cookiecutter-django.
That's an approach I saw some colleagues use in a previous project, but I never been too bothered with the Docker overhead myself to use it, it's a price I don't mind paying for the benefit of reproducibility. The way we did it was to have both Docker and Hybrid side by side and each developer on project was free to choose the way they wanted. Was useful to keep Docker around in case of tricky bug where an env closer to prod was needed.
Question for you is how do you usually run Celery in this context? Do you start another process on your host machine or do you keep Celery containerized?
from cookiecutter-django.
That would be a perfect opportnuity to trim out some of the hacks in cookiecutter-django too (like the non-standard directory structure, copying everything in the repo into the node container right at the start of the Django dockerfile meaning the docker cache is hardly ever useful, and the python script in a string inside a bash script, that waits for a postgres connection).
@JamesParrott I think we have a few issues tracking some of these:
However, I don't see what you mean about "copying everything in the repo into the node container right at the start of the Django dockerfile meaning the docker cache is hardly ever useful", could you point us at the problem in a new issue please? It would be good to tackle that here, we don't need a fork 😄
from cookiecutter-django.
Related Issues (20)
- Integrate PostgreSQL 16 Support in Django Cookiecutter HOT 1
- libpq-dev installation is repeated in Dockerfile HOT 1
- Adding django-ninja options to building REST APIs HOT 11
- S3 putObject fails when starting up project: What permissions are required.? HOT 3
- Selecting Whitenoise and AWS as cloud provider overrides STATIC_URL in a way that assumes Collectfast HOT 3
- Adopt Collectfasta HOT 2
- Drop support for runserver_plus & django_extensions HOT 2
- Python: can't open file '/app/manage.py': [Errno 2] No such file or directory - Django - Docker Compose HOT 8
- Python: can't open file '/app/manage.py': [Errno 2] No such file or directory - Django - Docker Compose
- createdb and migrate using conda
- ruff hook fails with F405 issue in config/settings/production.py HOT 1
- Why doesn't add RunServerPlus options for reload in windows when using docker? HOT 3
- Add `compose` to the names of docker compose files HOT 3
- Sometimes template code changes not detected in windows wls ubuntu22.04. HOT 4
- Discord invite expired HOT 1
- ValueError: Another profiling tool is already active HOT 3
- Add cloudflare to cloud provider options HOT 5
- PostgreSQL - connection failed: FATAL: remaining connection slots are reserved for non-replication superuser connections HOT 23
- Migrate gulpfile to ESM HOT 2
- {"detail":"Not Found"} at http://127.0.0.1:8000 immediately HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cookiecutter-django.