Skip to content

Commit 9e9a99a

Browse files
committed
add very simple docker-compose configuration
1 parent 19e6524 commit 9e9a99a

6 files changed

Lines changed: 165 additions & 0 deletions

File tree

deploy/.env.example

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Copy this file to deploy/.env and fill in the values.
2+
3+
# Path on the host where forecast data files are stored.
4+
# This is mounted read-only into rawdataforecaster at /data/forecast.
5+
# Relative paths are resolved from the deploy/ directory.
6+
FORECAST_DATA_PATH=../data/forecast
7+
8+
# --- correctedforecaster (optional) ---
9+
# To enable correctedforecaster, set COMPOSE_PROFILES=corrected AND
10+
# point jsonfrontend at it via JSONFRONTEND_UPSTREAM.
11+
# Leave COMPOSE_PROFILES empty (or unset) to run without correction.
12+
13+
COMPOSE_PROFILES=
14+
JSONFRONTEND_UPSTREAM=rawdataforecaster:5052
15+
16+
# When enabling correctedforecaster, change the two lines above to:
17+
# COMPOSE_PROFILES=corrected
18+
# JSONFRONTEND_UPSTREAM=correctedforecaster:5051
19+
20+
# Path on the host where topography data files are stored.
21+
# Only used when correctedforecaster is enabled.
22+
TOPOGRAPHY_DATA_PATH=../data/topography

deploy/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.env

deploy/README.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Deploy
2+
3+
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.
4+
5+
## Prerequisites
6+
7+
- [Docker](https://docs.docker.com/get-docker/) with Compose support
8+
- Local forecast data (see [Preparing data](#preparing-data) below)
9+
10+
## Preparing data
11+
12+
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.
13+
14+
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.
15+
16+
## Services
17+
18+
| Service | Description | Default port |
19+
|---|---|---|
20+
| `rawdataforecaster` | Serves forecast data over gRPC from a local directory | `5052` |
21+
| `correctedforecaster` | Post-processes forecast data and re-exposes it over gRPC ||
22+
| `jsonfrontend` | REST API that serves point forecast timeseries as JSON | `8080` |
23+
24+
`correctedforecaster` is optional and must be enabled via a Docker Compose [profile](#profiles).
25+
26+
## Usage
27+
28+
Build and start the base services:
29+
30+
```bash
31+
docker compose up --build
32+
```
33+
34+
Test that the API is responding:
35+
36+
```bash
37+
curl 'http://localhost:8080/?lat=59&lon=11'
38+
```
39+
40+
### Enabling correctedforecaster
41+
42+
`correctedforecaster` is disabled by default. To enable it, set both variables in your `.env` file:
43+
44+
```bash
45+
COMPOSE_PROFILES=corrected
46+
JSONFRONTEND_UPSTREAM=correctedforecaster:5051
47+
```
48+
49+
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.
50+
51+
## Environment variables
52+
53+
| Variable | Default | Description |
54+
|---|---|---|
55+
| `FORECAST_DATA_PATH` | `../data/forecast` | Path to the local forecast data directory |
56+
| `TOPOGRAPHY_DATA_PATH` | `../data/topography` | Path to the local topography data directory (used by `correctedforecaster`) |
57+
| `JSONFRONTEND_UPSTREAM` | `rawdataforecaster:5052` | gRPC upstream address for `jsonfrontend` |
58+
59+
These can be set in a `.env` file in this directory (`.env` is gitignored). Copy `.env.example` as a starting point:
60+
61+
```bash
62+
cp .env.example .env
63+
```
64+
65+
## Configuration
66+
67+
`rawdataforecaster.config.json` configures how `rawdataforecaster` reads forecast data:
68+
69+
```json
70+
{
71+
"source": {
72+
"bucket": "file:///data/forecast"
73+
},
74+
"areas": ["meps"],
75+
"loader": {
76+
"type": "blob"
77+
}
78+
}
79+
```
80+
81+
- **`source.bucket`** — points to the mounted forecast data directory inside the container.
82+
- **`areas`** — list of forecast areas to load (e.g. `meps`).
83+
- **`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.

deploy/docker-compose.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
services:
2+
rawdataforecaster:
3+
build:
4+
context: ..
5+
dockerfile: rawdataforecaster/build/package/Dockerfile
6+
ports:
7+
- "5052:5052"
8+
volumes:
9+
- ./rawdataforecaster.config.json:/config.json:ro
10+
- ${FORECAST_DATA_PATH:-../data/forecast}:/data/forecast:ro
11+
command: ["-config", "/config.json"]
12+
networks:
13+
- internal
14+
15+
correctedforecaster:
16+
build:
17+
context: ..
18+
dockerfile: correctedforecaster/build/package/Dockerfile
19+
profiles: ["corrected"]
20+
volumes:
21+
- ${TOPOGRAPHY_DATA_PATH:-../data/topography}:/data/topography:ro
22+
command:
23+
- "-upstream"
24+
- "rawdataforecaster:5052"
25+
- "-workdir"
26+
- "/data/topography"
27+
depends_on:
28+
- rawdataforecaster
29+
networks:
30+
- internal
31+
32+
jsonfrontend:
33+
build:
34+
context: ..
35+
dockerfile: jsonfrontend/build/package/Dockerfile
36+
ports:
37+
- "8080:8080"
38+
command:
39+
- "-upstream"
40+
- "${JSONFRONTEND_UPSTREAM:-rawdataforecaster:5052}"
41+
depends_on:
42+
- rawdataforecaster
43+
networks:
44+
- internal
45+
46+
networks:
47+
internal:
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"source": {
3+
"bucket": "file:///data/forecast"
4+
},
5+
"areas": ["meps"],
6+
"loader": {
7+
"type": "blob"
8+
}
9+
}

justfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ build-docker *modules="correctedforecaster healthz jsonfrontend moxfrontend rawd
22
set -e; for module in {{ modules }}; do \
33
docker build -t forti_$module -f $module/build/package/Dockerfile .; \
44
done
5+
6+
run-docker:
7+
cd deploy && docker compose up --build

0 commit comments

Comments
 (0)