Skip to content

Commit

Permalink
Merge pull request #71 from Clinical-Genomics/container
Browse files Browse the repository at this point in the history
Docker file (minor)

 ### Added
- Docker file
- commit template
- dockerhub push to stage - on pulrequest
- dockerhub push to prod - on new release
- bump version - on merge to master 
- updating test coverage - on merge to master
- dockerhub push to stage - on merge to master
  • Loading branch information
mayabrandi authored Jul 20, 2021
2 parents eb1ea9f + 97fc135 commit fe4486c
Show file tree
Hide file tree
Showing 7 changed files with 216 additions and 20 deletions.
9 changes: 9 additions & 0 deletions .github/commit_template.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

### Added
-

### Changed
-

### Fixed
-
19 changes: 0 additions & 19 deletions .github/workflows/bumpversion.yml

This file was deleted.

35 changes: 35 additions & 0 deletions .github/workflows/dockerhub_push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

name: Push cg_lims image to Docker Hub on push event

on: [pull_request]

jobs:
docker-image-push:
runs-on: ubuntu-latest
steps:
- name: Check out git repository
uses: actions/checkout@v2

- name: Extract branch name and remove illegal chars
id: get_branch_name
shell: bash
run: echo "##[set-output name=branch;]$(echo "$(tr "/" "-" <<<${GITHUB_REF#refs/heads/})")"

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1

- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: ./
file: ./Dockerfile
push: true
tags: "clinicalgenomics/cg_lims-stage:${{steps.get_branch_name.outputs.branch}}, clinicalgenomics/cg_lims-stage:latest"
35 changes: 35 additions & 0 deletions .github/workflows/dockerhub_push_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

name: Push to Docker Hub on new release event

on:
release:
types:
- created

jobs:
docker-image-release_push:
# Push to Docker Hub when a new release is created
runs-on: ubuntu-latest
steps:

- name: Check Out Repo
uses: actions/checkout@v2

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1

- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: ./
file: ./Dockerfile
push: true
tags: "clinicalgenomics/cg_lims:${{github.event.release.tag_name}}, clinicalgenomics/cg_lims:latest"
92 changes: 92 additions & 0 deletions .github/workflows/merge_master_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: 'Merge-master-CI'
on:
push:
branches:
- 'master'
- 'main'

jobs:
bump-version:
runs-on: ubuntu-latest
name: Bump version and push tags to master
steps:
- name: Bump version
uses: Clinical-Genomics/bump2version-ci@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_ACTOR: ${{ github.actor }}
with:
release_pat: ${{ secrets.BUMPVERSION_TOKEN }}

docker-image-push:
runs-on: ubuntu-latest
name: Push staging docker image to dockerhub
steps:
- name: Check out git repository
uses: actions/checkout@v2

- name: Extract branch name and remove illegal chars
id: get_branch_name
shell: bash
run: echo "##[set-output name=branch;]$(echo "$(tr "/" "-" <<<${GITHUB_REF#refs/heads/})")"

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1

- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: ./
file: ./Dockerfile
push: true
tags: "clinicalgenomics/cg_lims-stage:${{steps.get_branch_name.outputs.branch}}, clinicalgenomics/cg_lims-stage:latest"

tests-coverage:
runs-on: ubuntu-latest
name: Test and coveralls
steps:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Check out limsmock
uses: actions/checkout@v2
with:
repository: "Clinical-Genomics/limsmock"

- name: Install limsmock dependencies
run: |
python -m pip install --upgrade pip==21.1.2
pip install -r requirements.txt -r requirements-dev.txt .
- name: Check out cg_lims
uses: actions/checkout@v2
with:
repository: "Clinical-Genomics/cg_lims"

- name: Install cg_lims dependencies
run: |
pip install -r requirements.txt -r requirements-dev.txt .
- name: Install coveralls dependencies
run: |
pip install pytest-cov coveralls
- name: Test with pytest & Coveralls
run: |
pytest --cov=cg_lims/
coveralls
env:
GITHUB: 1
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
42 changes: 42 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
FROM python:3.8-slim

LABEL base_image="python:3.8-slim"
LABEL about.home="https://github.com/Clinical-Genomics/cg_lims"
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 BASEURI="https://clinical-lims-stage.scilifelab.se"
ENV HOST="clinical-lims-stage.scilifelab.se"
ENV USERNAME="apiuser"
ENV PASSWORD="??"
ENV CG_URL="https://clinical-api.scilifelab.se/api/v1"
ENV CG_LIMS_HOST="localhost"
ENV CG_LIMS_PORT=8000

EXPOSE 8000

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

# Install app requirements
RUN pip install -r requirements.txt

# Install app
RUN pip install -e .

CMD gunicorn \
--workers=$GUNICORN_WORKERS \
--bind=$GUNICORN_BIND \
--threads=$GUNICORN_THREADS \
--timeout=$GUNICORN_TIMEOUT \
--proxy-protocol \
--forwarded-allow-ips="10.0.2.100,127.0.0.1" \
--log-syslog \
--access-logfile - \
--log-level="debug" \
--worker-class=uvicorn.workers.UvicornWorker \
cg_lims.app.api.api_v1.api:app
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ click
PyYAML
pydantic
fastapi
pandas
pandas
gunicorn
uvicorn

0 comments on commit fe4486c

Please sign in to comment.