|
1 | | -# kukkuu |
2 | | -Godchildren of culture API |
| 1 | +# Kukkuu |
| 2 | + |
| 3 | +:baby: Godchildren of culture (kulttuurin kummilapset) API :violin: |
| 4 | + |
| 5 | +## Development with Docker |
| 6 | + |
| 7 | +1. Copy `docker-compose.env.yaml.example` to `docker-compose.env.yaml` and modify it if needed. |
| 8 | + |
| 9 | +2. Run `docker-compose up` |
| 10 | + |
| 11 | +The project is now running at [localhost:8081](http://localhost:8081) |
| 12 | + |
| 13 | +## Development without Docker |
| 14 | + |
| 15 | +Prerequisites: |
| 16 | + |
| 17 | +* PostgreSQL 10 |
| 18 | +* Python 3.7 |
| 19 | + |
| 20 | +### Installing Python requirements |
| 21 | + |
| 22 | +* Run `pip install -r requirements.txt` |
| 23 | +* Run `pip install -r requirements-dev.txt` (development requirements) |
| 24 | + |
| 25 | +### Database |
| 26 | + |
| 27 | +To setup a database compatible with default database settings: |
| 28 | + |
| 29 | +Create user and database |
| 30 | + |
| 31 | + sudo -u postgres createuser -P -R -S kukkuu # use password `kukkuu` |
| 32 | + sudo -u postgres createdb -O kukkuu kukkuu |
| 33 | + |
| 34 | +Allow user to create test database |
| 35 | + |
| 36 | + sudo -u postgres psql -c "ALTER USER kukkuu CREATEDB;" |
| 37 | + |
| 38 | +### Daily running |
| 39 | + |
| 40 | +* Create `.env` file: `touch .env` |
| 41 | +* Set the `DEBUG` environment variable to `1`. |
| 42 | +* Run `python manage.py migrate` |
| 43 | +* Run `python manage.py runserver localhost:8081` |
| 44 | + |
| 45 | +The project is now running at [localhost:8081](http://localhost:8081) |
| 46 | + |
| 47 | +## Keeping Python requirements up to date |
| 48 | + |
| 49 | +1. Install `pip-tools`: |
| 50 | + |
| 51 | + * `pip install pip-tools` |
| 52 | + |
| 53 | +2. Add new packages to `requirements.in` or `requirements-dev.in` |
| 54 | + |
| 55 | +3. Update `.txt` file for the changed requirements file: |
| 56 | + |
| 57 | + * `pip-compile requirements.in` |
| 58 | + * `pip-compile requirements-dev.in` |
| 59 | + |
| 60 | +4. If you want to update dependencies to their newest versions, run: |
| 61 | + |
| 62 | + * `pip-compile --upgrade requirements.in` |
| 63 | + |
| 64 | +5. To install Python requirements run: |
| 65 | + |
| 66 | + * `pip-sync requirements.txt` |
| 67 | + |
| 68 | +## Code format |
| 69 | + |
| 70 | +This project uses [`black`](https://github.com/ambv/black) for Python code formatting. |
| 71 | +We follow the basic config, without any modifications. Basic `black` commands: |
| 72 | + |
| 73 | +* To let `black` do its magic: `black .` |
| 74 | +* To see which files `black` would change: `black --check .` |
| 75 | + |
| 76 | +Or you can use [`pre-commit`](https://pre-commit.com/) to quickly format your code before committing. |
| 77 | + |
| 78 | + |
| 79 | +1. Install `pre-commit` (there are many ways to do but let's use pip as an example: |
| 80 | + * `pip install pre-commit` |
| 81 | +2. Set up git hooks from `.pre-commit-config.yaml`, run this command from project root: |
| 82 | + * `pre-commit install` |
| 83 | + |
| 84 | +After that, formatting hooks will run against all changed files before committing |
0 commit comments