From 72cab052b1dfaa6bd0258a47bd9dcf42778533d3 Mon Sep 17 00:00:00 2001 From: Pete Gadomski Date: Wed, 18 Jan 2023 11:55:34 -0700 Subject: [PATCH] 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. --- Makefile | 4 ++++ README.md | 20 +++++++++++++++++++- docker-compose.nginx.yml | 18 ++++++++++++++++++ docker-compose.yml | 13 ------------- 4 files changed, 41 insertions(+), 14 deletions(-) create mode 100644 docker-compose.nginx.yml diff --git a/Makefile b/Makefile index 36187c2e8..fbeb7d85f 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/README.md b/README.md index d26c12a32..85b03d930 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ + +

FastAPI implemention of the STAC API spec.

@@ -101,7 +103,23 @@ The application will be started on . 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 , with the pgstac app available at and the sqlalchemy app at . +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. diff --git a/docker-compose.nginx.yml b/docker-compose.nginx.yml new file mode 100644 index 000000000..b70bffe50 --- /dev/null +++ b/docker-compose.nginx.yml @@ -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 diff --git a/docker-compose.yml b/docker-compose.yml index be6beb37a..506a4a37b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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 @@ -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: @@ -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: