Skip to content

Commit

Permalink
devcontainer: update README
Browse files Browse the repository at this point in the history
  • Loading branch information
thomersch committed Jan 12, 2024
1 parent eb0d207 commit 8d6e1cc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 68 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:

services:
postgres:
image: postgis/postgis
image: postgis/postgis:15-3.4
env:
POSTGRES_USER: osmcal
POSTGRES_PASSWORD: postgres
Expand Down
77 changes: 10 additions & 67 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,62 +13,22 @@ Please look at [OpenStreetMap Calendar Documentation](https://osmcal.org/documen

## Developer Documentation

This is a Django application, it uses [poetry](https://python-poetry.org) for managing dependencies. Please look at their documentation for installation instructions.
The repo contains a [dev container](https://containers.dev) configuration, so you can develop without having to install all the dependencies on your machine manually. VS Code and PyCharm/IntelliJ have integrated support and you can even use Github Codespaces.

We support Python ≥ 3.8 and PostgreSQL ≥ 10.
Alternatively you can install like any other Python/Django project. We're using [poetry](https://python-poetry.org) for managing dependencies. Please look at their documentation for installation instructions.

### Database

You need a running PostgreSQL database. There are two options: Running it locally or using Docker.

#### A) Local Installation
Create a PostgreSQL user called `osmcal` and a database `osmcal` with the owner set to `osmcal`. E.g.
```
CREATE ROLE osmcal WITH LOGIN ENCRYPTED PASSWORD 'postgres';
CREATE DATABASE osmcal OWNER osmcal;
CREATE EXTENSION postgis;
```

Make sure you have following line in your [pg_hba.conf](https://www.postgresql.org/docs/12/auth-pg-hba-conf.html), so osmcal need a password to log in:
```
local all all trust
```
Alternatively, you can set your DB password using the `POSTGRES_PASSWORD` environment variable, c.f. the following section on Docker.


#### B) Docker

```
docker run -e POSTGRES_DB='osmcal' -e POSTGRES_USER='osmcal' -e POSTGRES_PASSWORD='postgres' --name osmcaldb postgis/postgis
```

*Note:* You can use `docker start osmcaldb` and `docker stop osmcaldb` after first run of the command above.

When using database in docker with the command above, the database host is:

```
export OSMCAL_PG_HOST=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' osmcaldb)
```

and database password is:

```
export OSMCAL_PG_PASSWORD='postgres'
```
We support Python ≥ 3.11 and PostgreSQL ≥ 15. (Older versions might work, but no guarantees).

### Virtual Environment
### Database

Use *poetry* to create a virtual environment. Then, install the dependencies:
You need a running PostgreSQL database with PostGIS installed. If you're using the dev container, the DB is automatically started and set up.

```
cd openstreetmap-calendar
poetry install
```
If you set this up manually, make sure you have an empty DB before starting. By default we're using

### Running Tests

```
poetry run ./manage.py test
make test
```

### Developer Server
Expand All @@ -78,38 +38,21 @@ In order to facilitate testing, you can use a fake login locally without having
To prepare for application launch run the database migrations:

```
poetry run ./manage.py migrate
make migrate
```

and then the local server:

```
poetry run ./manage.py runserver
make devserver
```

If you need test data, you can load some using:

```
poetry run ./manage.py loaddata osmcal/fixtures/demo.yaml
make fixtures
```

## API Documentation

The API is described using OpenAPI 3, the schema is located in `/api/schema/`. The currently live version is [visible here](https://osmcal.org/static/api.html).

## OAuth Setup

If want to test the OAuth flow, you need to create an OAuth app first:

1. Go to osm.org -> My Settings -> oauth settings -> bottom of the page (My Client Applications) -> Register your application.
2. Fill `Name` and `Main Application URL`. No restrictions here.
3. You *must* fill `Callback URL` with `http://localhost:8000/oauth/callback`.
4. Mark `read their user preferences.`
5. Click `Register`.

When the application is registered on osm.org, set the respective environment variables used for oauth and copy *Consumer Key* and *Consumer Secret*:

```
export OSMCAL_OSM_KEY='...'
export OSMCAL_OSM_SECRET='...'
```

0 comments on commit 8d6e1cc

Please sign in to comment.