diff --git a/.github/workflows/frontend_push.yml b/.github/workflows/frontend_push.yml new file mode 100644 index 0000000..cb7054b --- /dev/null +++ b/.github/workflows/frontend_push.yml @@ -0,0 +1,64 @@ +name: Deploy to Amazon ECS + +on: + push: + branches: + - master + +env: + AWS_REGION: us-east-1 + ECS_CLUSTER: medical_assistant_cluster + ECS_SERVICE: medical_assistant_frontend + ECR_REPOSITORY: 891377268337.dkr.ecr.us-east-1.amazonaws.com/medical_assistant_frontend + API_KEY: ${{secrets.API_KEY}} + +jobs: + build_image_backend: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@0e613a0980cbf65ed5b322eb7a1e075d28913a83 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ env.AWS_REGION }} + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@62f4f872db3836360b72999f4b87f1ff13310f3a + + - name: Build, tag, and push image to Amazon ECR + id: build-image + env: + IMAGE_TAG: lastest + run: | + + + docker build -t $ECR_REPOSITORY:$IMAGE_TAG ./frontend + + docker push $ECR_REPOSITORY:$IMAGE_TAG + + echo "image=$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT + + - name: Checkout repository + uses: actions/checkout@v2 + + + deploy_backend: + runs-on: ubuntu-latest + needs: build_image_backend + steps: + - 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: ${{ env.AWS_REGION }} + + - name: Deploy to ECS + run: | + aws ecs update-service --cluster ${{ env.ECS_CLUSTER }} --service ${{ env.ECS_SERVICE }} --force-new-deployment \ No newline at end of file diff --git a/.gitignore b/.gitignore index 736036e..298edd3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /model/dataset/archive/Brain Tumor Data Set/Brain Tumor Data Set/Brain Tumor /model/dataset/archive/Brain Tumor Data Set/Brain Tumor Data Set/Healthy +.pnpm*/ /model/resource /backend/__pycache__ /backend/.pytest_cache @@ -8,4 +9,5 @@ /backend/test/__pycache__ /backend/key/settings_token.pkl /model/gemini-model-build.ipynb -/backend/.env \ No newline at end of file +/backend/.env +/backend/venv diff --git a/backend/.dockerignore b/backend/.dockerignore new file mode 100644 index 0000000..4745e04 --- /dev/null +++ b/backend/.dockerignore @@ -0,0 +1,5 @@ +venv +__pycache__ +Dockerfile +.dockerignore +.gitignore diff --git a/backend/Dockerfile b/backend/Dockerfile index e1fe4a3..3ad696a 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,17 +1,11 @@ -FROM python:3.9-slim +# Slim image as builder base +FROM python:3.12.3-slim WORKDIR /app - COPY requirements.txt . - - -RUN pip install --upgrade pip setuptools - - -RUN pip install -r requirements.txt - +RUN pip install --upgrade pip setuptools \ + && pip install --no-cache -r requirements.txt COPY . . - EXPOSE 8000 CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"] diff --git a/frontend/.dockerignore b/frontend/.dockerignore new file mode 100644 index 0000000..8c90a74 --- /dev/null +++ b/frontend/.dockerignore @@ -0,0 +1,7 @@ +.eslintrc.cjs +node_modules/ +package-lock.json +pnpm-lock.json +.prettierrc +.gitignore +README.md diff --git a/frontend/index.html b/frontend/index.html index fe4dd77..28bcb37 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -2,7 +2,7 @@
- +