diff --git a/.github/workflows/auth-backend-ci-cd-production.yml b/.github/workflows/auth-backend-ci-cd-production.yml deleted file mode 100644 index cf579944b..000000000 --- a/.github/workflows/auth-backend-ci-cd-production.yml +++ /dev/null @@ -1,85 +0,0 @@ -name: CI/CD Pipeline for Auth Backend (Production) - -on: - push: - branches: - - main - paths: - - 'apps/auth-service/**' -jobs: - build_and_deploy: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - 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: ${{ secrets.AWS_REGION }} - - - name: Read version from package.json - id: get_version - run: | - VERSION=$(cat apps/auth-service/package.json | jq -r '.version') - echo "VERSION=${VERSION}" >> $GITHUB_ENV - - - name: Login to Amazon ECR - run: | - aws ecr get-login-password --region ${{ secrets.AWS_REGION }} | docker login --username AWS --password-stdin ${{ secrets.ECR_REGISTRY }} - - - name: Check latest image version in ECR - id: check_version - run: | - LATEST_ECR_VERSION=$(aws ecr describe-images --repository-name ${{ secrets.ECR_REPOSITORY_AUTH_BACKEND_NAME }} --region ${{ secrets.AWS_REGION }} --query 'sort_by(imageDetails,& imagePushedAt)[-1].imageTags[0]' --output text) - if [ "$VERSION" == "$LATEST_ECR_VERSION" ]; then - echo "::set-output name=should_deploy::false" - else - echo "::set-output name=should_deploy::true" - fi - - - name: Build Docker image - if: steps.check_version.outputs.should_deploy == 'true' - run: | - docker build -f apps/auth-service/Dockerfile --no-cache --progress=plain -t ${{ secrets.ECR_REGISTRY }}/${{ secrets.ECR_REPOSITORY_AUTH_BACKEND_NAME }}:$VERSION . - - - name: Push Docker image to Amazon ECR - if: steps.check_version.outputs.should_deploy == 'true' - run: | - docker push ${{ secrets.ECR_REGISTRY }}/${{ secrets.ECR_REPOSITORY_AUTH_BACKEND_NAME }}:$VERSION - - - name: Decode SSH Key - run: echo "${{ secrets.AWS_SSH_KEY }}" | base64 --decode > private_key.pem - - - name: Set file permissions - run: chmod 600 private_key.pem - - - name: Deploy to EC2 - if: steps.check_version.outputs.should_deploy == 'true' - run: | - ssh -o StrictHostKeyChecking=no -i private_key.pem ${{ secrets.AWS_EC2_USER_NAME }}@${{ secrets.AWS_EC2_HOST }} ' - export AWS_REGION=${{ secrets.AWS_REGION }} - export ECR_REGISTRY=${{ secrets.ECR_REGISTRY }} - export ECR_REPOSITORY_AUTH_BACKEND_NAME=${{ secrets.ECR_REPOSITORY_AUTH_BACKEND_NAME }} - - aws ecr get-login-password --region $AWS_REGION | sudo docker login --username AWS --password-stdin $ECR_REGISTRY - - LATEST_IMAGE_VERSION=$(aws ecr describe-images --repository-name $ECR_REPOSITORY_AUTH_BACKEND_NAME --region $AWS_REGION --query "sort_by(imageDetails,& imagePushedAt)[-1].imageTags[0]" --output text) - echo "Latest image version: $LATEST_IMAGE_VERSION" - - cd nginx/ - sed -i -E "s|(auth-backend:)[0-9]+\.[0-9]+\.[0-9]+|\1$LATEST_IMAGE_VERSION|g" docker-compose.yml - if [ $? -eq 0 ]; then - echo "Image version updated successfully in docker-compose.yml." - else - echo "Failed to update image version in docker-compose.yml." - exit 1 - fi - - sudo docker compose down auth-backend-service - sudo docker compose pull auth-backend-service - sudo docker compose up -d auth-backend-service - ' diff --git a/.github/workflows/auth-backend-ci-cd-staging.yml b/.github/workflows/auth-backend-ci-cd-staging.yml deleted file mode 100644 index c330fd322..000000000 --- a/.github/workflows/auth-backend-ci-cd-staging.yml +++ /dev/null @@ -1,85 +0,0 @@ -name: CI/CD Pipeline for Auth Backend (Staging) - -on: - push: - branches: - - staging - paths: - - 'apps/auth-service/**' -jobs: - build_and_deploy: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - 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: ${{ secrets.AWS_REGION }} - - - name: Read version from package.json - id: get_version - run: | - VERSION=$(cat apps/auth-service/package.json | jq -r '.version') - echo "VERSION=${VERSION}" >> $GITHUB_ENV - - - name: Login to Amazon ECR - run: | - aws ecr get-login-password --region ${{ secrets.AWS_REGION }} | docker login --username AWS --password-stdin ${{ secrets.ECR_REGISTRY }} - - - name: Check latest image version in ECR - id: check_version - run: | - LATEST_ECR_VERSION=$(aws ecr describe-images --repository-name ${{ secrets.STAGING_ECR_REPOSITORY_AUTH_BACKEND_NAME }} --region ${{ secrets.AWS_REGION }} --query 'sort_by(imageDetails,& imagePushedAt)[-1].imageTags[0]' --output text) - if [ "$VERSION" == "$LATEST_ECR_VERSION" ]; then - echo "::set-output name=should_deploy::false" - else - echo "::set-output name=should_deploy::true" - fi - - - name: Build Docker image - if: steps.check_version.outputs.should_deploy == 'true' - run: | - docker build -f apps/auth-service/Dockerfile --no-cache --progress=plain -t ${{ secrets.ECR_REGISTRY }}/${{ secrets.STAGING_ECR_REPOSITORY_AUTH_BACKEND_NAME }}:$VERSION . - - - name: Push Docker image to Amazon ECR - if: steps.check_version.outputs.should_deploy == 'true' - run: | - docker push ${{ secrets.ECR_REGISTRY }}/${{ secrets.STAGING_ECR_REPOSITORY_AUTH_BACKEND_NAME }}:$VERSION - - - name: Decode SSH Key - run: echo "${{ secrets.AWS_SSH_KEY_STAGING }}" | base64 --decode > private_key.pem - - - name: Set file permissions - run: chmod 600 private_key.pem - - - name: Deploy to EC2 - if: steps.check_version.outputs.should_deploy == 'true' - run: | - ssh -o StrictHostKeyChecking=no -i private_key.pem ${{ secrets.AWS_EC2_USER_NAME }}@${{ secrets.AWS_EC2_HOST_STAGING }} ' - export AWS_REGION=${{ secrets.AWS_REGION }} - export ECR_REGISTRY=${{ secrets.ECR_REGISTRY }} - export STAGING_ECR_REPOSITORY_AUTH_BACKEND_NAME=${{ secrets.STAGING_ECR_REPOSITORY_AUTH_BACKEND_NAME }} - - aws ecr get-login-password --region $AWS_REGION | sudo docker login --username AWS --password-stdin $ECR_REGISTRY - - LATEST_IMAGE_VERSION=$(aws ecr describe-images --repository-name $STAGING_ECR_REPOSITORY_AUTH_BACKEND_NAME --region $AWS_REGION --query "sort_by(imageDetails,& imagePushedAt)[-1].imageTags[0]" --output text) - echo "Latest image version: $LATEST_IMAGE_VERSION" - - cd backend/ - sed -i -E "s|(auth-backend:)[0-9]+\.[0-9]+\.[0-9]+|\1$LATEST_IMAGE_VERSION|g" docker-compose.yml - if [ $? -eq 0 ]; then - echo "Image version updated successfully in docker-compose.yml." - else - echo "Failed to update image version in docker-compose.yml." - exit 1 - fi - - sudo docker compose down auth-backend-service - sudo docker compose pull auth-backend-service - sudo docker compose up -d auth-backend-service - ' diff --git a/.github/workflows/codemod-backend-ci-cd-production copy 2.yml b/.github/workflows/codemod-backend-ci-cd-production copy 2.yml deleted file mode 100644 index 75c6dfd6d..000000000 --- a/.github/workflows/codemod-backend-ci-cd-production copy 2.yml +++ /dev/null @@ -1,85 +0,0 @@ -name: CI/CD Pipeline for Codemod Backend (Production) - -on: - push: - branches: - - main - paths: - - 'apps/backend/**' -jobs: - build_and_deploy: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - 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: ${{ secrets.AWS_REGION }} - - - name: Read version from package.json - id: get_version - run: | - VERSION=$(cat apps/backend/package.json | jq -r '.version') - echo "VERSION=${VERSION}" >> $GITHUB_ENV - - - name: Login to Amazon ECR - run: | - aws ecr get-login-password --region ${{ secrets.AWS_REGION }} | docker login --username AWS --password-stdin ${{ secrets.ECR_REGISTRY }} - - - name: Check latest image version in ECR - id: check_version - run: | - LATEST_ECR_VERSION=$(aws ecr describe-images --repository-name ${{ secrets.ECR_REPOSITORY_CODEMOD_BACKEND_NAME }} --region ${{ secrets.AWS_REGION }} --query 'sort_by(imageDetails,& imagePushedAt)[-1].imageTags[0]' --output text) - if [ "$VERSION" == "$LATEST_ECR_VERSION" ]; then - echo "::set-output name=should_deploy::false" - else - echo "::set-output name=should_deploy::true" - fi - - - name: Build Docker image - if: steps.check_version.outputs.should_deploy == 'true' - run: | - docker build -f apps/backend/Dockerfile --no-cache --progress=plain -t ${{ secrets.ECR_REGISTRY }}/${{ secrets.ECR_REPOSITORY_CODEMOD_BACKEND_NAME }}:$VERSION . - - - name: Push Docker image to Amazon ECR - if: steps.check_version.outputs.should_deploy == 'true' - run: | - docker push ${{ secrets.ECR_REGISTRY }}/${{ secrets.ECR_REPOSITORY_CODEMOD_BACKEND_NAME }}:$VERSION - - - name: Decode SSH Key - run: echo "${{ secrets.AWS_SSH_KEY }}" | base64 --decode > private_key.pem - - - name: Set file permissions - run: chmod 600 private_key.pem - - - name: Deploy to EC2 - if: steps.check_version.outputs.should_deploy == 'true' - run: | - ssh -o StrictHostKeyChecking=no -i private_key.pem ${{ secrets.AWS_EC2_USER_NAME }}@${{ secrets.AWS_EC2_HOST }} ' - export AWS_REGION=${{ secrets.AWS_REGION }} - export ECR_REGISTRY=${{ secrets.ECR_REGISTRY }} - export ECR_REPOSITORY_CODEMOD_BACKEND_NAME=${{ secrets.ECR_REPOSITORY_CODEMOD_BACKEND_NAME }} - - aws ecr get-login-password --region $AWS_REGION | sudo docker login --username AWS --password-stdin $ECR_REGISTRY - - LATEST_IMAGE_VERSION=$(aws ecr describe-images --repository-name $ECR_REPOSITORY_CODEMOD_BACKEND_NAME --region $AWS_REGION --query "sort_by(imageDetails,& imagePushedAt)[-1].imageTags[0]" --output text) - echo "Latest image version: $LATEST_IMAGE_VERSION" - - cd nginx/ - sed -i -E "s|(codemod-backend:)[0-9]+\.[0-9]+\.[0-9]+|\1$LATEST_IMAGE_VERSION|g" docker-compose.yml - if [ $? -eq 0 ]; then - echo "Image version updated successfully in docker-compose.yml." - else - echo "Failed to update image version in docker-compose.yml." - exit 1 - fi - - sudo docker compose down codemod-backend-service - sudo docker compose pull codemod-backend-service - sudo docker compose up -d codemod-backend-service - ' diff --git a/.github/workflows/codemod-backend-ci-cd-staging.yml b/.github/workflows/codemod-backend-ci-cd-staging.yml deleted file mode 100644 index 84dbe99ab..000000000 --- a/.github/workflows/codemod-backend-ci-cd-staging.yml +++ /dev/null @@ -1,85 +0,0 @@ -name: CI/CD Pipeline for Codemod Backend (Staging) - -on: - push: - branches: - - staging - paths: - - 'apps/backend/**' -jobs: - build_and_deploy: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - 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: ${{ secrets.AWS_REGION }} - - - name: Read version from package.json - id: get_version - run: | - VERSION=$(cat apps/backend/package.json | jq -r '.version') - echo "VERSION=${VERSION}" >> $GITHUB_ENV - - - name: Login to Amazon ECR - run: | - aws ecr get-login-password --region ${{ secrets.AWS_REGION }} | docker login --username AWS --password-stdin ${{ secrets.ECR_REGISTRY }} - - - name: Check latest image version in ECR - id: check_version - run: | - LATEST_ECR_VERSION=$(aws ecr describe-images --repository-name ${{ secrets.STAGING_ECR_REPOSITORY_CODEMOD_BACKEND_NAME }} --region ${{ secrets.AWS_REGION }} --query 'sort_by(imageDetails,& imagePushedAt)[-1].imageTags[0]' --output text) - if [ "$VERSION" == "$LATEST_ECR_VERSION" ]; then - echo "::set-output name=should_deploy::false" - else - echo "::set-output name=should_deploy::true" - fi - - - name: Build Docker image - if: steps.check_version.outputs.should_deploy == 'true' - run: | - docker build -f apps/backend/Dockerfile --no-cache --progress=plain -t ${{ secrets.ECR_REGISTRY }}/${{ secrets.STAGING_ECR_REPOSITORY_CODEMOD_BACKEND_NAME }}:$VERSION . - - - name: Push Docker image to Amazon ECR - if: steps.check_version.outputs.should_deploy == 'true' - run: | - docker push ${{ secrets.ECR_REGISTRY }}/${{ secrets.STAGING_ECR_REPOSITORY_CODEMOD_BACKEND_NAME }}:$VERSION - - - name: Decode SSH Key - run: echo "${{ secrets.AWS_SSH_KEY_STAGING }}" | base64 --decode > private_key.pem - - - name: Set file permissions - run: chmod 600 private_key.pem - - - name: Deploy to EC2 - if: steps.check_version.outputs.should_deploy == 'true' - run: | - ssh -o StrictHostKeyChecking=no -i private_key.pem ${{ secrets.AWS_EC2_USER_NAME }}@${{ secrets.AWS_EC2_HOST_STAGING }} ' - export AWS_REGION=${{ secrets.AWS_REGION }} - export ECR_REGISTRY=${{ secrets.ECR_REGISTRY }} - export STAGING_ECR_REPOSITORY_CODEMOD_BACKEND_NAME=${{ secrets.STAGING_ECR_REPOSITORY_CODEMOD_BACKEND_NAME }} - - aws ecr get-login-password --region $AWS_REGION | sudo docker login --username AWS --password-stdin $ECR_REGISTRY - - LATEST_IMAGE_VERSION=$(aws ecr describe-images --repository-name $STAGING_ECR_REPOSITORY_CODEMOD_BACKEND_NAME --region $AWS_REGION --query "sort_by(imageDetails,& imagePushedAt)[-1].imageTags[0]" --output text) - echo "Latest image version: $LATEST_IMAGE_VERSION" - - cd backend/ - sed -i -E "s|(codemod-backend:)[0-9]+\.[0-9]+\.[0-9]+|\1$LATEST_IMAGE_VERSION|g" docker-compose.yml - if [ $? -eq 0 ]; then - echo "Image version updated successfully in docker-compose.yml." - else - echo "Failed to update image version in docker-compose.yml." - exit 1 - fi - - sudo docker compose down codemod-backend-service - sudo docker compose pull codemod-backend-service - sudo docker compose up -d codemod-backend-service - ' diff --git a/.github/workflows/modgpt-backend-ci-cd-production.yml b/.github/workflows/modgpt-backend-ci-cd-production.yml deleted file mode 100644 index 89ae959ea..000000000 --- a/.github/workflows/modgpt-backend-ci-cd-production.yml +++ /dev/null @@ -1,85 +0,0 @@ -name: CI/CD Pipeline for ModGPT Backend (Production) - -on: - push: - branches: - - main - paths: - - 'apps/modgpt/**' -jobs: - build_and_deploy: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - 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: ${{ secrets.AWS_REGION }} - - - name: Read version from package.json - id: get_version - run: | - VERSION=$(cat apps/modgpt/package.json | jq -r '.version') - echo "VERSION=${VERSION}" >> $GITHUB_ENV - - - name: Login to Amazon ECR - run: | - aws ecr get-login-password --region ${{ secrets.AWS_REGION }} | docker login --username AWS --password-stdin ${{ secrets.ECR_REGISTRY }} - - - name: Check latest image version in ECR - id: check_version - run: | - LATEST_ECR_VERSION=$(aws ecr describe-images --repository-name ${{ secrets.ECR_REPOSITORY_MODGPT_BACKEND_NAME }} --region ${{ secrets.AWS_REGION }} --query 'sort_by(imageDetails,& imagePushedAt)[-1].imageTags[0]' --output text) - if [ "$VERSION" == "$LATEST_ECR_VERSION" ]; then - echo "::set-output name=should_deploy::false" - else - echo "::set-output name=should_deploy::true" - fi - - - name: Build Docker image - if: steps.check_version.outputs.should_deploy == 'true' - run: | - docker build -f apps/modgpt/Dockerfile --no-cache --progress=plain -t ${{ secrets.ECR_REGISTRY }}/${{ secrets.ECR_REPOSITORY_MODGPT_BACKEND_NAME }}:$VERSION . - - - name: Push Docker image to Amazon ECR - if: steps.check_version.outputs.should_deploy == 'true' - run: | - docker push ${{ secrets.ECR_REGISTRY }}/${{ secrets.ECR_REPOSITORY_MODGPT_BACKEND_NAME }}:$VERSION - - - name: Decode SSH Key - run: echo "${{ secrets.AWS_SSH_KEY }}" | base64 --decode > private_key.pem - - - name: Set file permissions - run: chmod 600 private_key.pem - - - name: Deploy to EC2 - if: steps.check_version.outputs.should_deploy == 'true' - run: | - ssh -o StrictHostKeyChecking=no -i private_key.pem ${{ secrets.AWS_EC2_USER_NAME }}@${{ secrets.AWS_EC2_HOST }} ' - export AWS_REGION=${{ secrets.AWS_REGION }} - export ECR_REGISTRY=${{ secrets.ECR_REGISTRY }} - export ECR_REPOSITORY_MODGPT_BACKEND_NAME=${{ secrets.ECR_REPOSITORY_MODGPT_BACKEND_NAME }} - - aws ecr get-login-password --region $AWS_REGION | sudo docker login --username AWS --password-stdin $ECR_REGISTRY - - LATEST_IMAGE_VERSION=$(aws ecr describe-images --repository-name $ECR_REPOSITORY_MODGPT_BACKEND_NAME --region $AWS_REGION --query "sort_by(imageDetails,& imagePushedAt)[-1].imageTags[0]" --output text) - echo "Latest image version: $LATEST_IMAGE_VERSION" - - cd nginx/ - sed -i -E "s|(modgpt-backend:)[0-9]+\.[0-9]+\.[0-9]+|\1$LATEST_IMAGE_VERSION|g" docker-compose.yml - if [ $? -eq 0 ]; then - echo "Image version updated successfully in docker-compose.yml." - else - echo "Failed to update image version in docker-compose.yml." - exit 1 - fi - - sudo docker compose down modgpt-backend-service - sudo docker compose pull modgpt-backend-service - sudo docker compose up -d modgpt-backend-service - ' diff --git a/.github/workflows/modgpt-backend-ci-cd-staging.yml b/.github/workflows/modgpt-backend-ci-cd-staging.yml deleted file mode 100644 index 3f51c6478..000000000 --- a/.github/workflows/modgpt-backend-ci-cd-staging.yml +++ /dev/null @@ -1,85 +0,0 @@ -name: CI/CD Pipeline for ModGPT Backend (Staging) - -on: - push: - branches: - - staging - paths: - - 'apps/modgpt/**' -jobs: - build_and_deploy: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - 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: ${{ secrets.AWS_REGION }} - - - name: Read version from package.json - id: get_version - run: | - VERSION=$(cat apps/modgpt/package.json | jq -r '.version') - echo "VERSION=${VERSION}" >> $GITHUB_ENV - - - name: Login to Amazon ECR - run: | - aws ecr get-login-password --region ${{ secrets.AWS_REGION }} | docker login --username AWS --password-stdin ${{ secrets.ECR_REGISTRY }} - - - name: Check latest image version in ECR - id: check_version - run: | - LATEST_ECR_VERSION=$(aws ecr describe-images --repository-name ${{ secrets.STAGING_ECR_REPOSITORY_MODGPT_BACKEND_NAME }} --region ${{ secrets.AWS_REGION }} --query 'sort_by(imageDetails,& imagePushedAt)[-1].imageTags[0]' --output text) - if [ "$VERSION" == "$LATEST_ECR_VERSION" ]; then - echo "::set-output name=should_deploy::false" - else - echo "::set-output name=should_deploy::true" - fi - - - name: Build Docker image - if: steps.check_version.outputs.should_deploy == 'true' - run: | - docker build -f apps/modgpt/Dockerfile --no-cache --progress=plain -t ${{ secrets.ECR_REGISTRY }}/${{ secrets.STAGING_ECR_REPOSITORY_MODGPT_BACKEND_NAME }}:$VERSION . - - - name: Push Docker image to Amazon ECR - if: steps.check_version.outputs.should_deploy == 'true' - run: | - docker push ${{ secrets.ECR_REGISTRY }}/${{ secrets.STAGING_ECR_REPOSITORY_MODGPT_BACKEND_NAME }}:$VERSION - - - name: Decode SSH Key - run: echo "${{ secrets.AWS_SSH_KEY_STAGING }}" | base64 --decode > private_key.pem - - - name: Set file permissions - run: chmod 600 private_key.pem - - - name: Deploy to EC2 - if: steps.check_version.outputs.should_deploy == 'true' - run: | - ssh -o StrictHostKeyChecking=no -i private_key.pem ${{ secrets.AWS_EC2_USER_NAME }}@${{ secrets.AWS_EC2_HOST_STAGING }} ' - export AWS_REGION=${{ secrets.AWS_REGION }} - export ECR_REGISTRY=${{ secrets.ECR_REGISTRY }} - export STAGING_ECR_REPOSITORY_MODGPT_BACKEND_NAME=${{ secrets.STAGING_ECR_REPOSITORY_MODGPT_BACKEND_NAME }} - - aws ecr get-login-password --region $AWS_REGION | sudo docker login --username AWS --password-stdin $ECR_REGISTRY - - LATEST_IMAGE_VERSION=$(aws ecr describe-images --repository-name $STAGING_ECR_REPOSITORY_MODGPT_BACKEND_NAME --region $AWS_REGION --query "sort_by(imageDetails,& imagePushedAt)[-1].imageTags[0]" --output text) - echo "Latest image version: $LATEST_IMAGE_VERSION" - - cd backend/ - sed -i -E "s|(modgpt-backend:)[0-9]+\.[0-9]+\.[0-9]+|\1$LATEST_IMAGE_VERSION|g" docker-compose.yml - if [ $? -eq 0 ]; then - echo "Image version updated successfully in docker-compose.yml." - else - echo "Failed to update image version in docker-compose.yml." - exit 1 - fi - - sudo docker compose down modgpt-backend-service - sudo docker compose pull modgpt-backend-service - sudo docker compose up -d modgpt-backend-service - ' diff --git a/.github/workflows/run-backend-ci-cd-production.yml b/.github/workflows/run-backend-ci-cd-production.yml deleted file mode 100644 index 92ce0557c..000000000 --- a/.github/workflows/run-backend-ci-cd-production.yml +++ /dev/null @@ -1,85 +0,0 @@ -name: CI/CD Pipeline for Run Backend (Production) - -on: - push: - branches: - - main - paths: - - 'apps/run-service/**' -jobs: - build_and_deploy: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - 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: ${{ secrets.AWS_REGION }} - - - name: Read version from package.json - id: get_version - run: | - VERSION=$(cat apps/run-service/package.json | jq -r '.version') - echo "VERSION=${VERSION}" >> $GITHUB_ENV - - - name: Login to Amazon ECR - run: | - aws ecr get-login-password --region ${{ secrets.AWS_REGION }} | docker login --username AWS --password-stdin ${{ secrets.ECR_REGISTRY }} - - - name: Check latest image version in ECR - id: check_version - run: | - LATEST_ECR_VERSION=$(aws ecr describe-images --repository-name ${{ secrets.ECR_REPOSITORY_RUN_BACKEND_NAME }} --region ${{ secrets.AWS_REGION }} --query 'sort_by(imageDetails,& imagePushedAt)[-1].imageTags[0]' --output text) - if [ "$VERSION" == "$LATEST_ECR_VERSION" ]; then - echo "::set-output name=should_deploy::false" - else - echo "::set-output name=should_deploy::true" - fi - - - name: Build Docker image - if: steps.check_version.outputs.should_deploy == 'true' - run: | - docker build -f apps/run-service/Dockerfile --no-cache --progress=plain -t ${{ secrets.ECR_REGISTRY }}/${{ secrets.ECR_REPOSITORY_RUN_BACKEND_NAME }}:$VERSION . - - - name: Push Docker image to Amazon ECR - if: steps.check_version.outputs.should_deploy == 'true' - run: | - docker push ${{ secrets.ECR_REGISTRY }}/${{ secrets.ECR_REPOSITORY_RUN_BACKEND_NAME }}:$VERSION - - - name: Decode SSH Key - run: echo "${{ secrets.AWS_SSH_KEY }}" | base64 --decode > private_key.pem - - - name: Set file permissions - run: chmod 600 private_key.pem - - - name: Deploy to EC2 - if: steps.check_version.outputs.should_deploy == 'true' - run: | - ssh -o StrictHostKeyChecking=no -i private_key.pem ${{ secrets.AWS_EC2_USER_NAME }}@${{ secrets.AWS_EC2_HOST }} ' - export AWS_REGION=${{ secrets.AWS_REGION }} - export ECR_REGISTRY=${{ secrets.ECR_REGISTRY }} - export ECR_REPOSITORY_RUN_BACKEND_NAME=${{ secrets.ECR_REPOSITORY_RUN_BACKEND_NAME }} - - aws ecr get-login-password --region $AWS_REGION | sudo docker login --username AWS --password-stdin $ECR_REGISTRY - - LATEST_IMAGE_VERSION=$(aws ecr describe-images --repository-name $ECR_REPOSITORY_RUN_BACKEND_NAME --region $AWS_REGION --query "sort_by(imageDetails,& imagePushedAt)[-1].imageTags[0]" --output text) - echo "Latest image version: $LATEST_IMAGE_VERSION" - - cd nginx/ - sed -i -E "s|(run-backend:)[0-9]+\.[0-9]+\.[0-9]+|\1$LATEST_IMAGE_VERSION|g" docker-compose.yml - if [ $? -eq 0 ]; then - echo "Image version updated successfully in docker-compose.yml." - else - echo "Failed to update image version in docker-compose.yml." - exit 1 - fi - - sudo docker compose down run-backend-service - sudo docker compose pull run-backend-service - sudo docker compose up -d run-backend-service - ' diff --git a/.github/workflows/run-backend-ci-cd-staging.yml b/.github/workflows/run-backend-ci-cd-staging.yml deleted file mode 100644 index 9eeff3f9d..000000000 --- a/.github/workflows/run-backend-ci-cd-staging.yml +++ /dev/null @@ -1,85 +0,0 @@ -name: CI/CD Pipeline for Run Backend (Staging) - -on: - push: - branches: - - staging - paths: - - 'apps/run-service/**' -jobs: - build_and_deploy: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - 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: ${{ secrets.AWS_REGION }} - - - name: Read version from package.json - id: get_version - run: | - VERSION=$(cat apps/run-service/package.json | jq -r '.version') - echo "VERSION=${VERSION}" >> $GITHUB_ENV - - - name: Login to Amazon ECR - run: | - aws ecr get-login-password --region ${{ secrets.AWS_REGION }} | docker login --username AWS --password-stdin ${{ secrets.ECR_REGISTRY }} - - - name: Check latest image version in ECR - id: check_version - run: | - LATEST_ECR_VERSION=$(aws ecr describe-images --repository-name ${{ secrets.STAGING_ECR_REPOSITORY_RUN_BACKEND_NAME }} --region ${{ secrets.AWS_REGION }} --query 'sort_by(imageDetails,& imagePushedAt)[-1].imageTags[0]' --output text) - if [ "$VERSION" == "$LATEST_ECR_VERSION" ]; then - echo "::set-output name=should_deploy::false" - else - echo "::set-output name=should_deploy::true" - fi - - - name: Build Docker image - if: steps.check_version.outputs.should_deploy == 'true' - run: | - docker build -f apps/run-service/Dockerfile --no-cache --progress=plain -t ${{ secrets.ECR_REGISTRY }}/${{ secrets.STAGING_ECR_REPOSITORY_RUN_BACKEND_NAME }}:$VERSION . - - - name: Push Docker image to Amazon ECR - if: steps.check_version.outputs.should_deploy == 'true' - run: | - docker push ${{ secrets.ECR_REGISTRY }}/${{ secrets.STAGING_ECR_REPOSITORY_RUN_BACKEND_NAME }}:$VERSION - - - name: Decode SSH Key - run: echo "${{ secrets.AWS_SSH_KEY_STAGING }}" | base64 --decode > private_key.pem - - - name: Set file permissions - run: chmod 600 private_key.pem - - - name: Deploy to EC2 - if: steps.check_version.outputs.should_deploy == 'true' - run: | - ssh -o StrictHostKeyChecking=no -i private_key.pem ${{ secrets.AWS_EC2_USER_NAME }}@${{ secrets.AWS_EC2_HOST_STAGING }} ' - export AWS_REGION=${{ secrets.AWS_REGION }} - export ECR_REGISTRY=${{ secrets.ECR_REGISTRY }} - export STAGING_ECR_REPOSITORY_RUN_BACKEND_NAME=${{ secrets.STAGING_ECR_REPOSITORY_RUN_BACKEND_NAME }} - - aws ecr get-login-password --region $AWS_REGION | sudo docker login --username AWS --password-stdin $ECR_REGISTRY - - LATEST_IMAGE_VERSION=$(aws ecr describe-images --repository-name $STAGING_ECR_REPOSITORY_RUN_BACKEND_NAME --region $AWS_REGION --query "sort_by(imageDetails,& imagePushedAt)[-1].imageTags[0]" --output text) - echo "Latest image version: $LATEST_IMAGE_VERSION" - - cd backend/ - sed -i -E "s|(run-backend:)[0-9]+\.[0-9]+\.[0-9]+|\1$LATEST_IMAGE_VERSION|g" docker-compose.yml - if [ $? -eq 0 ]; then - echo "Image version updated successfully in docker-compose.yml." - else - echo "Failed to update image version in docker-compose.yml." - exit 1 - fi - - sudo docker compose down run-backend-service - sudo docker compose pull run-backend-service - sudo docker compose up -d run-backend-service - ' diff --git a/apps/auth-service/esbuild.config.js b/apps/auth-service/esbuild.config.js index b2f52654c..3b942925f 100644 --- a/apps/auth-service/esbuild.config.js +++ b/apps/auth-service/esbuild.config.js @@ -4,7 +4,8 @@ esbuild .build({ entryPoints: ["src/index.ts"], bundle: true, - minify: true, + minify: false, + sourcemap: true, platform: "node", outfile: "build/index.js", banner: { diff --git a/apps/backend/Dockerfile b/apps/backend/Dockerfile index eddd87484..5db068434 100644 --- a/apps/backend/Dockerfile +++ b/apps/backend/Dockerfile @@ -1,4 +1,4 @@ -FROM node:20-alpine3.16 as base +FROM node:20.18-alpine as base ENV PNPM_HOME="/pnpm" ENV PATH="$PNPM_HOME:$PATH" @@ -53,9 +53,11 @@ FROM base AS runner # Copy stuff for prisma to work COPY --from=installer /app/node_modules/.pnpm/@prisma+client@5.15.1_prisma@5.15.1/node_modules/.prisma/ ./node_modules/.pnpm/@prisma+client@5.15.1_prisma@5.15.1/node_modules/.prisma/ +RUN apk update +RUN apk add --no-cache openssl + WORKDIR /app COPY --from=installer /app/apps/backend ./apps/backend COPY --from=installer /app/packages/database ./packages/database -CMD cd packages/database && pnpm dlx prisma@latest migrate deploy && cd - && node apps/backend/build/index.js - +CMD node apps/backend/build/index.cjs diff --git a/apps/backend/esbuild.config.js b/apps/backend/esbuild.config.js index b2f52654c..fddc30f42 100644 --- a/apps/backend/esbuild.config.js +++ b/apps/backend/esbuild.config.js @@ -4,19 +4,9 @@ esbuild .build({ entryPoints: ["src/index.ts"], bundle: true, - minify: true, + minify: false, platform: "node", - outfile: "build/index.js", - banner: { - js: ` - import { createRequire } from 'module'; - import { fileURLToPath, URL } from 'url'; - import path from 'path'; - const require = createRequire(import.meta.url); - const __filename = fileURLToPath(import.meta.url); - const __dirname = path.dirname(__filename); - `, - }, - format: "esm", + outfile: "build/index.cjs", + format: "cjs", }) .catch(() => process.exit(1)); diff --git a/apps/backend/package.json b/apps/backend/package.json index 6cca7c8b7..929bd87d9 100644 --- a/apps/backend/package.json +++ b/apps/backend/package.json @@ -55,7 +55,6 @@ "fuse.js": "catalog:", "ioredis": "catalog:", "langchain": "catalog:", - "lodash-es": "catalog:", "openai": "catalog:", "openai-edge": "catalog:", "parse-github-url": "catalog:", diff --git a/apps/backend/src/index.ts b/apps/backend/src/index.ts index e2812425f..bac2e2e95 100644 --- a/apps/backend/src/index.ts +++ b/apps/backend/src/index.ts @@ -1,5 +1,3 @@ -import "dotenv/config"; - import { startCronJobs } from "./cron.js"; import { runServer } from "./server.js"; diff --git a/apps/backend/src/services/UnkeyService.ts b/apps/backend/src/services/UnkeyService.ts index 2c1b79647..8f159ace8 100644 --- a/apps/backend/src/services/UnkeyService.ts +++ b/apps/backend/src/services/UnkeyService.ts @@ -1,11 +1,17 @@ import type { CreateAPIKeyRequest } from "@codemod-com/api-types"; import { Unkey } from "@unkey/api"; -import { memoize } from "lodash-es"; const UNKEY_API_ID = process.env.UNKEY_API_ID as string; const UNKEY_ROOT_KEY = process.env.UNKEY_ROOT_KEY as string; -const getUnkey = memoize(() => new Unkey({ rootKey: UNKEY_ROOT_KEY })); +let unkey: Unkey | null = null; + +const getUnkey = () => { + if (!unkey) { + unkey = new Unkey({ rootKey: UNKEY_ROOT_KEY }); + } + return unkey; +}; export const createApiKey = async ({ apiKeyData, diff --git a/packages/database/prisma/schema.prisma b/packages/database/prisma/schema.prisma index 2994f1430..3e17d675a 100644 --- a/packages/database/prisma/schema.prisma +++ b/packages/database/prisma/schema.prisma @@ -1,8 +1,9 @@ // https://github.com/prisma/prisma/issues/1787 hangs at prisma issues from 2019 generator client { - provider = "prisma-client-js" - engineType = "binary" + provider = "prisma-client-js" + engineType = "binary" + binaryTargets = ["native", "linux-musl-openssl-3.0.x", "linux-musl-arm64-openssl-3.0.x"] } generator json { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index dc3a26e95..fa403d129 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1055,9 +1055,6 @@ importers: langchain: specifier: 'catalog:' version: 0.3.6(@langchain/core@0.2.36(openai@4.23.0))(axios@1.7.7)(handlebars@4.7.8)(openai@4.23.0) - lodash-es: - specifier: 'catalog:' - version: 4.17.21 openai: specifier: 'catalog:' version: 4.23.0 @@ -1277,27 +1274,6 @@ importers: specifier: 'catalog:' version: 17.7.2 - apps/cli/dist/jscodeshift: - devDependencies: - '@codemod.com/codemod-utils': - specifier: '*' - version: 1.0.0(@babel/preset-env@7.24.7(@babel/core@7.24.7)) - '@types/jscodeshift': - specifier: ^0.11.10 - version: 0.11.11 - '@types/node': - specifier: 20.9.0 - version: 20.9.0 - jscodeshift: - specifier: ^0.15.1 - version: 0.15.2(@babel/preset-env@7.24.7(@babel/core@7.24.7)) - typescript: - specifier: ^5.2.2 - version: 5.5.4 - vitest: - specifier: ^1.0.1 - version: 1.1.0(@types/node@20.9.0)(jsdom@23.2.0)(terser@5.31.1) - apps/frontend: dependencies: '@ariakit/react': @@ -7392,6 +7368,8 @@ importers: specifier: ^4.11.0 version: 4.15.7 + packages/database/generated/client: {} + packages/deprecated: {} packages/filemod: @@ -29471,7 +29449,7 @@ snapshots: archiver-utils@5.0.2: dependencies: - glob: 10.4.2 + glob: 10.4.5 graceful-fs: 4.2.11 is-stream: 2.0.1 lazystream: 1.0.1 @@ -36632,7 +36610,7 @@ snapshots: rimraf@5.0.7: dependencies: - glob: 10.4.2 + glob: 10.4.5 rollup@3.29.4: optionalDependencies: @@ -37611,7 +37589,7 @@ snapshots: dependencies: '@jridgewell/gen-mapping': 0.3.5 commander: 4.1.1 - glob: 10.4.2 + glob: 10.4.5 lines-and-columns: 1.2.4 mz: 2.7.0 pirates: 4.0.6