Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove nix introduce uv #64

Merged
merged 6 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 58 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,79 +1,89 @@
# Undead Mongoose

Django application for the mongoose backend & board interface, build in Django.
Django application for the mongoose backend & board interface.

## Prerequisites

To run Undead Mongoose, you need:
Install [uv](https://docs.astral.sh/uv/getting-started/installation/) and then let uv install the correct python version and the dependencies.

- docker
- docker-compose
- nix
- Python 3.8
- dotenv (`python3-dotenv-cli` on Ubuntu)
```bash
git clone https://github.com/svsticky/undead-mongoose.git
cd undead-mongoose
uv sync
```

## Setting up
First, run

Copy `sample.env` to `.env` and edit where necessary.

Setup the database with:
Copy `sample.env` to `.env` and make sure the database options are correct. By default the credentials are setup to use the docker database. Then run the following commands to setup the database:

``` bash
docker-compose up -d
dotenv nix-shell --run "./manage.py migrate"
```bash
docker compose up -d
uv run --env-file .env ./manage.py migrate
```

In development, create an admin superuser
``` bash
dotenv nix-shell --run "./manage.py createsuperuser"

```bash
uv run --env-file .env ./manage.py createsuperuser
```

### Setup Koala connection (local)
Then depending on whether you want to use a local version of koala, you need to do some additional setup:

(In development) Change `KOALA_DB_NAME` to `koala-development`
- *If you have a locally running version of koala*: (In development) Change `KOALA_DB_NAME` to `koala-development`

Create the `undead_mongoose` user in Koala's database:
```sql
CREATE USER undead_mongoose WITH PASSWORD 'mongoose123';
```
Create the `undead_mongoose` user in Koala's database:

Configure privileges for the `undead_mongoose` user in Koala's database (Replace `koala` with `koala-development` in development):
```sql
\c "koala"
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO undead_mongoose;
```
```sql
CREATE USER undead_mongoose WITH PASSWORD 'mongoose123';
```

To enable oauth, you should go to koala.rails.local:3000/api/oauth/applications and create a new application with {{ canonical_hostname }}/oidc/callback/ as the callback url.
Configure privileges for the `undead_mongoose` user in Koala's database (Replace `koala` with `koala-development` in development):

It's also possible to generate the client through your CLI in the `constipiated-koala` project by running the command below
```bash
bundle exec rake "doorkeeper:create[undead Mongoose, http://localhost:8000/oidc/callback/, openid profile email member-read]"
```
```sql
\c "koala"
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO undead_mongoose;
```

Ensure scopes 'openid member-read email profile' are present. Also ensure to copy the application_id and secret and put them in your `.env` file.
To enable oauth, you should go to koala.rails.local:3000/api/oauth/applications and create a new application with {{ canonical_hostname }}/oidc/callback/ as the callback url.

```ini
API_TOKEN=koala
It's also possible to generate the client through your CLI in the `constipiated-koala` project by running the command below

OIDC_RP_CLIENT_ID=example_id
OIDC_RP_CLIENT_SECRET=example_secret
```bash
bundle exec rake "doorkeeper:create[undead Mongoose, http://localhost:8000/oidc/callback/, openid profile email member-read]"
```

ALLOWED_HOSTS=localhost
```
Ensure scopes 'openid member-read email profile' are present. Also ensure to copy the application_id and secret and put them in your `.env` file.

Make sure that the `OIDC_OP_*_ENDPOINT` endpoints are correct. The ones in sample.env should suffice.
```ini
API_TOKEN=koala

Alter Koala's `.env` file such that the following keys have the following values:
```ini
CHECKOUT_TOKEN=koala
```
OIDC_RP_CLIENT_ID=example_id
OIDC_RP_CLIENT_SECRET=example_secret

ALLOWED_HOSTS=localhost
```

Make sure that the `OIDC_OP_*_ENDPOINT` endpoints are correct. The ones in sample.env should suffice.

Alter Koala's `.env` file such that the following keys have the following values:

```ini
CHECKOUT_TOKEN=koala
```

- *Alternatively, use the staging version of koala:* create an oauth application for your mongoose installation via <https://koala.dev.svsticky.nl/api/oauth/applications>. Make sure you log in with the <[email protected]> account to access the page. Create a new application with the following information:
- Confidential: `true`
- Callback url: `http://localhost:8000/oidc/callback/`
- Scopes: `openid profile email member-read`

Copy the application id and secret into the `.env` file and make sure you update the oauth urls to point to koala.dev.svsticky.nl.

## Running

``` bash
# database
docker-compose up -d
# server
nix-shell --run "./manage.py runserver"
# Database
docker compose up -d

# Server
uv run --env-file .env ./manage.py runserver
```
41 changes: 0 additions & 41 deletions nix/django-constance.nix

This file was deleted.

25 changes: 0 additions & 25 deletions nix/django-oidc.nix

This file was deleted.

26 changes: 0 additions & 26 deletions nix/sources.json

This file was deleted.

Loading
Loading