Skip to content

Commit 1eb7bea

Browse files
committed
feat: add nginx proxy in own docker-compose file
Includes a Makefile rule to run it, and some documentation in README.md. Also adds a markdownlint silencer and one or two touchups to the whitespace.
1 parent 23271ee commit 1eb7bea

File tree

4 files changed

+43
-14
lines changed

4 files changed

+43
-14
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ docker-run-sqlalchemy: image
3030
docker-run-pgstac: image
3131
$(run_pgstac)
3232

33+
.PHONY: docker-run-nginx-proxy
34+
docker-run-nginx-proxy:
35+
docker-compose -f docker-compose.yml -f docker-compose.nginx.yml up
36+
3337
.PHONY: docker-shell-sqlalchemy
3438
docker-shell-sqlalchemy:
3539
$(run_sqlalchemy) /bin/bash

README.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
<!-- markdownlint-disable MD033 MD041 -->
2+
13
<p align="center">
24
<img src="https://github.com/radiantearth/stac-site/raw/master/images/logo/stac-030-long.png" width=400>
35
<p align="center">FastAPI implemention of the STAC API spec.</p>
@@ -30,6 +32,7 @@ packages:
3032
- **stac_fastapi.types**: Shared types and abstract base classes used by the library.
3133

3234
#### Backends
35+
3336
- **stac_fastapi.sqlalchemy**: Postgres backend implementation with sqlalchemy.
3437
- **stac_fastapi.pgstac**: Postgres backend implementation with [PGStac](https://github.com/stac-utils/pgstac).
3538

@@ -64,6 +67,7 @@ pip install -e stac_fastapi/pgstac
6467
## Local Development
6568

6669
Use docker-compose via make to start the application, migrate the database, and ingest some example data:
70+
6771
```bash
6872
make image
6973
make docker-run-all
@@ -84,7 +88,23 @@ The application will be started on <http://localhost:8080>.
8488
By default, the apps are run with uvicorn hot-reloading enabled. This can be turned off by changing the value
8589
of the `RELOAD` env var in docker-compose.yml to `false`.
8690

87-
#### Note to Docker for Windows users
91+
### nginx proxy
92+
93+
This repo includes an example nginx proxy service.
94+
To start:
95+
96+
```shell
97+
make docker-run-nginx-proxy
98+
```
99+
100+
The proxy will be started on <http://localhost>, with the pgstac app available at <http://localhost/api/v1/pgstac/> and the sqlalchemy app at <http://localhost/api/v1/sqlalchemy/>.
101+
If you need to customize the proxy port, use the `STAC_FASTAPI_NGINX_PORT` environment variable:
102+
103+
```shell
104+
STAC_FASTAPI_NGINX_PORT=7822 make docker-run-nginx-proxy
105+
```
106+
107+
### Note to Docker for Windows users
88108

89109
You'll need to enable experimental features on Docker for Windows in order to run the docker-compose,
90110
due to the "--platform" flag that is required to allow the project to run on some Apple architectures.

docker-compose.nginx.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version: '3'
2+
services:
3+
nginx:
4+
image: nginx
5+
ports:
6+
- ${STAC_FASTAPI_NGINX_PORT:-80}:80
7+
volumes:
8+
- ./nginx.conf:/etc/nginx/nginx.conf
9+
depends_on:
10+
- app-pgstac
11+
- app-sqlalchemy
12+
command: [ "nginx-debug", "-g", "daemon off;" ]
13+
app-pgstac:
14+
environment:
15+
- UVICORN_ROOT_PATH=/api/v1/pgstac
16+
app-sqlalchemy:
17+
environment:
18+
- UVICORN_ROOT_PATH=/api/v1/sqlalchemy

docker-compose.yml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
11
version: '3'
22
services:
3-
nginx:
4-
image: nginx
5-
ports:
6-
- ${STAC_FASTAPI_NGINX_PORT:-80}:80
7-
volumes:
8-
- ./nginx.conf:/etc/nginx/nginx.conf
9-
depends_on:
10-
- app-pgstac
11-
- app-sqlalchemy
12-
command: ["nginx-debug", "-g", "daemon off;"]
13-
143
app-sqlalchemy:
154
container_name: stac-fastapi-sqlalchemy
165
image: stac-utils/stac-fastapi
@@ -30,7 +19,6 @@ services:
3019
- POSTGRES_HOST_WRITER=database
3120
- POSTGRES_PORT=5432
3221
- WEB_CONCURRENCY=10
33-
- UVICORN_ROOT_PATH=/api/v1/sqlalchemy
3422
ports:
3523
- "8081:8081"
3624
volumes:
@@ -62,7 +50,6 @@ services:
6250
- DB_MIN_CONN_SIZE=1
6351
- DB_MAX_CONN_SIZE=1
6452
- USE_API_HYDRATE=${USE_API_HYDRATE:-false}
65-
- UVICORN_ROOT_PATH=/api/v1/pgstac
6653
ports:
6754
- "8082:8082"
6855
volumes:

0 commit comments

Comments
 (0)