diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml deleted file mode 100644 index 114532a..0000000 --- a/.github/workflows/build.yaml +++ /dev/null @@ -1,94 +0,0 @@ -name: Build Docker Container & Push to Registry - -on: - workflow_call: - workflow_dispatch: - push: - branches: [main] - pull_request: - branches: [main] - -jobs: - test_fastapi_job: - uses: StarmoonAI/starmoon-private/.github/workflows/test-fastapi.yaml@main - docker_build: - runs-on: ubuntu-latest - defaults: - run: - working-directory: backend - needs: [test_fastapi_job] - env: - CLUSTER_NAME: AItoyK8s - - steps: - - name: Checkout source code - uses: actions/checkout@v3 - - name: Azure login - id: login - uses: azure/login@v1.4.3 - with: - creds: ${{ secrets.AZURE_CREDENTIALS }} - - name: Azure Container Registry login - run: | - az acr login --name ${{ secrets.REGISTRY }} - - name: Set AKS context - id: set-context - uses: azure/aks-set-context@v3 - with: - resource-group: "${{ secrets.resource_group }}" - cluster-name: "${{ secrets.cluster_name }}" - - name: Build container image - run: | - docker build --tag aitoy:latest . - - name: Manually tag the built image with custom tags - run: | - docker tag aitoy:latest aitoyregistry.azurecr.io/aitoy:${GITHUB_SHA::7}-${GITHUB_RUN_ID::5} - - name: Push all tagged images to the registry - run: | - docker push aitoyregistry.azurecr.io/aitoy --all-tags - - name: Update deployment secrets - run: | - if kubectl get secrets | grep -q fastapi-prod-env; then - kubectl delete secret fastapi-prod-env - fi - cat << EOF >> ./.env.prod - LLM_MODEL_NAME=${{ secrets.LLM_MODEL_NAME }} - MS_SPEECH_ENDPOINTY=${{ secrets.MS_SPEECH_ENDPOINTY }} - SPEECH_KEY=${{ secrets.SPEECH_KEY }} - SPEECH_REGION=${{ secrets.SPEECH_REGION }} - DG_API_KEY=${{ secrets.DG_API_KEY }} - HF_ACCESS_TOKEN=${{ secrets.HF_ACCESS_TOKEN }} - HF_EMOTION_API_URL=${{ secrets.HF_EMOTION_API_URL }} - AZURE_OPENAI_ENDPOINT=${{ secrets.AZURE_OPENAI_ENDPOINT }} - AZURE_OPENAI_API_KEY=${{ secrets.AZURE_OPENAI_API_KEY }} - NEXT_PUBLIC_SUPABASE_URL=${{ secrets.NEXT_PUBLIC_SUPABASE_URL }} - NEXT_PUBLIC_SUPABASE_ANON_KEY=${{ secrets.NEXT_PUBLIC_SUPABASE_ANON_KEY }} - JWT_SECRET_KEY=${{ secrets.JWT_SECRET_KEY }} - CELERY_BROKER_URL=${{ secrets.CELERY_BROKER_URL }} - CELERY_RESULT_BACKEND=${{ secrets.CELERY_RESULT_BACKEND }} - CELERY_FLOWER_USER=${{ secrets.CELERY_FLOWER_USER }} - CELERY_FLOWER_PASSWORD=${{ secrets.CELERY_FLOWER_PASSWORD }} - EOF - kubectl create secret generic fastapi-prod-env --from-env-file=./.env.prod - - name: Refresh k8s deployment - run: | - kubectl apply -f kubernetes/redis/deployment.yaml - kubectl apply -f kubernetes/fastapi/deployment.yaml - kubectl apply -f kubernetes/celery/beat-deployment.yaml - kubectl apply -f kubernetes/celery/worker-deployment.yaml - kubectl apply -f kubernetes/flower/deployment.yaml - - name: Update Deployment image - run: | - kubectl set image deployment/starmoon-app starmoon-app=aitoyregistry.azurecr.io/aitoy:${GITHUB_SHA::7}-${GITHUB_RUN_ID::5} - kubectl set image deployment/celery-beat celery-beat=aitoyregistry.azurecr.io/aitoy:${GITHUB_SHA::7}-${GITHUB_RUN_ID::5} - kubectl set image deployment/celery-worker celery-worker=aitoyregistry.azurecr.io/aitoy:${GITHUB_SHA::7}-${GITHUB_RUN_ID::5} - kubectl set image deployment/celery-flower celery-flower=aitoyregistry.azurecr.io/aitoy:${GITHUB_SHA::7}-${GITHUB_RUN_ID::5} - - name: Get Deployment status - run: | - kubectl rollout status deployment/starmoon-app - kubectl rollout status deployment/celery-beat - kubectl rollout status deployment/celery-worker - kubectl rollout status deployment/celery-flower - - name: Post-build FastAPI Commands - Migrate / Collectstatic - run: | - export SINGLE_POD_NAME=$(kubectl get pod -l app=starmoon-app -o jsonpath="{.items[0].metadata.name}") diff --git a/.github/workflows/test-fastapi.yaml b/.github/workflows/test-fastapi.yaml deleted file mode 100644 index 1d06848..0000000 --- a/.github/workflows/test-fastapi.yaml +++ /dev/null @@ -1,44 +0,0 @@ -name: FastAPI Test - -on: - workflow_call: - workflow_dispatch: - -jobs: - build: - runs-on: ubuntu-latest - defaults: - run: - working-directory: backend - env: - WEBSITE_HOSTNAME: localhost:8000 - FRONTEND_HOSTNAME: localhost:3000 - strategy: - max-parallel: 4 - matrix: - python-version: ["3.10", "3.11"] - - steps: - - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 - with: - python-version: ${{ matrix.python-version }} - - name: Install system dependencies - run: | - sudo apt-get update - sudo apt-get install -y portaudio19-dev python-all-dev - - - name: Install Python dependencies - run: | - python -m pip install --upgrade pip - pip install poetry - pip install flake8 - - name: Install poetry dependencies - run: | - poetry install --only main - - name: Look for major issues with flake8 - run: | - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # - name: Run tests - # run: poetry run pytest diff --git a/backend/kubernetes/celery/beat-deployment.yaml b/backend/kubernetes/celery/beat-deployment.yaml deleted file mode 100644 index fa14713..0000000 --- a/backend/kubernetes/celery/beat-deployment.yaml +++ /dev/null @@ -1,27 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: celery-beat - labels: - app: celery-beat -spec: - replicas: 1 - selector: - matchLabels: - pod: celery-beat - template: - metadata: - labels: - pod: celery-beat - spec: - containers: - - name: celery-beat - image: aitoyregistry.azurecr.io/aitoy:latest - command: ["/bin/sh", "-c"] - args: - - | - rm -f './celerybeat.pid' - poetry run celery -A app.celery.worker.celery_app beat --loglevel=info - envFrom: - - secretRef: - name: fastapi-prod-env \ No newline at end of file diff --git a/backend/kubernetes/celery/worker-deployment.yaml b/backend/kubernetes/celery/worker-deployment.yaml deleted file mode 100644 index 00e52c8..0000000 --- a/backend/kubernetes/celery/worker-deployment.yaml +++ /dev/null @@ -1,47 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: celery-worker - labels: - deployment: celery-worker -spec: - replicas: 1 - selector: - matchLabels: - pod: celery-worker - template: - metadata: - labels: - pod: celery-worker - spec: - containers: - - name: celery-worker - image: aitoyregistry.azurecr.io/aitoy:latest - command: - [ - "poetry", - "run", - "celery", - "-A", - "app.celery.worker.celery_app", - "worker", - "-l", - "info", - ] - envFrom: - - secretRef: - name: fastapi-prod-env - ---- -apiVersion: autoscaling/v1 -kind: HorizontalPodAutoscaler -metadata: - name: celery-worker -spec: - scaleTargetRef: - apiVersion: apps/v1 - kind: Deployment - name: celery-worker - minReplicas: 1 - maxReplicas: 30 - targetCPUUtilizationPercentage: 90 \ No newline at end of file diff --git a/backend/kubernetes/fastapi/deployment.yaml b/backend/kubernetes/fastapi/deployment.yaml deleted file mode 100644 index b25b50e..0000000 --- a/backend/kubernetes/fastapi/deployment.yaml +++ /dev/null @@ -1,74 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: starmoon-app -spec: - replicas: 2 - selector: - matchLabels: - app: starmoon-app - template: - metadata: - labels: - app: starmoon-app - spec: - containers: - - name: starmoon-app - image: aitoyregistry.azurecr.io/aitoy:latest - command: - - poetry - - run - - uvicorn - - app.main:app - - "--host" - - "0.0.0.0" - - "--port" - - "8000" - - "--ws-ping-interval" - - "600" - - "--ws-ping-timeout" - - "600" - ports: - - containerPort: 8000 - envFrom: - - secretRef: - name: fastapi-prod-env - affinity: - podAntiAffinity: - requiredDuringSchedulingIgnoredDuringExecution: - - labelSelector: - matchExpressions: - - key: "app" - operator: In - values: - - starmoon-app - topologyKey: "kubernetes.io/hostname" - ---- -apiVersion: v1 -kind: Service -metadata: - name: starmoon-service -spec: - type: LoadBalancer - # type: ClusterIP - ports: - - protocol: TCP - port: 80 - targetPort: 8000 - selector: - app: starmoon-app - ---- -apiVersion: autoscaling/v1 -kind: HorizontalPodAutoscaler -metadata: - name: starmoon-app -spec: - scaleTargetRef: - apiVersion: apps/v1 - kind: Deployment - name: starmoon-app - minReplicas: 1 - maxReplicas: 20 - targetCPUUtilizationPercentage: 90 \ No newline at end of file diff --git a/backend/kubernetes/flower/deployment.yaml b/backend/kubernetes/flower/deployment.yaml deleted file mode 100644 index 65a76f2..0000000 --- a/backend/kubernetes/flower/deployment.yaml +++ /dev/null @@ -1,49 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: celery-flower - labels: - pod: celery-flower -spec: - replicas: 1 - selector: - matchLabels: - pod: celery-flower - template: - metadata: - labels: - pod: celery-flower - spec: - containers: - - name: celery-flower - image: aitoyregistry.azurecr.io/aitoy:latest - command: - - poetry - - run - - celery - - "-A" - - "app.celery.worker.celery_app" - - flower - - "--basic_auth=$(CELERY_FLOWER_USER):$(CELERY_FLOWER_PASSWORD)" - ports: - - containerPort: 5555 - resources: - limits: - cpu: 100m - envFrom: - - secretRef: - name: fastapi-prod-env - ---- -apiVersion: v1 -kind: Service -metadata: - name: flower-service -spec: - type: LoadBalancer - ports: - - protocol: TCP - port: 80 - targetPort: 5555 - selector: - pod: celery-flower \ No newline at end of file diff --git a/backend/kubernetes/ingress/args b/backend/kubernetes/ingress/args deleted file mode 100644 index e800013..0000000 --- a/backend/kubernetes/ingress/args +++ /dev/null @@ -1,4 +0,0 @@ -- --certificatesresolvers.default.acme.tlschallenge - - --certificatesresolvers.default.acme.email=junruxiong@gmail.com - - --certificatesresolvers.default.acme.storage=/data/acme.json - - --certificatesresolvers.default.acme.caserver=https://acme-v02.api.letsencrypt.org/directory \ No newline at end of file diff --git a/backend/kubernetes/ingress/ingress-celery.yaml b/backend/kubernetes/ingress/ingress-celery.yaml deleted file mode 100644 index bd3b45e..0000000 --- a/backend/kubernetes/ingress/ingress-celery.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: traefik.io/v1alpha1 -kind: IngressRoute -metadata: - name: flower -spec: - routes: - - kind: Rule - match: Host(`celery.starmoon.app`) - services: - - name: flower-service - port: 80 - tls: - certResolver: default \ No newline at end of file diff --git a/backend/kubernetes/ingress/ingress-starmoon.yaml b/backend/kubernetes/ingress/ingress-starmoon.yaml deleted file mode 100644 index 1a93184..0000000 --- a/backend/kubernetes/ingress/ingress-starmoon.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: traefik.io/v1alpha1 -kind: IngressRoute -metadata: - name: starmoon -spec: - routes: - - kind: Rule - match: Host(`api.starmoon.app`) - services: - - name: starmoon-service - port: 80 - tls: - certResolver: default \ No newline at end of file diff --git a/backend/kubernetes/redis/deployment.yaml b/backend/kubernetes/redis/deployment.yaml deleted file mode 100644 index 83d761a..0000000 --- a/backend/kubernetes/redis/deployment.yaml +++ /dev/null @@ -1,38 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: redis - labels: - app: redis -spec: - replicas: 1 - selector: - matchLabels: - app: redis - template: - metadata: - labels: - app: redis - spec: - containers: - - name: redis - image: redis:7-alpine - imagePullPolicy: Always - - env: - - name: PORT - value: "6379" - ports: - - containerPort: 6379 - ---- -apiVersion: v1 -kind: Service -metadata: - name: redis -spec: - ports: - - port: 6379 - targetPort: 6379 - selector: - app: redis \ No newline at end of file