Watch
1
0
Fork
You've already forked drillapi
0
mirror of https://github.com/SFOE/drillapi.git synced 2026-08-17 12:42:05 +00:00
Read-only mirror of https://github.com/SFOE/drillapi — Bundesamt für Energie. Issues & pull requests at the source. Catalog: https://www.opensource.admin.ch/en/softwares/fqylpd https://www.opensource.admin.ch/en/softwares/fqylpd
  • Python 96.1%
  • HTML 3.7%
  • Dockerfile 0.2%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-08-03 12:06:05 +00:00
.github bump to v12 2026-07-23 14:38:55 +02:00
src/drillapi Update dependencies (#213) 2026-06-04 10:33:21 +02:00
tests Better test coverage (#211) 2026-06-04 10:20:47 +02:00
.gitattributes Handle inactive canton, better edge cases handling (#113) 2026-01-26 14:35:22 +01:00
.gitignore switch project to uv (#101) 2026-01-20 09:40:48 +01:00
.inspector-ignore feat: scan image upon PR and fix security findings 2026-06-24 09:15:54 +02:00
.pre-commit-config.yaml Use ruff (#133) 2026-02-02 10:58:45 +01:00
docker-compose.yml Refactor (#67) 2025-12-17 11:15:36 +01:00
Dockerfile Update base image and fix cantonal failures (#188) 2026-04-23 14:23:04 +02:00
Dockerfile.lambda update base image on build 2026-06-24 09:26:13 +02:00
env.example remove ALLOWED_IP setting (#102) 2026-01-20 10:01:06 +01:00
LICENSE Add GNU GPL v3 license (#64) 2025-12-16 11:55:17 +01:00
publiccode.yml chore: update publiccode.yml to v0.2.1 2026-07-01 07:12:56 +00:00
pyproject.toml Bump pydantic-settings from 2.14.1 to 2.14.2 (#223) 2026-06-24 07:52:36 +02:00
pytest.ini setup CI, dev containers, tests, pre-commit 2025-10-28 09:01:21 +01:00
README.md Use ruff (#133) 2026-02-02 10:58:45 +01:00
uv.lock Merge pull request #218 from SFOE/feat/scan-image-upon-pr 2026-06-24 13:17:54 +02:00

CI CI

drillapi - geothermal drilling

Query the cantonal geoservices to know whether a site in Switzerland is suitable for a geothermal drilling.

What does this FastAPI project do ?

  • take x/y coordinates in EPSG:2056 on route /v1/x/y
  • find in which canton the coordinates are and retrieve specific geoservice configuration
  • send request to corresponding cantonal geoservices, depending on location
  • process and reclass the results (1: OK, 2: With restriction, 3: Forbidden, 4: Unknown or Service Error)
  • return reponse used by drill-frontend vuejs web app

Run

This project can run in docker:

Latest image

docker run -d \
 -p 8000:8000 \
 -e RATE_LIMIT="1000/minute" \
 -e ALLOWED_ORIGINS='["http://localhost:5173","https://www.uvek-gis.admin.ch/"]' \
 -e ENVIRONMENT=PROD \
 ghcr.io/sfoe/drillapi:latest

Release specific image

docker run -d \
 -p 8000:8000 \
 -e RATE_LIMIT="1000/minute" \
 -e ALLOWED_ORIGINS='["http://localhost:5173","https://www.uvek-gis.admin.ch/"]' \
 -e ENVIRONMENT=PROD \
 ghcr.io/sfoe/drillapi:<vx.y.z>

Local setup for development

This project uses UV

Create .env file and ⚠️ adapt values ⚠️

Special attention to the ENVIRONMENT value, MUST never be set to DEV in production environnement

cp env.example .env

Install dependencies using UV

uv sync

For dev install dev requirements

uv sync --extra dev

Use Ruff

Check

uv run ruff check --fix

Format

uv run ruff format .

Maintenance

Dependabot is configured to search for update on a weekly basis and open PRs when necessary.

Upgrade dependencies manually

If you need to update on an emergency, you can update manually.

uv lock --upgrade

Start

Run dev server

uv run uvicorn drillapi.app:app --reload

Run project

uv run python -m drillapi

Explore

OpenAPI doc

http://127.0.0.1:8000/docs

Checker that sends predefined calls to all configured cantons

http://127.0.0.1:8000/checker

Or check one canton only

http://127.0.0.1:8000/checker/VD

Main route v1

http://127.0.0.1:8000/v1/drill-category/2602531.09/1202835.00

Canton's configuration v1

http://127.0.0.1:8000/v1/cantons

Canton's configuration v1 for one canton's code ("NE", "BE")

http://127.0.0.1:8000/v1/cantons/NE

Test

Install dev requirements

uv sync --extra dev

Run tests

uv run python -m pytest -v

Running local docker image

Using Docker Compose

docker compose up -d --build && docker compose logs -f drillapi

Using Docker

Build local image

docker build -t drillapi .

Run container

docker run -d -p 8000:8000 --name drillapi_container drillapi

Build lambda image locally

sudo docker build -t drillapi-lambda .

Run lambda image locally

docker run -p 9000:8000 drillapi-lambda

View logs for docker image

docker logs -f drillapi_container

Stop container

docker stop drillapi_container
docker rm drillapi_container