From f2178849654b24971d98e500b12ebd386492c76e Mon Sep 17 00:00:00 2001 From: David Graham Date: Sun, 25 Aug 2024 11:26:53 -0400 Subject: [PATCH] remove references to localhost outside configs --- compose.yaml | 6 +++--- docs/guide/src/design/server.md | 18 +++++++++++++----- .../guide/src/development/local-development.md | 2 +- docs/guide/src/operations/configuration.md | 4 ++-- server/haztrak/settings/dev.py | 2 +- 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/compose.yaml b/compose.yaml index fbd906de1..c493c60aa 100644 --- a/compose.yaml +++ b/compose.yaml @@ -11,7 +11,7 @@ services: - ./server:/app environment: DJANGO_SETTINGS_MODULE: "haztrak.settings.dev" - HT_HOST: "localhost" + HT_HOST: ${HT_HOST} HT_SECRET_KEY: ${HT_SECRET_KEY} HT_DEBUG: ${HT_DEBUG} HT_LOG_LEVEL: ${HT_LOG_LEVEL} @@ -29,7 +29,7 @@ services: HT_DB_PORT: ${HT_DB_PORT} labels: - "traefik.enable=true" - - "traefik.http.routers.trak.rule=Host(`localhost`)" + - "traefik.http.routers.trak.rule=Host(`${HT_HOST}`)" - "traefik.http.routers.trak.rule=PathPrefix(`/api`) || PathPrefix(`/admin`) || PathPrefix(`/static`)" - "traefik.http.routers.trak.entrypoints=web" command: | @@ -123,7 +123,7 @@ services: VITE_GITHUB_URL: ${VITE_GITHUB_URL} labels: - "traefik.enable=true" - - "traefik.http.routers.client.rule=Host(`localhost`)" + - "traefik.http.routers.client.rule=Host(`${HT_HOST}`)" - "traefik.http.routers.client.entrypoints=web" command: sh -c "cd /app; npm install; npm start" diff --git a/docs/guide/src/design/server.md b/docs/guide/src/design/server.md index b99ef0d84..2e870a64a 100644 --- a/docs/guide/src/design/server.md +++ b/docs/guide/src/design/server.md @@ -1,10 +1,13 @@ ## Server and Rest API -The REST API is the primary way users read and change data in the Haztrak system. It is implemented using Python, the [Django Framework](https://www.djangoproject.com/), and [Django Rest Framework](https://www.django-rest-framework.org/). +The REST API is the primary way users read and change data in the Haztrak system. It is implemented using Python, +the [Django Framework](https://www.djangoproject.com/), +and [Django Rest Framework](https://www.django-rest-framework.org/). The choice to use Python stemmed from a desire to use a language that the team was already familiar with, something that is easy to learn (regardless of whether Python is your primary language, it's easy to read). -The choice to use Django was made because it is a mature, well-documented, and widely used framework that provides a lot of functionality out of the box. +The choice to use Django was made because it is a mature, well-documented, and widely used framework that provides a lot +of functionality out of the box. Many Django developer have turned to what they call the 'service layer', which usually encapsulated the use cases business logic. It's a contentious topic whether the policy/business logic should be @@ -25,8 +28,10 @@ The Admin site provides a quick, model-centric interface where trusted users can manage content. It's not intended to provide a process centric interface, admin user's should not be, for example, signing manifests through the admin site. -The admin interface is an out-of-the-box feature of the [Django framework](https://docs.djangoproject.com/en/4.1/ref/contrib/admin/). -It can be found by appending `/admin` to the URL of the host and port of HTTP server, for example `http://localhost:8000/admin` +The admin interface is an out-of-the-box feature of +the [Django framework](https://docs.djangoproject.com/en/4.1/ref/contrib/admin/). +It can be found by appending `/admin` to the URL of the host and port of HTTP server, for example +`http://localhost/admin` ## In-memory Database @@ -35,6 +40,9 @@ The in-memory data store serves a couple purposes, - As a message broker for Haztrak's [task queue](./task-queue.md) - A cache for the [http server](./http-server.md) -As a cache, the in-memory data store is utilized to increase performance by allowing Haztrak to cut down on latency for recently used resources including recent database queries, computed values, and external service calls. As a message broker, the data store provides a reliable way for the back end service to communicate which each other (e.g., launch background tasks). +As a cache, the in-memory data store is utilized to increase performance by allowing Haztrak to cut down on latency for +recently used resources including recent database queries, computed values, and external service calls. As a message +broker, the data store provides a reliable way for the back end service to communicate which each other (e.g., launch +background tasks). The Haztrak project currently uses [Redis](https://redis.io/) as both the message broker and in-memory data store. diff --git a/docs/guide/src/development/local-development.md b/docs/guide/src/development/local-development.md index 7bafc0f1b..621d5adf9 100644 --- a/docs/guide/src/development/local-development.md +++ b/docs/guide/src/development/local-development.md @@ -42,7 +42,7 @@ that we've specified in the [docker-compose.yaml](https://github.com/USEPA/haztrak/blob/main/docker-compose.yaml) file._ After all containers are successfully running (you can inspect with `docker ps`), -visit [localhost:8080](http://localhost:8080) +visit [localhost:8080](http://localhost) ## Fixtures (logging in) diff --git a/docs/guide/src/operations/configuration.md b/docs/guide/src/operations/configuration.md index 875300a83..77f93bffa 100644 --- a/docs/guide/src/operations/configuration.md +++ b/docs/guide/src/operations/configuration.md @@ -63,7 +63,7 @@ The follow variables are required, haztrak will exit if not present. the [e-Manifest API Client Library](https://github.com/USEPA/e-manifest/tree/master/emanifest-py) - `HT_CORS_DOMAIN` - Value for cross-origin resource sharing, the domain that the React app is deployed - - Example for local development: should be something like `http://localhost:3000` + - Example for local development: should be something like `http://localhost` - `HT_CACHE_URL` - URL that points to the cache, in this instance Redis - Example for local development: should be something like `redis://localhost:6379` @@ -137,7 +137,7 @@ will default to `HT_LOG_LEVEL`s default. - `VITE_HT_API_URL` - Value: host/domain name of the haztrak back end - - Default: `http://localhost:8000` + - Default: `http://localhost` - `VITE_HT_ENV` - Default: `PROD` - Options: `PROD`, `DEV`, `TEST` diff --git a/server/haztrak/settings/dev.py b/server/haztrak/settings/dev.py index 9facc1fc3..ebdc23df6 100644 --- a/server/haztrak/settings/dev.py +++ b/server/haztrak/settings/dev.py @@ -5,7 +5,7 @@ # General SECRET_KEY = "django-insecure-%btjqoun@6ps$e@8bw$48s+!x1e4aiz&5p2nrf6cmiw4)jsx5d" DEBUG = True -CORS_ORIGIN_WHITELIST = [os.getenv("HT_CORS_DOMAIN", "http://localhost:3000")] +CORS_ORIGIN_WHITELIST = [os.getenv("HT_CORS_DOMAIN", "http://localhost")] REST_FRAMEWORK["DEFAULT_RENDERER_CLASSES"] = [ # noqa: F405 "rest_framework.renderers.JSONRenderer",