Skip to content
This repository was archived by the owner on Jul 21, 2025. It is now read-only.

Commit bf087e6

Browse files
authored
feat: docker compose (#32)
1 parent 3d370ae commit bf087e6

File tree

22 files changed

+190
-92
lines changed

22 files changed

+190
-92
lines changed

.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.venv
2+
.*_cache
3+
node_modules/
4+
__pycache__

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,4 @@ cython_debug/
171171

172172
# PyPI configuration file
173173
.pypirc
174+
.vscode/

Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# https://docs.astral.sh/uv/guides/integration/docker/#intermediate-layer
2+
3+
FROM python:3.12-slim AS builder
4+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
5+
6+
WORKDIR /app
7+
8+
RUN --mount=type=cache,target=/root/.cache/uv \
9+
--mount=type=bind,source=uv.lock,target=uv.lock \
10+
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
11+
uv sync --frozen --no-install-project --no-build-package stacrs --refresh
12+
13+
ADD . /app
14+
15+
RUN --mount=type=cache,target=/root/.cache/uv \
16+
uv sync --frozen --no-editable
17+
18+
FROM python:3.12-slim
19+
COPY --from=builder --chown=app:app /app/.venv /app/.venv
20+
21+
CMD [ "/app/.venv/bin/uvicorn", "tistac.main:app" ]

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,15 @@ Then:
2020
scripts/dev
2121
```
2222

23-
This will start the server on <http://127.0.0.1:8000/>.
23+
This will start the **stac-fastapi** server on <http://127.0.0.1:8000/>.
24+
25+
To start both a **pgstac** and **stac-fastapi** server:
26+
27+
```shell
28+
docker compose up
29+
```
30+
31+
This will start **pgstac** on <http://127.0.0.1:8000> and **stac-fastapi** on <http://127.0.0.1:8001>.
2432

2533
## Developing
2634

docker-compose.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
services:
2+
pgstac:
3+
container_name: pgstac
4+
image: ghcr.io/stac-utils/pgstac:v0.9.1
5+
environment:
6+
- POSTGRES_USER=username
7+
- POSTGRES_PASSWORD=password
8+
- POSTGRES_DB=pgstac
9+
- PGUSER=username
10+
- PGPASSWORD=password
11+
- PGDATABASE=pgstac
12+
ports:
13+
- 5432:5432
14+
healthcheck:
15+
test: ["CMD-SHELL", "pg_isready", "-d", "pgstac"]
16+
interval: 1s
17+
timeout: 20s
18+
retries: 20
19+
tistac-pgstac:
20+
container_name: tistac-pgstac
21+
build: .
22+
environment:
23+
- TISTAC_BACKEND=postgresql://username:password@pgstac:5432/pgstac
24+
- UVICORN_HOST=0.0.0.0
25+
- UVICORN_PORT=8000
26+
ports:
27+
- 8000:8000
28+
depends_on:
29+
pgstac:
30+
condition: service_healthy
31+
tistac-stac-fastapi:
32+
container_name: tistac-stac-fastapi
33+
build: .
34+
environment:
35+
- TISTAC_BACKEND=/app/data/naip.parquet
36+
- UVICORN_HOST=0.0.0.0
37+
- UVICORN_PORT=8001
38+
ports:
39+
- 8001:8001
40+
volumes:
41+
- ./data:/app/data

main.py

Lines changed: 0 additions & 3 deletions
This file was deleted.

scripts/dev

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
set -e
44

5-
TISTAC_BACKEND=data/naip.parquet uv run fastapi dev
5+
TISTAC_BACKEND=data/naip.parquet uv run fastapi dev src/tistac/main.py

src/tistac/app.py

Lines changed: 0 additions & 55 deletions
This file was deleted.

src/tistac/backend.py renamed to src/tistac/backends/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from abc import ABC, abstractmethod
22

3-
from .item_collection import ItemCollection
4-
from .search import Search
3+
from tistac.models.item_collection import ItemCollection
4+
from tistac.models.search import Search
55

66

77
class Backend(ABC):

src/tistac/pgstac.py renamed to src/tistac/backends/pgstac.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
from pgstacrs import Client
44

5-
from .backend import Backend
6-
from .item_collection import ItemCollection
7-
from .search import Search
5+
from tistac.backends import Backend
6+
from tistac.models.item_collection import ItemCollection
7+
from tistac.models.search import Search
88

99

1010
class PgstacBackend(Backend):

0 commit comments

Comments
 (0)