Skip to content
This repository has been archived by the owner on May 31, 2024. It is now read-only.

Commit

Permalink
Add Dockerfile for easier deployment of registry (#50)
Browse files Browse the repository at this point in the history
* Add Dockerfile for easier deployment of registry

* Add README note

* Add docker build in CI

* Fix old typo in README

* Hit endpoints in same workflow step

* Add healthcheck to docker container
  • Loading branch information
ml-evs authored Nov 14, 2023
1 parent 8b4e0fe commit 9dca085
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 1 deletion.
22 changes: 22 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,25 @@ jobs:
- name: Run database ingestion tasks
run: |
invoke validate-entries
build:
runs-on: ubuntu-latest
steps:
- name: Check Docker build
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: true
- name: Build image
run: |
docker build . -t marda-registry
- name: Launch image
run: |
docker run -d --env PORT=8080 -p 8080:8080 marda-registry
- name: Hit registry endpoints
run: |
sleep 5
curl http://localhost:8080/filetypes | jq
curl http://localhost:8080/extractors| jq
curl http://localhost:8080/redoc
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from python:3.11-slim-buster

env PORT=8000
workdir /app

# Copy local version of the registry and install reqs
copy requirements.txt /app
run pip install -r requirements.txt

copy schemas /app/schemas
copy marda_registry /app/marda_registry
copy tasks.py /app

# Regenerate models from the current schemas
run invoke regenerate-models

# Validate all entries against the schema
run invoke validate-entries

cmd uvicorn marda_registry.app:app --host 0.0.0.0 --port ${PORT}

healthcheck --interval=5m --timeout=3s --start-period=10s \
cmd curl --fail http://localhost:${PORT} || exit 1
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,24 @@ invoke regenerate-models
From the repository root directory, launch the server with uvicorn:

```
uvicorn src.marda_registry.app:app
uvicorn marda_registry.app:app
```

then navigate to http://localhost:5000 to test.

## Deployment

The registry app can be easily deployed via the given [Dockerfile](./Dockerfile).
After cloning the repository (with submodules, following the instructions above), the image can be built for a given schema version by running

```shell
docker build . -t marda-registry
```

and then launched with

```shell
docker run -p 8080 --env PORT=8080 marda-registry
```

or equivalent command.

0 comments on commit 9dca085

Please sign in to comment.