Skip to content

Commit

Permalink
remove references to localhost outside configs
Browse files Browse the repository at this point in the history
  • Loading branch information
dpgraham4401 committed Aug 25, 2024
1 parent 19709bd commit f217884
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
6 changes: 3 additions & 3 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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: |
Expand Down Expand Up @@ -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"

Expand Down
18 changes: 13 additions & 5 deletions docs/guide/src/design/server.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

Expand All @@ -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.
2 changes: 1 addition & 1 deletion docs/guide/src/development/local-development.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions docs/guide/src/operations/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -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`
Expand Down
2 changes: 1 addition & 1 deletion server/haztrak/settings/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit f217884

Please sign in to comment.