Skip to content

Commit

Permalink
merge develop into main
Browse files Browse the repository at this point in the history
  • Loading branch information
jusa3 committed Aug 3, 2023
2 parents 5b23106 + 070f96f commit 481b057
Show file tree
Hide file tree
Showing 35 changed files with 15,696 additions and 876 deletions.
128 changes: 128 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: Continuous Integration

on:
pull_request: { branches: [ "main","develop" ] }
push:
branches: [ "main","develop" ]
tags: [ "*" ]
env:
KUBECONFIG: .kube/config
KUBECONFIG_FILE: ${{ secrets.KUBECONFIG }}
GIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
NPM_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
build:
name: "Build Image"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- id: generate-image-tag
name: Generate Image Tag
env:
ref_name: "${{ github.ref_name }}"
head_ref: "${{ github.head_ref }}"
run: |
head_ref="${head_ref/\//-}"
ref_name="${head_ref:-${ref_name/main/latest}}"
echo "::set-output name=imageTag::${ref_name#v}"
- name: Login to Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push Backend
uses: docker/build-push-action@v2
with:
context: ./backend
push: true
tags: |
ghcr.io/${{ github.repository }}/backend:${{ steps.generate-image-tag.outputs.imageTag }}
ghcr.io/${{ github.repository }}/backend:${{ github.event.pull_request.head.sha || github.sha }}
build-args: |
COMMIT_SHA=${{ github.sha }}
- uses: actions/setup-node@v3
with:
node-version: '17.x'
registry-url: 'https://npm.pkg.github.com/'
- run: npm ci --legacy-peer-deps
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
working-directory: ./frontend
- run: npm run build
env:
CI: false
working-directory: ./frontend
- name: Build and Push Frontend
uses: docker/build-push-action@v2
with:
context: ./frontend
push: true
tags: |
ghcr.io/${{ github.repository }}/frontend:${{ steps.generate-image-tag.outputs.imageTag }}
ghcr.io/${{ github.repository }}/frontend:${{ github.event.pull_request.head.sha || github.sha }}
deploy_development:
needs: build
if: github.ref == 'refs/heads/develop'
runs-on: ubuntu-latest
steps:
- id: generate-image-tag
name: Generate Image Tag
env:
ref_name: "${{ github.ref_name }}"
head_ref: "${{ github.head_ref }}"
run: |
head_ref="${head_ref/\//-}"
ref_name="${head_ref:-${ref_name/main/latest}}"
echo "::set-output name=imageTag::${ref_name#v}"
- uses: actions/checkout@v2
- run: |
mkdir -p .kube
echo "${{ env.KUBECONFIG_FILE }}" > $KUBECONFIG
- uses: stefanprodan/kube-tools@v1
with:
helmv3: 3.12.0
command: |
kubectl get nodes
helmv3 repo add mda-deployment https://nfdi4health.github.io/mda-deployment/
helmv3 repo update
helmv3 upgrade mda-${{ steps.generate-image-tag.outputs.imageTag }} \
--install \
--set-json='images.backend="ghcr.io/${{ github.repository }}/backend:${{ github.event.pull_request.head.sha || github.sha }}"' \
--set-json='images.frontend="ghcr.io/${{ github.repository }}/frontend:${{ github.event.pull_request.head.sha || github.sha }}"' \
--set-json='images.prediction="gitlab.zbmed.de:5050/km/thesis/pierre-ba/backend:a7d3254ee488a236dade40ecedc646861aff9dbe"' \
--set-json='ingress.dns="${{ steps.generate-image-tag.outputs.imageTag }}.mda.qa.km.k8s.zbmed.de"' \
mda-deployment/metadata-annotation
deploy_main:
needs: build
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- id: generate-image-tag
name: Generate Image Tag
env:
ref_name: "${{ github.ref_name }}"
head_ref: "${{ github.head_ref }}"
run: |
head_ref="${head_ref/\//-}"
ref_name="${head_ref:-${ref_name/main/latest}}"
echo "::set-output name=imageTag::${ref_name#v}"
- uses: actions/checkout@v2
- run: |
mkdir -p .kube
echo "${{ env.KUBECONFIG_FILE }}" > $KUBECONFIG
- uses: stefanprodan/kube-tools@v1
with:
helmv3: 3.12.0
command: |
kubectl get nodes
helmv3 repo add mda-deployment https://nfdi4health.github.io/mda-deployment/
helmv3 repo update
helmv3 upgrade mda-${{ steps.generate-image-tag.outputs.imageTag }} \
--install \
--set-json='images.backend="ghcr.io/${{ github.repository }}/backend:${{ github.event.pull_request.head.sha || github.sha }}"' \
--set-json='images.frontend="ghcr.io/${{ github.repository }}/frontend:${{ github.event.pull_request.head.sha || github.sha }}"' \
--set-json='images.prediction="gitlab.zbmed.de:5050/km/thesis/pierre-ba/backend:a7d3254ee488a236dade40ecedc646861aff9dbe"' \
--set-json='ingress.dns="${{ steps.generate-image-tag.outputs.imageTag }}.mda.qa.km.k8s.zbmed.de"' \
mda-deployment/metadata-annotation
37 changes: 37 additions & 0 deletions .github/workflows/deployment_production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Deployment to production
concurrency: production
on:
workflow_dispatch:
inputs:
tags:
description: 'Do you really want to update the production instance'
required: false
type: boolean
image_sha:
description: 'Image SHA ID, Optional '
type: string
required: false
env:
KUBECONFIG: .kube/config
KUBECONFIG_FILE: ${{ secrets.KUBECONFIG_PROD }}
jobs:
deployment:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: |
mkdir -p .kube
echo "${{ env.KUBECONFIG_FILE }}" > $KUBECONFIG
- uses: stefanprodan/kube-tools@v1
with:
helmv3: 3.12.0
command: |
helmv3 repo add mda-deployment https://nfdi4health.github.io/mda-deployment/
helmv3 repo update
helmv3 upgrade mda-main \
--install \
--set-json='images.backend="ghcr.io/${{ github.repository }}/backend:${{ github.event.pull_request.head.sha || github.sha }}"' \
--set-json='images.frontend="ghcr.io/${{ github.repository }}/frontend:${{ github.event.pull_request.head.sha || github.sha }}"' \
--set-json='images.prediction="gitlab.zbmed.de:5050/km/thesis/pierre-ba/backend:a7d3254ee488a236dade40ecedc646861aff9dbe"' \
--set-json='ingress.dns="mda.main.prod.km.k8s.zbmed.de"' \
mda-deployment/metadata-annotation
101 changes: 0 additions & 101 deletions .gitlab-ci.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export DB_PASSWORD=postgres
export DB_HOST=localhost
export API_SEMLOOKP=https://semanticlookup.zbmed.de/ols/api/
export INSTRUMENTS=instruments
export API_PREDICT=http://172.29.0.3:5000
export API_PREDICT=http://172.29.0.5:5000
flask run
```

Expand Down
1 change: 1 addition & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ ENV FLASK_APP="restapi"
ARG COMMIT_SHA
ENV COMMIT_SHA=$COMMIT_SHA
RUN python -m pip install -r requirements.txt
RUN python -m pip install -U pydantic spacy
RUN python -m spacy download en_core_web_sm
CMD ["flask","run","--host=0.0.0.0"]
Loading

0 comments on commit 481b057

Please sign in to comment.