Skip to content

Commit 160379a

Browse files
committed
update development section on readme
1 parent d39f638 commit 160379a

File tree

1 file changed

+16
-129
lines changed

1 file changed

+16
-129
lines changed

README.md

Lines changed: 16 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -2,158 +2,45 @@
22

33
Mataroa Collection list of blogs.
44

5-
## Contributing
6-
7-
Feel free to open a PR on [GitHub](https://github.com/sirodoht/illich) or
8-
send an email patch to [~sirodoht/public-[email protected]](mailto:~sirodoht/[email protected]).
9-
10-
On how to contribute using email patches see [git-send-email.io](https://git-send-email.io/).
11-
125
## Development
136

14-
This is a [Django](https://www.djangoproject.com/) codebase. Check out the
15-
[Django docs](https://docs.djangoproject.com/) for general technical documentation.
16-
17-
### Structure
18-
19-
The Django project is `illich`. There is one Django app, `main`, with all business logic.
20-
Application CLI commands are generally divided into two categories, those under `python manage.py`
21-
and those under `make`.
22-
23-
### Dependencies
24-
25-
Using [venv](https://docs.python.org/3/library/venv.html):
26-
27-
```sh
28-
python3 -m venv venv
29-
source venv/bin/activate
30-
pip install -r requirements.txt
31-
pip install -r requirements_dev.txt
32-
```
33-
34-
This project also uses [pip-tools](https://github.com/jazzband/pip-tools) for dependency
35-
management.
36-
37-
### Environment variables
38-
39-
A file named `.envrc` is used to define the environment variables required for this project to
40-
function. One can either export it directly or use [direnv](https://github.com/direnv/direnv).
41-
There is an example environment file one can copy as base:
42-
43-
```sh
44-
cp .envrc.example .envrc
45-
```
46-
47-
`.envrc` should contain the following variables:
48-
49-
```sh
50-
export SECRET_KEY=some-secret-key
51-
export DATABASE_URL=postgres://illich:db-password@db:5432/illich
52-
export EMAIL_HOST_USER=smtp-user
53-
export EMAIL_HOST_PASSWORD=smtp-password
54-
```
55-
56-
When on production, also include the following variables (see [Deployment](#Deployment) and
57-
[Backup](#Backup)):
58-
59-
```sh
60-
export NODEBUG=1
61-
export PGPASSWORD=db-password
62-
```
63-
64-
### Database
65-
66-
This project uses PostgreSQL. Assuming one has set the `DATABASE_URL` (see above), to create the
67-
database schema:
7+
This is a standard [Django](https://docs.djangoproject.com/) application with
8+
[uv](https://github.com/astral-sh/uv).
689

69-
```sh
70-
python manage.py migrate
71-
```
72-
73-
### Serve
74-
75-
To run the Django development server:
76-
77-
```sh
78-
python manage.py runserver
79-
```
80-
81-
### Docker
82-
83-
If Docker and docker-compose are preferred, then:
84-
85-
1. Set `DATABASE_URL` in `.envrc` to `postgres://postgres:postgres@db:5432/postgres`
86-
1. Run `docker-compose up -d`.
87-
88-
The database data will be saved in the git-ignored directory / Docker volume `db_data`,
89-
located in the root of the project.
90-
91-
## Testing
92-
93-
Using the Django test runner:
10+
1. Create database tables with:
9411

9512
```sh
96-
python manage.py test
13+
uv run manage.py migrate
9714
```
9815

99-
For coverage, run:
16+
2. Run development server with:
10017

10118
```sh
102-
make cov
19+
uv run manage.py runserver
10320
```
10421

105-
## Code linting & formatting
106-
107-
The following tools are used for code linting and formatting:
22+
## Format and lint
10823

109-
* [black](https://github.com/psf/black) for code formatting.
110-
* [isort](https://github.com/pycqa/isort) for imports order consistency.
111-
* [flake8](https://gitlab.com/pycqa/flake8) for code linting.
112-
113-
To use:
24+
Run Python formatting with:
11425

11526
```sh
116-
make format
117-
make lint
27+
uv run ruff format
11828
```
11929

120-
## Deployment
121-
122-
Deployment is configured using [uWSGI](https://uwsgi.readthedocs.io/en/latest/)
123-
and [nginx](https://nginx.org/).
124-
125-
Remember to set the environment variables before starting `uwsgi`. Depending on the deployment
126-
environment, this could mean directly exporting the variables or just sourcing `.envrc` (with all
127-
production variables — including `NODEBUG`):
30+
Run Python linting with:
12831

12932
```sh
130-
source .envrc
131-
uwsgi illich.ini
33+
uv run ruff check --fix
13234
```
13335

134-
Note that the value of the `NODEBUG` variable is ignored. What matters is merely its existence
135-
in the environment.
136-
137-
## Backup
36+
## Deploy
13837

139-
To automate backup, there is [a script](backup-database.sh) which dumps the database and uploads
140-
it into AWS S3. The script also needs the database password as an environment variable. The
141-
key needs to be `PGPASSWORD`. The backup script assumes the variable lives in `.envrc` like so:
38+
Every commit on branch `main` auto-deploys using GitHub Actions. To deploy manually:
14239

14340
```sh
144-
export PGPASSWORD=db-password
145-
```
146-
147-
To restore a dump:
148-
149-
```sh
150-
pg_restore -v -h localhost -cO --if-exists -d illich -U illich -W illich.dump
151-
```
152-
153-
To add on cron:
154-
155-
```sh
156-
0 */6 * * * /opt/apps/illich/backup-database.sh
41+
cd ansible/
42+
cp .envrc.example .envrc
43+
uv run ansible-playbook playbook.yaml -v
15744
```
15845

15946
## License

0 commit comments

Comments
 (0)