Skip to content

Commit 2c6f249

Browse files
committed
Added deploy instructions
1 parent ebc81eb commit 2c6f249

2 files changed

Lines changed: 72 additions & 0 deletions

File tree

Dockerfile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# BUILD stage
2+
FROM python:3.12-slim AS build
3+
ARG CACTUS_CLIENT_NOTIFICATIONS_VERSION=v0.0.6
4+
5+
RUN apt-get update; apt-get install -y git openssh-client
6+
7+
# Setup the git config to use https
8+
RUN git config --global url."https://git@github.com/".insteadOf "ssh://git@github.com/"
9+
10+
# Install app / dependencies
11+
RUN pip install --no-cache-dir "cactus-client-notifications[server] @ git+ssh://git@github.com/bsgip/cactus-client-notifications.git@${CACTUS_CLIENT_NOTIFICATIONS_VERSION}" gunicorn
12+
13+
# RUN stage
14+
FROM python:3.12-slim
15+
16+
17+
WORKDIR /app
18+
19+
# Copy env
20+
COPY --from=build --chown=appuser:appuser /usr/local/lib/ /usr/local/lib/
21+
COPY --from=build --chown=appuser:appuser /usr/local/bin/ /usr/local/bin/
22+
23+
# conf
24+
ENV PYTHONDONTWRITEBYTECODE=1
25+
ENV PYTHONUNBUFFERED=1
26+
ENV APP_HOST='0.0.0.0'
27+
ENV APP_PORT='8080'
28+
29+
# run app
30+
CMD ["sh", "-c", "exec gunicorn cactus_client_notifications.server.main:app --bind ${APP_HOST}:${APP_PORT} --worker-class aiohttp.GunicornWebWorker"]
31+

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
This is a mini web server for listening for 2030.5 subscription notifications on behalf of [cactus-client](https://github.com/bsgip/cactus-client). It's designed to be hosted at a publicly available IP and will provide a running test instance with unique callback URIs that can be utilised for the duration of a test.
44

5+
## PKI
6+
7+
This app is expected to be run downstream of TLS termination (eg behind an nginx reverse proxy).
8+
9+
Any mutual TLS / other considerations are expected to be managed at the point of TLS termination.
10+
11+
512
## Development
613

714
`pip install cactus_client_notifications` will install ONLY the schema dependencies (the default)
@@ -10,6 +17,40 @@ This is a mini web server for listening for 2030.5 subscription notifications on
1017

1118
`pip install cactus_client_notifications[server,dev,test]` will install ALL dependencies for development / tests
1219

20+
## Configuration
21+
22+
All configuration is managed via a series of environment variables. It's likely `SERVER_URL` and `MOUNT_POINT` are the only values you'll need to set for deployment.
23+
24+
| Environment Variable | Default Value | Description |
25+
| -------------------- | ------------- | ----------- |
26+
| `APP_PORT` | `8080` | What port the application will be listening on (reverse proxy target port) |
27+
| `SERVER_URL` | `http://localhost:8080` | The public URI that all webhooks will be hosted under (This will need to be resolvable by BOTH the cactus CLI tool AND the utility server for submitting notifications) |
28+
| `MOUNT_POINT` | `/` | If this service is hosted a path prefix (eg `/api/v12/`) set that value here. |
29+
| `MAX_IDLE_DURATION_SECONDS` | `3600` | Any notification endpoint that hasn't been interacted with for this many seconds will be deleted |
30+
| `MAX_DURATION_SECONDS` | `262800` (73 hours) | Any notification endpoint that is at least this old will be deleted |
31+
| `MAX_ACTIVE_ENDPOINTS` | `1024` | The maximum number of endpoints that can be in existance at one time. |
32+
| `MAX_ENDPOINT_NOTIFICATIONS` | `100` | The maximum number of (uncollected) notifications that an endpoint can hold |
33+
| `CLEANUP_FREQUENCY_SECONDS` | `120` | How frequently the server checks for expired endpoints |
34+
35+
1336
## Building
1437

38+
To build a Docker containerised version of the app - use the included Dockerfile:
39+
40+
`docker build --build-arg CACTUS_CLIENT_NOTIFICATIONS_VERSION=v0.0.6 .`
41+
42+
If you want to run the built image (and host it at `my.server/api`):
43+
44+
`docker run -e SERVER_URL=https://my.server:8080 -e MOUNT_POINT=/api -p 8080:8080 cactus-client-notifications`
45+
46+
1547
## API
48+
49+
| Method/Endpoint | Description | JSON Models |
50+
| --------------- | ----------- | ----------- |
51+
| `GET /manage` | Plaintext app status (eg: describing active endpoints and uncollected notifications) | Request: `None` Response: `None - plaintext` |
52+
| `POST /manage/endpoint` | Attempts to create a notification endpoint. response will contain the unique notification endpoint ID and fully qualified URL | Request: `None` Response: `cactus_client_notifications.schema.CreateEndpointResponse` |
53+
| `GET /manage/endpoint/{endpoint_id}` | Collects all Notifications for the nominated `endpoint_id`. Once a notification has been collected it will be cleared. | Request: `None` Response: `cactus_client_notifications.schema.CollectEndpointResponse` |
54+
| `PUT /manage/endpoint/{endpoint_id}` | Updates the configuration for `endpoint_id` (eg enabling / disabling it).| Request: `cactus_client_notifications.schema.ConfigureEndpointRequest` Response: `None` |
55+
| `DELETE /manage/endpoint/{endpoint_id}` | Requests the deletion of the endpoint with `endpoint_id` | Request: `None` Response: `None` |
56+
| `* /webhook/{endpoint_id}` | The actual notification webhook that the utility server will be sending requests to. | Request: `Any` Response: `None` |

0 commit comments

Comments
 (0)