Skip to content

Commit

Permalink
Merge 7b32b5b into 3f626b7
Browse files Browse the repository at this point in the history
  • Loading branch information
Mropat committed May 3, 2021
2 parents 3f626b7 + 7b32b5b commit 5154f7c
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 9 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/build_container_pull.yml
@@ -0,0 +1,29 @@
---

name: Build container for stage testing
on: [push]

jobs:
docker-image-ci:
name: Docker Image CI
runs-on: ubuntu-latest
steps:

- name: Check out git repository
uses: actions/checkout@v1

- name: Get branch name
uses: nelonoel/branch-name@v1.0.1

- name: Modify illegal docker names
id: get_branch_name
shell: bash
run: echo "##[set-output name=branch;]$(echo "$(tr "/" "-" <<<$BRANCH_NAME)")"

- name: Build and publish to Docker Hub
uses: elgohr/Publish-Docker-Github-Action@master
with:
name: clinicalgenomics/niptool-stage
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
tags: "${{ steps.get_branch_name.outputs.branch }}"
24 changes: 24 additions & 0 deletions .github/workflows/build_container_release.yml
@@ -0,0 +1,24 @@
---

name: Build container from latest release
on:
release:
types:
- created

jobs:
docker-image-CI:
name: Docker Image CI
runs-on: ubuntu-latest
steps:

- name: Check out git repository
uses: actions/checkout@v2

- name: Build and publish to Docker Hub
uses: elgohr/Publish-Docker-Github-Action@master
with:
name: clinicalgenomics/niptool
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
tags: "${{ github.event.release.tag_name }}, latest"
22 changes: 18 additions & 4 deletions Dockerfile
Expand Up @@ -4,6 +4,17 @@ LABEL base_image="python:3.8-slim"
LABEL about.home="https://github.com/Clinical-Genomics/NIPTool"
LABEL about.tags="NIPT,statistics,Non Invasive Prenatal Test,python"


ENV GUNICORN_WORKERS=1
ENV GUNICORN_THREADS=1
ENV GUNICORN_BIND="0.0.0.0:8000"
ENV GUNICORN_TIMEOUT=400
ENV DB_URI="mongodb://localhost:27017/nipt-demo"
ENV DB_NAME="nipt-demo"
ENV SERVICE_SCOPE="external"

EXPOSE 8000

WORKDIR /home/worker/app
COPY . /home/worker/app

Expand All @@ -13,7 +24,10 @@ RUN pip install -r requirements.txt
# Install app
RUN pip install -e .

# Create and switch to a new non-root user
RUN useradd worker
RUN chown worker:worker -R /home/worker
USER worker
CMD gunicorn \
--workers=$GUNICORN_WORKERS \
--bind=$GUNICORN_BIND \
--threads=$GUNICORN_THREADS \
--timeout=$GUNICORN_TIMEOUT \
--worker-class=uvicorn.workers.UvicornWorker \
NIPTool.main:$SERVICE_SCOPE\_app
6 changes: 2 additions & 4 deletions NIPTool/commands/base.py
Expand Up @@ -26,7 +26,7 @@
@click.group()
@click.pass_context
def cli(context: click.Context):
""" Main entry point """
"""Main entry point"""
logging.basicConfig(level=logging.INFO)
context.obj = {}

Expand All @@ -41,9 +41,7 @@ def serve_command(reload: bool, api: str):
This command will serve the user interface (external) as default
"""
app = "NIPTool.main:external_app"
if api == "internal":
app = "NIPTool.main:internal_app"
app = f"NIPTool.main:{api}_app"
LOG.info("Running %s api on host:%s and port:%s", api, settings.host, settings.port)
uvicorn.run(app=app, host=settings.host, port=settings.port, reload=reload)

Expand Down
2 changes: 1 addition & 1 deletion NIPTool/config.py
Expand Up @@ -21,7 +21,7 @@ class Settings(BaseSettings):
port: int = 8000

class Config:
from_file = str(ENV_FILE)
env_file = str(ENV_FILE)


settings = Settings()
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Expand Up @@ -15,4 +15,5 @@ jinja2
passlib
fastapi
uvicorn
gunicorn
python-jose

0 comments on commit 5154f7c

Please sign in to comment.