2024-07-14 21:14:07 +00:00
|
|
|
# data.coop member system
|
2019-08-31 22:25:25 +00:00
|
|
|
|
2024-07-14 21:14:07 +00:00
|
|
|
## Development setup
|
2023-10-02 18:10:24 +00:00
|
|
|
|
2024-07-14 21:14:07 +00:00
|
|
|
There are two ways to setup the development environment.
|
2023-10-02 18:10:24 +00:00
|
|
|
|
2024-07-14 21:14:07 +00:00
|
|
|
- Using the Docker Compose setup provided in this repository.
|
|
|
|
- Using [hatch](https://hatch.pypa.io/) in your host OS.
|
2023-10-02 18:10:24 +00:00
|
|
|
|
2024-07-14 21:14:07 +00:00
|
|
|
### Using Docker Compose
|
2023-10-02 18:10:24 +00:00
|
|
|
|
2024-07-14 21:14:07 +00:00
|
|
|
Working with the Docker Compose setup is made easy with the `Makefile` provided in the repository.
|
2023-10-02 18:10:24 +00:00
|
|
|
|
|
|
|
#### Requirements
|
2019-08-31 22:25:25 +00:00
|
|
|
|
2021-02-28 23:15:01 +00:00
|
|
|
- Docker
|
2024-07-14 21:14:07 +00:00
|
|
|
- docker compose plugin
|
2019-08-31 22:25:25 +00:00
|
|
|
|
2023-10-02 18:10:24 +00:00
|
|
|
#### Setup
|
2019-08-31 22:25:25 +00:00
|
|
|
|
2024-07-14 21:14:07 +00:00
|
|
|
1. Setup .env file
|
2019-08-31 22:25:25 +00:00
|
|
|
|
2024-07-20 20:24:41 +00:00
|
|
|
An example .env file is provided in the repository. You can copy it to .env file using the following command:
|
2019-08-31 22:25:25 +00:00
|
|
|
|
2024-07-20 20:24:41 +00:00
|
|
|
```bash
|
|
|
|
cp .env.example .env
|
|
|
|
```
|
2019-08-31 22:25:25 +00:00
|
|
|
|
2024-07-20 20:24:41 +00:00
|
|
|
The default values in the .env file are suitable for the docker-compose setup.
|
2019-08-31 22:25:25 +00:00
|
|
|
|
2024-07-14 21:14:07 +00:00
|
|
|
2. Migrate
|
2019-08-31 22:25:25 +00:00
|
|
|
|
2024-07-20 20:24:41 +00:00
|
|
|
```bash
|
|
|
|
make migrate
|
|
|
|
```
|
2019-08-31 22:25:25 +00:00
|
|
|
|
2024-07-14 21:14:07 +00:00
|
|
|
3. Run the development server
|
2021-02-28 23:15:01 +00:00
|
|
|
|
2024-07-20 20:24:41 +00:00
|
|
|
```bash
|
|
|
|
make run
|
|
|
|
```
|
2021-02-28 23:15:01 +00:00
|
|
|
|
2024-07-20 20:33:30 +00:00
|
|
|
#### Building and running other things
|
|
|
|
|
|
|
|
```bash
|
|
|
|
# Build the containers
|
|
|
|
make build
|
|
|
|
|
|
|
|
# Create a superuser
|
|
|
|
make createsuperuser
|
|
|
|
|
|
|
|
# Create Django migrations (after this, maybe you need to change file permissions in volume)
|
|
|
|
make makemigrations
|
|
|
|
```
|
|
|
|
|
2024-07-14 21:14:07 +00:00
|
|
|
### Using hatch
|
2021-02-28 23:15:01 +00:00
|
|
|
|
2024-07-14 21:14:07 +00:00
|
|
|
#### Requirements
|
2023-10-02 18:10:24 +00:00
|
|
|
|
2024-07-14 21:14:07 +00:00
|
|
|
- Python 3.12 or higher
|
|
|
|
- [hatch](https://hatch.pypa.io/) (Recommended way to install is using `pipx install hatch`)
|
|
|
|
- A running PostgreSQL server
|
2023-10-02 18:10:24 +00:00
|
|
|
|
2024-07-14 21:14:07 +00:00
|
|
|
#### Setup
|
2023-10-02 18:10:24 +00:00
|
|
|
|
2024-07-14 21:14:07 +00:00
|
|
|
1. Setup .env file
|
2023-10-02 18:10:24 +00:00
|
|
|
|
2024-07-20 20:24:41 +00:00
|
|
|
An example .env file is provided in the repository. You can copy it to .env file using the following command:
|
2023-10-02 18:10:24 +00:00
|
|
|
|
2024-07-20 20:24:41 +00:00
|
|
|
```bash
|
|
|
|
cp .env.example .env
|
|
|
|
```
|
2023-10-02 18:10:24 +00:00
|
|
|
|
2024-07-20 20:24:41 +00:00
|
|
|
Edit the .env file and set the values for the environment variables, especially the database variables.
|
2023-10-02 18:10:24 +00:00
|
|
|
|
2024-07-14 21:14:07 +00:00
|
|
|
2. Run migrate
|
2023-10-02 18:10:24 +00:00
|
|
|
|
2024-07-20 20:24:41 +00:00
|
|
|
```bash
|
|
|
|
hatch run dev:migrate
|
|
|
|
```
|
2023-10-02 18:10:24 +00:00
|
|
|
|
2024-07-14 21:14:07 +00:00
|
|
|
3. Run the development server
|
2023-10-02 18:10:24 +00:00
|
|
|
|
2024-07-20 20:24:41 +00:00
|
|
|
```bash
|
|
|
|
hatch run dev:server
|
|
|
|
```
|
2024-07-31 21:26:40 +00:00
|
|
|
|
|
|
|
#### Updating requirements
|
|
|
|
|
|
|
|
If you want to update the requirements, you can run the following command:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
hatch run requirements
|
|
|
|
```
|
|
|
|
|
|
|
|
This uses [hatch-pip-compile](https://juftin.com/hatch-pip-compile/) to update the requirements.
|