Skip to content

Commit b0fc11a

Browse files
committed
Updated read to explain Docker usage
1 parent b80d103 commit b0fc11a

3 files changed

Lines changed: 195 additions & 17 deletions

File tree

PLAN.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ All Python repos follow the same pattern: FastAPI service, structured as a packa
7676
- Convert NSW API calls to async using `httpx` + `asyncio` # check with surveyor, bit of a big change and already runs API calls in parallel using ThreadPoolExecutor
7777

7878
### Definition of done
79-
- All 3 GitHub issues closed with a PR each # no pr
79+
- All 3 GitHub issues closed with a PR each # DONE
8080
- `pytest tests/` passes with no live API calls # DONE
81-
- Green CI badge visible on the GitHub repo # not done
82-
- `docker build` succeeds # not tested
83-
- `/mark/TS/2761` returns a SurveyMark JSON object # needs to be checked
84-
- `/mark/TS/2761/sketch` returns a PDF # not done
85-
- Surface level appears in the `search` block of GeoJSON output # needs to be checked
81+
- Green CI badge visible on the GitHub repo # DONE
82+
- `docker build` succeeds # DONE
83+
- `/mark/TS/2761` returns a SurveyMark JSON object # DONE
84+
- `/mark/TS/2761/sketch` returns a PDF # check with surveyor about doing this
85+
- Surface level appears in the `search` block of GeoJSON output # DONE "surface_level_ahd" is reported
8686
- `GET /history` returns the last 20 searches # DONE
8787

8888
### Career skills demonstrated

README.md

Lines changed: 67 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ git clone https://github.com/jamAM7/mls-spatial.git
1717
cd mls-spatial
1818
```
1919

20-
2. Place `credentials.json` and `token.json` in the project root (obtain from project administrator)
20+
2. Place `credentials.json` in the project root (obtain from project administrator)
2121

2222
3. Create and activate a virtual environment
2323

@@ -37,34 +37,90 @@ source venv/bin/activate
3737
pip install -r requirements.txt
3838
```
3939

40+
5. Authenticate with Google Drive (first time only)
41+
42+
Run the console app once:
43+
```
44+
python console/run.py
45+
```
46+
47+
A browser window will open asking you to authorise Google Drive access. Complete it and `token.json` will be created in the project root. You only need to do this once — the token is reused and auto-refreshed on every subsequent run.
48+
4049
## Running with Docker (recommended)
4150

42-
Docker is the easiest way to run the service without configuring a local Python environment.
51+
Docker runs the FastAPI service in an isolated container with no local Python environment required. The console app still runs locally against the service over HTTP.
4352

44-
### Requirements
45-
- [Docker Desktop](https://www.docker.com/products/docker-desktop/)
53+
### Prerequisites
54+
- [Docker Desktop](https://www.docker.com/products/docker-desktop/) installed and running
4655
- `credentials.json` and `token.json` in the project root
4756

48-
### Start the service
57+
`token.json` must exist before starting Docker — the container cannot run the interactive browser auth flow. Complete step 5 of [Setup](#setup) first if you haven't already.
58+
59+
### First run
60+
61+
Create an empty database file so Docker mounts it correctly:
62+
```
63+
touch mls_spatial.db
64+
```
65+
66+
Then start the service:
4967
```
5068
docker compose up --build
5169
```
5270

53-
The service will be available at `http://localhost:8000`.
71+
The `--build` flag builds the image from the Dockerfile. The first run takes a minute or two to download the base image and install dependencies — subsequent starts are fast.
72+
73+
The FastAPI service will be available at `http://localhost:8000`.
5474

55-
To run in the background:
75+
### Day-to-day usage
76+
77+
Start the service:
5678
```
57-
docker compose up --build -d
79+
docker compose up
5880
```
5981

60-
To stop:
82+
Once you see this in the terminal, the service is running:
83+
```
84+
mls-spatial-mls-spatial-1 | INFO: Application startup complete.
85+
mls-spatial-mls-spatial-1 | INFO: Uvicorn running on http://0.0.0.0:8000
86+
```
87+
88+
The FastAPI service is now running at `http://localhost:8000`. You can verify it's working by opening `http://localhost:8000/docs` in your browser — this shows the interactive API documentation where you can test endpoints directly.
89+
90+
To run the console app, open a separate terminal and run:
91+
```
92+
python console/run.py
93+
```
94+
95+
To start the service in the background (no terminal output):
96+
```
97+
docker compose up -d
98+
```
99+
100+
To stop the service:
61101
```
62102
docker compose down
63103
```
64104

105+
Rebuild after code changes:
106+
```
107+
docker compose up --build
108+
```
109+
110+
### What gets mounted
111+
112+
The container shares these paths with your local machine — no rebuild needed when these files change:
113+
114+
| Host path | Container path | Purpose |
115+
|---|---|---|
116+
| `./credentials.json` | `/app/credentials.json` | Google OAuth credentials |
117+
| `./token.json` | `/app/token.json` | Google OAuth token (auto-refreshed) |
118+
| `./output/` | `/app/output/` | Search results and generated files |
119+
| `./mls_spatial.db` | `/app/mls_spatial.db` | Search history database |
120+
65121
## Usage
66122

67-
Run the console app:
123+
With either the local server or Docker running, start the console app:
68124
```
69125
python console/run.py
70126
```
@@ -91,7 +147,7 @@ Results are saved to `output/{address}-{date}/` containing:
91147

92148
## FastAPI Service
93149

94-
For programmatic access or the AutoCAD add-in:
150+
For programmatic access or the AutoCAD add-in, the service can also be run locally without Docker:
95151
```
96152
uvicorn service.server:app --port 8000
97153
```

0 commit comments

Comments
 (0)