Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add UI to stack #7

Merged
merged 1 commit into from
Jul 16, 2024
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
24 changes: 19 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ docker compose exec api fastapi dev --host 0.0.0.0 ./src/aross_stations_db/api

From here, you can interactively pause at any `breakpoint()` calls in the Python code.


### UI development

The instructions below specify starting the stack with the `--profile ui` option. If you
wish to develop in
[the user interface code repository](https://github.com/nsidc/aross-stations-ui), you
should omit that flag and follow the instructions in the UI repo to develop.

</details>


Expand Down Expand Up @@ -112,7 +120,7 @@ The stack is configured within `compose.yml` and includes containers:
* `aross-stations-api`: An HTTP API for accessing data in the database.

```bash
docker compose up --pull=always --detach
docker compose --profile ui up --pull=always --detach
```

> [!IMPORTANT]
Expand Down Expand Up @@ -203,13 +211,19 @@ You can replace `api` with any other service name, or omit it to view logs for a
services.


## View UI
### View UI

Navigate to `http://localhost:80`.


### Experiment in JupyterLab

For now, it's just a Jupyterlab instance with a demo notebook. In your browser, navigate
to `http://localhost:8888`. The password is the same as the database password you set earlier.
This repository provides a demo notebook to experiment with the API. In your browser,
navigate to `http://localhost:8888`. The password is the same as the database password
you set earlier.

This UI will likely be replaced with something more robust. Who knows ;)

## Cleanup

### Shutdown

Expand Down
17 changes: 14 additions & 3 deletions compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,23 @@ x-dev-common: &dev-common


services:
ui:
<<: *dev-common

api:
<<: *dev-common
command: ["dev", "--host", "0.0.0.0", "./src/aross_stations_db/api"]
# NOTE: In place of the above command, which uses the image's default
# `fastapi` entrypoint, you can run the container with no server (using
# "sleep" instead):
#
# entrypoint: "sleep"
# command: ["9999999"]
#
# ... then, you can connect to the container for debugging, e.g. by
# placing a breakpoint in code then interactively running the server
# process:
# docker compose exec api fastapi dev --host 0.0.0.0 ./src/aross_stations_db/api

cli:
<<: *dev-common

jupyterlab:
<<: *dev-common
34 changes: 21 additions & 13 deletions compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,12 @@ x-image: &image "nsidc/aross-stations-db"

services:
ui:
container_name: "aross-stations-jupyterlab"
container_name: "aross-stations-ui"
depends_on: ["api"]
image: *image
<<: *common

entrypoint: "jupyter"
command: ["lab", "--allow-root", "--ip=0.0.0.0"]
image: "nsidc/aross-stations-ui:latest"
ports:
- "8888:8888"
environment:
JUPYTER_TOKEN: "${POSTGRES_PASSWORD}"
- "80:80"
profiles: ["ui"]


api:
Expand Down Expand Up @@ -71,7 +66,20 @@ services:
environment:
AROSS_DATA_BASEDIR: "/data"
AROSS_DB_CONNSTR: null
profiles:
# Prevents this "service" from running with `docker compose up`.
# Instead, it's intended to be used like `docker compose run cli --help`.
- "_"
# Prevents this "service" from running with `docker compose up`.
# Instead, it's intended to be used like `docker compose run cli --help`.
profiles: ["_"]


jupyterlab:
container_name: "aross-stations-jupyterlab"
depends_on: ["api"]
image: *image
<<: *common

entrypoint: "jupyter"
command: ["lab", "--allow-root", "--ip=0.0.0.0"]
ports:
- "8888:8888"
environment:
JUPYTER_TOKEN: "${POSTGRES_PASSWORD}"
Loading