pali-lili/README.md

102 lines
3 KiB
Markdown
Raw Normal View History

2025-12-14 17:47:51 +00:00
# ilo pali lili
Backend for orchestrating deployment of censorship circumvention resources.
2025-12-14 17:55:13 +00:00
![](./screenshot.png)
## Local Development
2025-12-14 17:47:51 +00:00
### Setup just
MacOS:
```shell
brew install just
```
Debian/Ubuntu:
```shell
apt install just
````
Others: [link](https://github.com/casey/just?tab=readme-ov-file#packages)
### Setup poetry
```shell
pip install poetry
```
Other ways: [link](https://python-poetry.org/docs/#installation)
### Setup Postgres (16.3)
```shell
just up
```
### Copy the environment file and install dependencies
1. `cp .env.example .env`
2. `poetry install`
### Run the uvicorn server
With default settings:
```shell
just run
```
With extra configs (e.g. logging file)
```shell
just run --log-config logging.ini
```
2025-12-14 17:55:13 +00:00
### Linters
2025-12-14 17:47:51 +00:00
Format the code with `ruff --fix` and `ruff format`
```shell
just lint
```
### Migrations
- Create an automatic migration from changes in `src/database.py`
```shell
just mm *migration_name*
```
- Run migrations
```shell
just migrate
```
- Downgrade migrations
```shell
just downgrade downgrade -1 # or -2 or base or hash of the migration
```
2025-12-14 17:55:13 +00:00
## Deployment
2025-12-14 17:47:51 +00:00
Deployment is done with Docker and Gunicorn. The Dockerfile is optimized for small size and fast builds with a non-root user. The gunicorn configuration is set to use the number of workers based on the number of CPU cores.
Example of running the app with docker compose:
```shell
docker compose -f docker-compose.prod.yml up -d --build
```
2025-12-14 17:55:13 +00:00
## Conventions
2025-12-14 17:47:51 +00:00
This project uses the
[FastAPI best practices](https://github.com/zhanymkanov/fastapi-best-practices)
documented by GitHub user zhanymkanov and was originally created from their
[template](https://github.com/zhanymkanov/fastapi_production_template).
2025-12-14 17:55:13 +00:00
## Copyright
2025-12-14 17:47:51 +00:00
Copyright © 2025 SR2 Communications Limited.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.