Skip to content

Commit

Permalink
feat: add nginx proxy in own docker-compose file
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gadomski authored and moradology committed Feb 27, 2023
1 parent 8844929 commit 72cab05
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 14 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ docker-run-sqlalchemy: image
docker-run-pgstac: image
$(run_pgstac)

.PHONY: docker-run-nginx-proxy
docker-run-nginx-proxy:
docker-compose -f docker-compose.yml -f docker-compose.nginx.yml up

.PHONY: docker-shell-sqlalchemy
docker-shell-sqlalchemy:
$(run_sqlalchemy) /bin/bash
Expand Down
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<!-- markdownlint-disable MD033 MD041 -->

<p align="center">
<img src="https://github.com/radiantearth/stac-site/raw/master/images/logo/stac-030-long.png" width=400>
<p align="center">FastAPI implemention of the STAC API spec.</p>
Expand Down Expand Up @@ -101,7 +103,23 @@ The application will be started on <http://localhost:8080>.
By default, the apps are run with uvicorn hot-reloading enabled. This can be turned off by changing the value
of the `RELOAD` env var in docker-compose.yml to `false`.

#### Note to Docker for Windows users
### nginx proxy

This repo includes an example nginx proxy service.
To start:

```shell
make docker-run-nginx-proxy
```

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/>.
If you need to customize the proxy port, use the `STAC_FASTAPI_NGINX_PORT` environment variable:

```shell
STAC_FASTAPI_NGINX_PORT=7822 make docker-run-nginx-proxy
```

### Note to Docker for Windows users

You'll need to enable experimental features on Docker for Windows in order to run the docker-compose,
due to the "--platform" flag that is required to allow the project to run on some Apple architectures.
Expand Down
18 changes: 18 additions & 0 deletions docker-compose.nginx.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: '3'
services:
nginx:
image: nginx
ports:
- ${STAC_FASTAPI_NGINX_PORT:-80}:80
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
depends_on:
- app-pgstac
- app-sqlalchemy
command: [ "nginx-debug", "-g", "daemon off;" ]
app-pgstac:
environment:
- UVICORN_ROOT_PATH=/api/v1/pgstac
app-sqlalchemy:
environment:
- UVICORN_ROOT_PATH=/api/v1/sqlalchemy
13 changes: 0 additions & 13 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
version: '3'
services:
nginx:
image: nginx
ports:
- ${STAC_FASTAPI_NGINX_PORT:-80}:80
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
depends_on:
- app-pgstac
- app-sqlalchemy
command: ["nginx-debug", "-g", "daemon off;"]

app-sqlalchemy:
container_name: stac-fastapi-sqlalchemy
image: stac-utils/stac-fastapi
Expand All @@ -30,7 +19,6 @@ services:
- POSTGRES_HOST_WRITER=database
- POSTGRES_PORT=5432
- WEB_CONCURRENCY=10
- UVICORN_ROOT_PATH=/api/v1/sqlalchemy
ports:
- "8081:8081"
volumes:
Expand Down Expand Up @@ -62,7 +50,6 @@ services:
- DB_MIN_CONN_SIZE=1
- DB_MAX_CONN_SIZE=1
- USE_API_HYDRATE=${USE_API_HYDRATE:-false}
- UVICORN_ROOT_PATH=/api/v1/pgstac
ports:
- "8082:8082"
volumes:
Expand Down

0 comments on commit 72cab05

Please sign in to comment.