Skip to content
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
22 changes: 22 additions & 0 deletions deploy/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copy this file to deploy/.env and fill in the values.

# Path on the host where forecast data files are stored.
# This is mounted read-only into rawdataforecaster at /data/forecast.
# Relative paths are resolved from the deploy/ directory.
FORECAST_DATA_PATH=../data/forecast

# --- correctedforecaster (optional) ---
# To enable correctedforecaster, set COMPOSE_PROFILES=corrected AND
# point jsonfrontend at it via JSONFRONTEND_UPSTREAM.
# Leave COMPOSE_PROFILES empty (or unset) to run without correction.

COMPOSE_PROFILES=
JSONFRONTEND_UPSTREAM=rawdataforecaster:5052

# When enabling correctedforecaster, change the two lines above to:
# COMPOSE_PROFILES=corrected
# JSONFRONTEND_UPSTREAM=correctedforecaster:5051

# Path on the host where topography data files are stored.
# Only used when correctedforecaster is enabled.
TOPOGRAPHY_DATA_PATH=../data/topography
1 change: 1 addition & 0 deletions deploy/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.env
83 changes: 83 additions & 0 deletions deploy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Deploy

This folder contains configuration for running Forti locally using Docker Compose. It brings up the core services — `rawdataforecaster`, `correctedforecaster`, and `jsonfrontend` — using local forecast data.

## Prerequisites

- [Docker](https://docs.docker.com/get-docker/) with Compose support
- Local forecast data (see [Preparing data](#preparing-data) below)

## Preparing data

Forecast data can be produced using [forti-prep](https://github.com/metno/forti-prep), a companion tool that downloads and post-processes the input datasets into the format expected by Forti.

By default, the Compose setup expects forecast data to be available at `../data/forecast` (relative to this folder), which corresponds to `data/forecast/` in the repository root. You can override this with the `FORECAST_DATA_PATH` environment variable.

## Services

| Service | Description | Default port |
|---|---|---|
| `rawdataforecaster` | Serves forecast data over gRPC from a local directory | `5052` |
| `correctedforecaster` | Post-processes forecast data and re-exposes it over gRPC | — |
| `jsonfrontend` | REST API that serves point forecast timeseries as JSON | `8080` |

`correctedforecaster` is optional and must be enabled via a Docker Compose [profile](#profiles).

## Usage

Build and start the base services:

```bash
docker compose up --build
```

Test that the API is responding:

```bash
curl 'http://localhost:8080/?lat=59&lon=11'
```

### Enabling correctedforecaster

`correctedforecaster` is disabled by default. To enable it, set both variables in your `.env` file:

```bash
COMPOSE_PROFILES=corrected
JSONFRONTEND_UPSTREAM=correctedforecaster:5051
```

Both need to change together: `COMPOSE_PROFILES` starts the container, and `JSONFRONTEND_UPSTREAM` points `jsonfrontend` at it. Leave `COMPOSE_PROFILES` empty (or unset) to run without correction.

## Environment variables

| Variable | Default | Description |
|---|---|---|
| `FORECAST_DATA_PATH` | `../data/forecast` | Path to the local forecast data directory |
| `TOPOGRAPHY_DATA_PATH` | `../data/topography` | Path to the local topography data directory (used by `correctedforecaster`) |
| `JSONFRONTEND_UPSTREAM` | `rawdataforecaster:5052` | gRPC upstream address for `jsonfrontend` |

These can be set in a `.env` file in this directory (`.env` is gitignored). Copy `.env.example` as a starting point:

```bash
cp .env.example .env
```

## Configuration

`rawdataforecaster.config.json` configures how `rawdataforecaster` reads forecast data:

```json
{
"source": {
"bucket": "file:///data/forecast"
},
"areas": ["meps"],
"loader": {
"type": "blob"
}
}
```

- **`source.bucket`** — points to the mounted forecast data directory inside the container.
- **`areas`** — list of forecast areas to load (e.g. `meps`).
- **`loader.type`** — `"blob"` streams data on demand rather than loading everything into memory. Keep this as `"blob"` unless you have a specific reason to change it.
47 changes: 47 additions & 0 deletions deploy/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
services:
rawdataforecaster:
build:
context: ..
dockerfile: rawdataforecaster/build/package/Dockerfile
ports:
- "5052:5052"
volumes:
- ./rawdataforecaster.config.json:/config.json:ro
- ${FORECAST_DATA_PATH:-../data/forecast}:/data/forecast:ro
command: ["-config", "/config.json"]
networks:
- internal

correctedforecaster:
build:
context: ..
dockerfile: correctedforecaster/build/package/Dockerfile
profiles: ["corrected"]
volumes:
- ${TOPOGRAPHY_DATA_PATH:-../data/topography}:/data/topography:ro
command:
- "-upstream"
- "rawdataforecaster:5052"
- "-workdir"
- "/data/topography"
depends_on:
- rawdataforecaster
networks:
- internal

jsonfrontend:
build:
context: ..
dockerfile: jsonfrontend/build/package/Dockerfile
ports:
- "8080:8080"
command:
- "-upstream"
- "${JSONFRONTEND_UPSTREAM:-rawdataforecaster:5052}"
depends_on:
- rawdataforecaster
networks:
- internal

networks:
internal:
9 changes: 9 additions & 0 deletions deploy/rawdataforecaster.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"source": {
"bucket": "file:///data/forecast"
},
"areas": ["meps"],
"loader": {
"type": "blob"
}
}
3 changes: 3 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ build-docker *modules="correctedforecaster healthz jsonfrontend moxfrontend rawd
set -e; for module in {{ modules }}; do \
docker build -t forti_$module -f $module/build/package/Dockerfile .; \
done

run-docker:
cd deploy && docker compose up --build
Loading