Skip to content

Commit

Permalink
Merge pull request #111 from reef-technologies/sembr
Browse files Browse the repository at this point in the history
fix `readable` integration
  • Loading branch information
mjurbanski-reef committed Jun 6, 2023
2 parents 3e1db9c + 2fcb511 commit 72db713
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 61 deletions.
24 changes: 11 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -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:
<https://github.com/cruft/cruft>

## License

License
-------
This project is licensed under the terms of the [BSD-3 License](/LICENSE)
92 changes: 50 additions & 42 deletions features.md
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions {{cookiecutter.repostory_name}}/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions {{cookiecutter.repostory_name}}/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,17 @@ def security_check(session):
)


@nox.session(python=PYTHON_DEFAULT_VERSION)
def readable(session):
@nox.session(name='format', python=PYTHON_DEFAULT_VERSION)
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',
)


Expand Down

0 comments on commit 72db713

Please sign in to comment.