Skip to content

Commit

Permalink
merge from master
Browse files Browse the repository at this point in the history
  • Loading branch information
craigrbarnes committed Jan 23, 2025
2 parents baf36c4 + 05a7153 commit bb752a5
Show file tree
Hide file tree
Showing 17 changed files with 1,437 additions and 899 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
DB_PASSWORD: metadata_pass
PGPASSWORD: metadata_pass
run: |
poetry run pytest --cov=src --cov=migrations/versions --cov-fail-under=94 --cov-report xml
poetry run pytest --cov=src --cov=migrations/versions --cov-fail-under=93 --cov-report xml
- name: Submit coverage report
if: github.ref == 'refs/heads/master'
env:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/integration_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,7 @@ jobs:
CI_TEST_ORCID_PASSWORD: ${{ secrets.CI_TEST_ORCID_PASSWORD }}
CI_TEST_RAS_USERID: ${{ secrets.CI_TEST_RAS_USERID }}
CI_TEST_RAS_PASSWORD: ${{ secrets.CI_TEST_RAS_PASSWORD }}
CI_TEST_RAS_2_USERID: ${{ secrets.CI_TEST_RAS_2_USERID }}
CI_TEST_RAS_2_PASSWORD: ${{ secrets.CI_TEST_RAS_2_PASSWORD }}
CI_SLACK_BOT_TOKEN: ${{ secrets.CI_SLACK_BOT_TOKEN }}
CI_SLACK_CHANNEL_ID: ${{ secrets.CI_SLACK_CHANNEL_ID }}
48 changes: 34 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,38 @@
FROM quay.io/cdis/python:python3.9-buster-2.0.0 as base
ARG AZLINUX_BASE_VERSION=master

FROM base as builder
RUN pip install --upgrade pip poetry
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential gcc make musl-dev libffi-dev libssl-dev git curl bash
# Base stage with python-build-base
FROM quay.io/cdis/python-nginx-al:${AZLINUX_BASE_VERSION} AS base

COPY . /src/
WORKDIR /src
RUN python -m venv /env && . /env/bin/activate && poetry install --no-interaction --no-dev
ENV appname=mds

COPY --chown=gen3:gen3 /src/${appname} /${appname}

WORKDIR /${appname}

# Builder stage
FROM base AS builder

USER gen3

COPY poetry.lock pyproject.toml /${appname}/

# RUN python3 -m venv /env && . /env/bin/activate &&
RUN poetry install -vv --no-interaction --without dev

COPY --chown=gen3:gen3 . /${appname}
COPY --chown=gen3:gen3 ./deployment/wsgi/wsgi.py /${appname}/wsgi.py

RUN poetry install -vv --no-interaction --without dev

ENV PATH="$(poetry env info --path)/bin:$PATH"

# Final stage
FROM base
COPY --from=builder /env /env
COPY --from=builder /src /src
ENV PATH="/env/bin/:${PATH}"
WORKDIR /src
CMD ["/env/bin/gunicorn", "mds.asgi:app", "-b", "0.0.0.0:80", "-k", "uvicorn.workers.UvicornWorker", "-c", "gunicorn.conf.py"]

COPY --from=builder /${appname} /${appname}

# Switch to non-root user 'gen3' for the serving process

USER gen3

CMD ["/bin/bash", "-c", "/${appname}/dockerrun.bash"]
7 changes: 7 additions & 0 deletions gunicorn.conf.py → deployment/wsgi/gunicorn.conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,10 @@ def __init__(self, cfg):


logger_class = CDISLogger
wsgi_app = "deployment.wsgi.wsgi:app"
bind = "0.0.0.0:8000"
workers = 1
user = "gen3"
group = "gen3"
timeout = 300
worker_class = "uvicorn.workers.UvicornWorker"
3 changes: 3 additions & 0 deletions deployment/wsgi/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from mds.main import get_app

app = get_app()
4 changes: 4 additions & 0 deletions dockerrun.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

nginx
poetry run gunicorn -c "/mds/deployment/wsgi/gunicorn.conf.py" mds.asgi:app
9 changes: 9 additions & 0 deletions docs/dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,12 @@ helm upgrade --install gen3/metadata
You can also store your images in a local registry. Kind and Minikube are popular for their local registries:
- https://kind.sigs.k8s.io/docs/user/local-registry/
- https://minikube.sigs.k8s.io/docs/handbook/registry/#enabling-insecure-registries


## Additional Notes

When using the Metadata Service as a backend to retrieve results for the Discovery Page, query response times can increase if the database contains a large number of records. To improve performance in such cases, one recommended approach is to manually add an index on the `data->>_guid_type` field in the PostgreSQL database.

```SQL
create index metadata_guid_type on public.metadata((data->>'_guid_type'));
```
18 changes: 12 additions & 6 deletions docs/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ components:
\ using in place of whatever GUID\n specified"
properties:
aliases:
items: {}
items:
type: string
title: Aliases
type: array
title: AliasObjInput
Expand Down Expand Up @@ -68,7 +69,9 @@ components:
properties:
loc:
items:
type: string
anyOf:
- type: string
- type: integer
title: Location
type: array
msg:
Expand All @@ -92,8 +95,8 @@ components:
type: http
info:
title: Framework Services Object Management Service
version: 4.0.1
openapi: 3.0.2
version: 4.0.2
openapi: 3.1.0
paths:
/_status:
get:
Expand Down Expand Up @@ -283,10 +286,12 @@ paths:
\ }\n },\n ...\n ]"
operationId: get_aggregate_metadata_for_commons_aggregate_metadata__name__get
parameters:
- in: path
- description: Return the results without grouping items by commons.
in: path
name: name
required: true
schema:
description: Return the results without grouping items by commons.
title: Name
type: string
responses:
Expand Down Expand Up @@ -434,7 +439,8 @@ paths:
content:
application/json:
schema:
items: {}
items:
type: object
title: Data List
type: array
required: true
Expand Down
Loading

0 comments on commit bb752a5

Please sign in to comment.