From 6684f22f7feea265282feb2ea16eb28fcac8c3bb Mon Sep 17 00:00:00 2001 From: muzammil360 Date: Fri, 10 Nov 2023 17:04:27 +0500 Subject: [PATCH 01/10] Add cd.yml and dockerfile --- .github/workflows/api-cd.yml | 28 ++++++++++++++++++++++++++++ api/Dockerfile | 10 ++++++++++ 2 files changed, 38 insertions(+) create mode 100644 .github/workflows/api-cd.yml create mode 100644 api/Dockerfile diff --git a/.github/workflows/api-cd.yml b/.github/workflows/api-cd.yml new file mode 100644 index 0000000..8db87ca --- /dev/null +++ b/.github/workflows/api-cd.yml @@ -0,0 +1,28 @@ +name: Docker CI/CD + +on: + push: + branches: + - 'muz/add-cd-pipeline' + +env: + WORKING_DIR: ./api + +jobs: + build-and-push: + runs-on: ubuntu-latest + defaults: + run: + shell: bash + working-directory: ${{ env.WORKING_DIR }} + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Login to Docker Hub + run: docker login -u ${{ secrets.DOCKERHUB_PUSH_TOKEN }} -p ${{ secrets.DOCKERHUB_PUSH_TOKEN }} + + - name: Build and push Docker image + run: | + docker build -t muzammil360/ml-kubernetes/api:latest . + docker push muzammil360/ml-kubernetes/api:latest diff --git a/api/Dockerfile b/api/Dockerfile new file mode 100644 index 0000000..9dd6578 --- /dev/null +++ b/api/Dockerfile @@ -0,0 +1,10 @@ +FROM python:3.8 + +WORKDIR /app + +COPY . /app + +RUN pip install --no-cache-dir -r requirements.txt +RUN python download_weights.py + +CMD ["uvicorn","server:app"] From 5db0c3a4e0c17980bf2da2822383a8eb6eb06a0b Mon Sep 17 00:00:00 2001 From: muzammil360 Date: Fri, 10 Nov 2023 17:05:07 +0500 Subject: [PATCH 02/10] update python base docker --- api/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/Dockerfile b/api/Dockerfile index 9dd6578..b8fa7d8 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.8 +FROM python:3.8-alpine WORKDIR /app From 49199fb57b611a098b525222d10e407272f4410f Mon Sep 17 00:00:00 2001 From: muzammil360 Date: Fri, 10 Nov 2023 17:08:26 +0500 Subject: [PATCH 03/10] update docker login command --- .github/workflows/api-cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/api-cd.yml b/.github/workflows/api-cd.yml index 8db87ca..2bea339 100644 --- a/.github/workflows/api-cd.yml +++ b/.github/workflows/api-cd.yml @@ -20,7 +20,7 @@ jobs: uses: actions/checkout@v2 - name: Login to Docker Hub - run: docker login -u ${{ secrets.DOCKERHUB_PUSH_TOKEN }} -p ${{ secrets.DOCKERHUB_PUSH_TOKEN }} + run: echo "${{ secrets.DOCKERHUB_PUSH_TOKEN }}" | docker login -u muzammil360 --password-stdin - name: Build and push Docker image run: | From d2a82adce57765febf1f1d3b9d3f9dbe16d1f479 Mon Sep 17 00:00:00 2001 From: muzammil360 Date: Fri, 10 Nov 2023 17:09:37 +0500 Subject: [PATCH 04/10] update cicd names --- .github/workflows/api-cd.yml | 2 +- .github/workflows/api-ci.yml | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/api-cd.yml b/.github/workflows/api-cd.yml index 2bea339..f89bb68 100644 --- a/.github/workflows/api-cd.yml +++ b/.github/workflows/api-cd.yml @@ -1,4 +1,4 @@ -name: Docker CI/CD +name: API-CD on: push: diff --git a/.github/workflows/api-ci.yml b/.github/workflows/api-ci.yml index 9899afc..202dabe 100644 --- a/.github/workflows/api-ci.yml +++ b/.github/workflows/api-ci.yml @@ -1,4 +1,4 @@ -name: Python application +name: API-CI on: pull_request: @@ -11,7 +11,6 @@ env: jobs: build: - runs-on: ubuntu-latest defaults: run: From 7ecc5d50d49961ae8153338e23341cb355a66ffb Mon Sep 17 00:00:00 2001 From: muzammil360 Date: Fri, 10 Nov 2023 17:11:50 +0500 Subject: [PATCH 05/10] update docker file --- api/Dockerfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/api/Dockerfile b/api/Dockerfile index b8fa7d8..33130ed 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -1,10 +1,12 @@ FROM python:3.8-alpine WORKDIR /app +RUN pip install --upgrade pip -COPY . /app - +COPY requirements.txt /app/requirements.txt RUN pip install --no-cache-dir -r requirements.txt + +COPY . /app RUN python download_weights.py CMD ["uvicorn","server:app"] From f26877c8c49a56961dbcb58fa9189a075350da40 Mon Sep 17 00:00:00 2001 From: muzammil360 Date: Fri, 10 Nov 2023 18:03:24 +0500 Subject: [PATCH 06/10] using slim python --- api/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/Dockerfile b/api/Dockerfile index 33130ed..620085f 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -1,9 +1,9 @@ -FROM python:3.8-alpine +FROM python:3.8-slim WORKDIR /app RUN pip install --upgrade pip -COPY requirements.txt /app/requirements.txt +COPY requirements.txt requirements.txt RUN pip install --no-cache-dir -r requirements.txt COPY . /app From 1b2416bac79bea26eafa75bbaf8830c098653437 Mon Sep 17 00:00:00 2001 From: muzammil360 Date: Fri, 10 Nov 2023 18:03:37 +0500 Subject: [PATCH 07/10] using slim python --- api/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/Dockerfile b/api/Dockerfile index 620085f..2589b41 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -3,7 +3,7 @@ FROM python:3.8-slim WORKDIR /app RUN pip install --upgrade pip -COPY requirements.txt requirements.txt +COPY requirements.txt /app/ RUN pip install --no-cache-dir -r requirements.txt COPY . /app From 4d96687bec8fe889460e1440808d488ee28df787 Mon Sep 17 00:00:00 2001 From: muzammil360 Date: Fri, 10 Nov 2023 18:06:02 +0500 Subject: [PATCH 08/10] update cd pipeline --- .github/workflows/api-cd.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/api-cd.yml b/.github/workflows/api-cd.yml index f89bb68..6d45730 100644 --- a/.github/workflows/api-cd.yml +++ b/.github/workflows/api-cd.yml @@ -19,10 +19,11 @@ jobs: - name: Checkout code uses: actions/checkout@v2 - - name: Login to Docker Hub - run: echo "${{ secrets.DOCKERHUB_PUSH_TOKEN }}" | docker login -u muzammil360 --password-stdin + # - name: Login to Docker Hub + # run: echo "${{ secrets.DOCKERHUB_PUSH_TOKEN }}" | docker login -u muzammil360 --password-stdin - - name: Build and push Docker image + - name: Login, Build and push Docker image run: | + echo "${{ secrets.DOCKERHUB_PUSH_TOKEN }}" | docker login -u muzammil360 --password-stdin docker build -t muzammil360/ml-kubernetes/api:latest . docker push muzammil360/ml-kubernetes/api:latest From dd6df2a56cf52ffbea3d825f162284cf9466c356 Mon Sep 17 00:00:00 2001 From: muzammil360 Date: Fri, 10 Nov 2023 18:08:43 +0500 Subject: [PATCH 09/10] update docker name --- .github/workflows/api-cd.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/api-cd.yml b/.github/workflows/api-cd.yml index 6d45730..4b4521c 100644 --- a/.github/workflows/api-cd.yml +++ b/.github/workflows/api-cd.yml @@ -25,5 +25,5 @@ jobs: - name: Login, Build and push Docker image run: | echo "${{ secrets.DOCKERHUB_PUSH_TOKEN }}" | docker login -u muzammil360 --password-stdin - docker build -t muzammil360/ml-kubernetes/api:latest . - docker push muzammil360/ml-kubernetes/api:latest + docker build -t muzammil360/ml-kubernetes:latest . + docker push muzammil360/ml-kubernetes:latest From 40ceeee153421aafc3c4b296a5169af905926732 Mon Sep 17 00:00:00 2001 From: muzammil360 Date: Mon, 13 Nov 2023 16:20:57 +0500 Subject: [PATCH 10/10] update --- .github/workflows/api-cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/api-cd.yml b/.github/workflows/api-cd.yml index 4b4521c..34c2cc3 100644 --- a/.github/workflows/api-cd.yml +++ b/.github/workflows/api-cd.yml @@ -3,7 +3,7 @@ name: API-CD on: push: branches: - - 'muz/add-cd-pipeline' + - 'main' env: WORKING_DIR: ./api