Skip to content

Commit

Permalink
open source
Browse files Browse the repository at this point in the history
  • Loading branch information
juanArias8 committed Jun 16, 2023
0 parents commit 90abd8f
Show file tree
Hide file tree
Showing 891 changed files with 123,691 additions and 0 deletions.
165 changes: 165 additions & 0 deletions .github/workflows/cd-api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
name: CI Test and deploy backend
on:
workflow_dispatch:
workflow_call:
env:
MAX_LINE_LENGTH: 120
WORKING_DIR_BACKEND: morpheus-server
jobs:
ci-backend:
uses: ./.github/workflows/ci-api.yaml
with:
called: true
secrets: inherit
deploy-api-k8s:
runs-on: ubuntu-latest
needs:
- ci-backend
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Create kube config
run: |
aws eks --region ${{secrets.AWS_REGION}} update-kubeconfig --name ${{secrets.AWS_CLUSTER_NAME}}
- name: Deploy
run: |
# Running migrations by a pod
kubectl run morpheus-migrations --pod-running-timeout=15m --rm -i --image monadicalsas/morpheus:${{ github.run_id }} --overrides="{
\"spec\": {
\"imagePullSecrets\": [
{
\"name\": \"regcred\"
}
],
\"containers\": [
{
\"name\": \"morpheus\",
\"image\": \"monadicalsas/morpheus:${{ github.run_id }}\",
\"imagePullPolicy\": \"Always\",
\"command\": [
\"alembic\", \"upgrade\", \"head\"
],
\"env\": [
{
\"name\": \"POSTGRES_USER\",
\"valueFrom\": {
\"secretKeyRef\": {
\"name\": \"morpheus-secret\",
\"key\": \"POSTGRES_USER\",
\"optional\": false
}
}
},
{
\"name\": \"POSTGRES_DB\",
\"valueFrom\": {
\"secretKeyRef\": {
\"name\": \"morpheus-secret\",
\"key\": \"POSTGRES_DB\",
\"optional\": false
}
}
},
{
\"name\": \"POSTGRES_PASSWORD\",
\"valueFrom\": {
\"secretKeyRef\": {
\"name\": \"morpheus-secret\",
\"key\": \"POSTGRES_PASSWORD\",
\"optional\": false
}
}
},
{
\"name\": \"POSTGRES_HOST\",
\"valueFrom\": {
\"secretKeyRef\": {
\"name\": \"morpheus-secret\",
\"key\": \"POSTGRES_HOST\",
\"optional\": false
}
}
},
{
\"name\": \"FIREBASE_PROJECT_ID\",
\"valueFrom\": {
\"secretKeyRef\": {
\"name\": \"morpheus-secret\",
\"key\": \"FIREBASE_PROJECT_ID\",
\"optional\": true
}
}
},
{
\"name\": \"FIREBASE_PRIVATE_KEY\",
\"valueFrom\": {
\"secretKeyRef\": {
\"name\": \"morpheus-secret\",
\"key\": \"FIREBASE_PRIVATE_KEY\",
\"optional\": true
}
}
},
{
\"name\": \"FIREBASE_WEB_API_KEY\",
\"valueFrom\": {
\"secretKeyRef\": {
\"name\": \"morpheus-secret\",
\"key\": \"FIREBASE_WEB_API_KEY\",
\"optional\": true
}
}
},
{
\"name\": \"FIREBASE_CLIENT_EMAIL\",
\"valueFrom\": {
\"secretKeyRef\": {
\"name\": \"morpheus-secret\",
\"key\": \"FIREBASE_CLIENT_EMAIL\",
\"optional\": true
}
}
},
{
\"name\": \"IMAGES_BUCKET\",
\"valueFrom\": {
\"secretKeyRef\": {
\"name\": \"morpheus-secret\",
\"key\": \"IMAGES_BUCKET\",
\"optional\": true
}
}
},
{
\"name\": \"IMAGES_TEMP_BUCKET\",
\"valueFrom\": {
\"secretKeyRef\": {
\"name\": \"morpheus-secret\",
\"key\": \"IMAGES_TEMP_BUCKET\",
\"optional\": true
}
}
},
{
\"name\": \"MODELS_BUCKET\",
\"valueFrom\": {
\"secretKeyRef\": {
\"name\": \"morpheus-secret\",
\"key\": \"MODELS_BUCKET\",
\"optional\": true
}
}
}
]
}
]
}
}"
helm upgrade --timeout 15m0s --install --atomic morpheus ./morpheus-server/helm/charts/morpheus/ \
--set image.tag=${{ github.run_id }} --set domain=${{secrets.FRONTEND_DOMAIN}}
33 changes: 33 additions & 0 deletions .github/workflows/cd-collaborative.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: CI Test and deploy Collaborative
on:
workflow_dispatch:
workflow_call:
env:
MAX_LINE_LENGTH: 120
WORKING_DIR_BACKEND: morpheus-collaborative
jobs:
ci-collab:
uses: ./.github/workflows/ci-collaborative.yaml
with:
called: true
secrets: inherit
deploy-collaborative-k8s:
runs-on: ubuntu-latest
needs:
- ci-collab
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Create kube config
run: |
aws eks --region ${{secrets.AWS_REGION}} update-kubeconfig --name ${{secrets.AWS_CLUSTER_NAME}}
- name: Deploy using helm
run: |
helm upgrade --timeout 15m0s --install --atomic morpheus-collaborative ./morpheus-collaborative/helm/charts/morpheus-collaborative/ \
--set image.tag=collab-${{ github.run_id }} --set domain=${{secrets.FRONTEND_DOMAIN}}
36 changes: 36 additions & 0 deletions .github/workflows/cd-frontend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: CI Test and deploy Frontend
on:
workflow_dispatch:
workflow_call:
jobs:
ci-frontend:
uses: ./.github/workflows/ci-frontend.yaml
with:
called: true
secrets: inherit
deploy-frontend-k8s:
runs-on: ubuntu-latest
needs:
- ci-frontend
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Create kube config
run: |
aws eks --region ${{secrets.AWS_REGION}} update-kubeconfig --name ${{secrets.AWS_CLUSTER_NAME}}
- name: Deploy using helm
run: |
helm upgrade --timeout 15m0s --install --atomic morpheus-client ./morpheus-client/helm/charts/morpheus-client/ \
--set image.tag=client-${{ github.run_id }}
- name: Clear cache in cloudflare
run: |
curl -X POST "https://api.cloudflare.com/client/v4/zones/${{secrets.CLOUDFLARE_ZONE_ID}}/purge_cache" \
-H "Authorization: Bearer ${{secrets.CLOUDFLARE_API_TOKEN}}" \
-H "Content-Type: application/json" \
--data '{"purge_everything":true}' || echo "Failed to clear caches"
113 changes: 113 additions & 0 deletions .github/workflows/ci-api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: CI backend
on:
workflow_call:
inputs:
called:
required: false
type: string
workflow_dispatch:
inputs:
called:
required: false
type: string
env:
MAX_LINE_LENGTH: 120
WORKING_DIR: morpheus-server
jobs:
linters:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ env.WORKING_DIR }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
id: python-cache
with:
python-version: '3.10'
cache: pip
cache-dependency-path: ./${{ env.WORKING_DIR }}/requirements.lint.txt
- name: Install packages
run: |
pip install -r requirements.lint.txt
- name: Black
run: |
black --line-length $MAX_LINE_LENGTH --exclude app/migrations/ .
- name: Flake8
run: |
flake8 --max-line-length $MAX_LINE_LENGTH --exclude app/migrations/ .
ci-backend:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ env.WORKING_DIR }}
services:
postgres:
image: postgres
env:
POSTGRES_USER: postgres
POSTGRES_DB: morpheus
POSTGRES_PASSWORD: password
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
id: python-cache
with:
python-version: '3.10'
cache: pip
- name: Install packages
run: |
pip install pipenv
pip install pytest
- name: Install dependencies
run: |
pipenv requirements > requirements.txt
pip install -r requirements.txt
pip install torch --index-url https://download.pytorch.org/whl/cpu
- name: Run tests
env:
POSTGRES_HOST: localhost
FIREBASE_PROJECT_ID: ${{ secrets.FIREBASE_PROJECT_ID }}
FIREBASE_PRIVATE_KEY: ${{ secrets.FIREBASE_PRIVATE_KEY }}
FIREBASE_CLIENT_EMAIL: ${{ secrets.FIREBASE_CLIENT_EMAIL }}
FIREBASE_WEB_API_KEY: ${{ secrets.FIREBASE_WEB_API_KEY }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
IMAGES_BUCKET: ${{ secrets.IMAGES_BUCKET }}
IMAGES_TEMP_BUCKET: ${{ secrets.IMAGES_TEMP_BUCKET }}
MODELS_BUCKET: ${{ secrets.MODELS_BUCKET }}
run: |
pytest
echo ${{ inputs.called }}
-
name: Set up QEMU
if: ${{ inputs.called == 'true' }}
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
if: ${{ inputs.called == 'true' }}
uses: docker/setup-buildx-action@v2
-
name: Login to DockerHub
if: ${{ inputs.called == 'true' }}
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
-
name: Build and push
if: ${{ inputs.called == 'true' }}
uses: docker/build-push-action@v3
with:
context: "{{defaultContext}}:morpheus-server"
build-args: |
BUILD_ENV=copy
push: true
tags: monadicalsas/morpheus:${{ github.run_id }}
Loading

0 comments on commit 90abd8f

Please sign in to comment.