From fec422f2d56d6c363eaa8b8e50866e7beca5d08c Mon Sep 17 00:00:00 2001 From: Maciej Urbanski Date: Wed, 31 May 2023 21:46:47 +0200 Subject: [PATCH 1/3] reformat Markdown using `readable` --- README.md | 24 +++++++------- features.md | 92 +++++++++++++++++++++++++++++------------------------ 2 files changed, 61 insertions(+), 55 deletions(-) diff --git a/README.md b/README.md index 11fe59f..6fee5f7 100644 --- a/README.md +++ b/README.md @@ -1,37 +1,35 @@ -cookiecutter-rt-django -====================== +# cookiecutter-rt-django CookieCutter template for Django application projects with docker-compose etc. -Requirements ------------- +## Requirements ```sh pip install cruft ``` -Usage ------ +## Usage -* Generate a new Cookiecutter template layout: +- Generate a new Cookiecutter template layout: ```sh cruft create https://github.com/reef-technologies/cookiecutter-rt-django ``` -* See diff with +- See diff with ```sh cruft diff ``` -* Update the project by running +- Update the project by running ```sh cruft update ``` -* If you have a repo which was initialized without cruft (i.e. with `cookiecutter` command), you can still link the project: +- If you have a repo which was initialized without cruft (i.e. with `cookiecutter` command), you can still link the project: ```sh cruft link https://github.com/reef-technologies/cookiecutter-rt-django ``` -More on cruft: https://github.com/cruft/cruft +More on cruft: + + +## License -License -------- This project is licensed under the terms of the [BSD-3 License](/LICENSE) diff --git a/features.md b/features.md index c8618aa..a222569 100644 --- a/features.md +++ b/features.md @@ -1,57 +1,65 @@ # RT cookiecutter template selling points ## Main configuration -* [Cookiecutter](https://github.com/cookiecutter/cookiecutter) template -* Template updates using [Cruft](https://github.com/cruft/cruft) -* [Docker](https://www.docker.com) and [docker-compose](https://docs.docker.com/compose/) for easy & simple (c) development and deployment -* Latest [python](https://www.python.org) from 3.9 line (due to [nogil fork compatibility](https://www.backblaze.com/blog/python-gil-vs-nogil-boost-i-o-performance-10x-with-one-line-change/)) -* Latest [Django](https://www.djangoproject.com) LTS release -* [Gunicorn](https://gunicorn.org) for running WSGI instances on prod -* [Uvicorn](https://www.uvicorn.org) for ASGI instances on prod -* [Postgres](https://www.postgresql.org) for database -* Task management via [celery](https://docs.celeryproject.org) -* Multiple workers & queues supported (if you need to divide / prioritize tasks and apply different levels of concurrency) + +- [Cookiecutter](https://github.com/cookiecutter/cookiecutter) template +- Template updates using [Cruft](https://github.com/cruft/cruft) +- [Docker](https://www.docker.com) and [docker-compose](https://docs.docker.com/compose/) for easy & simple (c) development and deployment +- Latest [python](https://www.python.org) from 3.9 line (due to [nogil fork compatibility](https://www.backblaze.com/blog/python-gil-vs-nogil-boost-i-o-performance-10x-with-one-line-change/)) +- Latest [Django](https://www.djangoproject.com) LTS release +- [Gunicorn](https://gunicorn.org) for running WSGI instances on prod +- [Uvicorn](https://www.uvicorn.org) for ASGI instances on prod +- [Postgres](https://www.postgresql.org) for database +- Task management via [celery](https://docs.celeryproject.org) +- Multiple workers & queues supported (if you need to divide / prioritize tasks and apply different levels of concurrency) ## Self-hosted configuration -* Persistent [redis](https://redis.io) for task management backend -* Celery task monitoring via [flower](https://flower.readthedocs.io/en/latest/) + +- Persistent [redis](https://redis.io) for task management backend +- Celery task monitoring via [flower](https://flower.readthedocs.io/en/latest/) ## Cloud configuration -* AWS terraform to deploy RDS, SQS, ELB etc + +- AWS terraform to deploy RDS, SQS, ELB etc ## Configuration -* [.env files](https://12factor.net/config) for configuration; preconfigured `.env` for both local and prod environments -* [django-debug-toolbar](https://django-debug-toolbar.readthedocs.io/en/latest/) (enabled for local environment) for debugging app performance -* [ipython](https://ipython.org) included for nice interactive django shell -* [django-extensions](https://django-extensions.readthedocs.io/en/latest/) for drawing graph of models and more + +- [.env files](https://12factor.net/config) for configuration; preconfigured `.env` for both local and prod environments +- [django-debug-toolbar](https://django-debug-toolbar.readthedocs.io/en/latest/) (enabled for local environment) for debugging app performance +- [ipython](https://ipython.org) included for nice interactive django shell +- [django-extensions](https://django-extensions.readthedocs.io/en/latest/) for drawing graph of models and more ## Deployment -* [2-stage docker image build](https://docs.docker.com/develop/develop-images/multistage-build/) for clean app image -* Easy deployment based on `git push production master` -* Redeployment doesn't stop `db`, `redis` and `nginx` containers -> non-interrupted deployments -* Migrations are done during deployment, before application startup -> application won't be run on unmigrated database + +- [2-stage docker image build](https://docs.docker.com/develop/develop-images/multistage-build/) for clean app image +- Easy deployment based on `git push production master` +- Redeployment doesn't stop `db`, `redis` and `nginx` containers -> non-interrupted deployments +- Migrations are done during deployment, before application startup -> application won't be run on unmigrated database ## Security -* [CORS headers](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing) preconfigured -* [CSP](https://en.wikipedia.org/wiki/Content_Security_Policy) integrated -* Compression is off by default to avoid [BREACH attack](https://en.wikipedia.org/wiki/BREACH) -* Brotli compression support -* [http/2](https://en.wikipedia.org/wiki/HTTP/2) support -* [TLS 1.2&1.3](https://en.wikipedia.org/wiki/Transport_Layer_Security) via [letsencrypt](https://letsencrypt.org) with auto-renewal -* Forward secrecy ciphers -* Overall ssllabs security class: A+ 100/100/90/90 (to keep compatibility with some older clients) + +- [CORS headers](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing) preconfigured +- [CSP](https://en.wikipedia.org/wiki/Content_Security_Policy) integrated +- Compression is off by default to avoid [BREACH attack](https://en.wikipedia.org/wiki/BREACH) +- Brotli compression support +- [http/2](https://en.wikipedia.org/wiki/HTTP/2) support +- [TLS 1.2&1.3](https://en.wikipedia.org/wiki/Transport_Layer_Security) via [letsencrypt](https://letsencrypt.org) with auto-renewal +- Forward secrecy ciphers +- Overall ssllabs security class: + A+ 100/100/90/90 (to keep compatibility with some older clients) ## Reliability -* Backups to: - * Host system - * [B2](https://www.backblaze.com/b2/cloud-storage.html) using a `writeFiles`-only key - * Email -* Script and a written procedure for restoring the system from a backup -* [Sentry](https://sentry.io) error tracking preconfigured -* Prometheus for data collection -* Grafana for metrics - * Generic host dashboard section optimized for both VM and physical machines - * nginx-level dashboard section for http/ws statistics - * Active monitoring dashboard (http ping) - * Alert history dashboard -* Alertmanager for detecting issues and alerting + +- Backups to: + - Host system + - [B2](https://www.backblaze.com/b2/cloud-storage.html) using a `writeFiles`-only key + - Email +- Script and a written procedure for restoring the system from a backup +- [Sentry](https://sentry.io) error tracking preconfigured +- Prometheus for data collection +- Grafana for metrics + - Generic host dashboard section optimized for both VM and physical machines + - nginx-level dashboard section for http/ws statistics + - Active monitoring dashboard (http ping) + - Alert history dashboard +- Alertmanager for detecting issues and alerting From 61c8a6c169f79e4ab2d7186a0f08d276ff1f17c9 Mon Sep 17 00:00:00 2001 From: Maciej Urbanski Date: Wed, 31 May 2023 21:47:08 +0200 Subject: [PATCH 2/3] fix readable call & rename session name to `format` --- {{cookiecutter.repostory_name}}/.github/workflows/ci.yml | 4 ++-- {{cookiecutter.repostory_name}}/noxfile.py | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/{{cookiecutter.repostory_name}}/.github/workflows/ci.yml b/{{cookiecutter.repostory_name}}/.github/workflows/ci.yml index 3621c74..ed029af 100644 --- a/{{cookiecutter.repostory_name}}/.github/workflows/ci.yml +++ b/{{cookiecutter.repostory_name}}/.github/workflows/ci.yml @@ -34,10 +34,10 @@ jobs: cache: "pip" - name: Install dependencies run: python -m pip install --upgrade nox pip setuptools + - name: Run format + run: nox -vs format - name: Run linters run: nox -vs lint - - name: Run readable - run: nox -vs readable {%- endif %} test: timeout-minutes: 10 diff --git a/{{cookiecutter.repostory_name}}/noxfile.py b/{{cookiecutter.repostory_name}}/noxfile.py index 36e75e9..4ab8a68 100644 --- a/{{cookiecutter.repostory_name}}/noxfile.py +++ b/{{cookiecutter.repostory_name}}/noxfile.py @@ -62,15 +62,16 @@ def security_check(session): @nox.session(python=PYTHON_DEFAULT_VERSION) -def readable(session): +def format(session): session.run( 'docker', 'run', + '--rm', '-v', f'{ROOT.absolute()}:/data', '-w', '/data', '-u', f'{os.geteuid()}:{os.getegid()}', - 'ghcr.io/bobheadxi/readable:v0.4.0@sha256:d26dccd39069ad6118376d4499d3cf3d74a1c599442e751fc0ca29acbcb044c4', - 'fmt', '**.md', + 'ghcr.io/bobheadxi/readable:v0.5.0@sha256:423c133e7e9ca0ac20b0ab298bd5dbfa3df09b515b34cbfbbe8944310cc8d9c9', + 'fmt', '**/*.md', ) From 2fcb511d9960ddcecc4784a210d336f32f1e593c Mon Sep 17 00:00:00 2001 From: Maciej Urbanski Date: Thu, 1 Jun 2023 00:22:25 +0200 Subject: [PATCH 3/3] fix nox format session name --- {{cookiecutter.repostory_name}}/noxfile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/{{cookiecutter.repostory_name}}/noxfile.py b/{{cookiecutter.repostory_name}}/noxfile.py index 4ab8a68..a996425 100644 --- a/{{cookiecutter.repostory_name}}/noxfile.py +++ b/{{cookiecutter.repostory_name}}/noxfile.py @@ -61,8 +61,8 @@ def security_check(session): ) -@nox.session(python=PYTHON_DEFAULT_VERSION) -def format(session): +@nox.session(name='format', python=PYTHON_DEFAULT_VERSION) +def format_(session): session.run( 'docker', 'run',