From 21ee6a011064661d0675b2736c295ce831e48839 Mon Sep 17 00:00:00 2001 From: Vijay-J0shi Date: Fri, 25 Apr 2025 22:21:13 +0530 Subject: [PATCH 1/4] continious Deployment testing --- .github/workflows/cd.yml | 22 ++++++++++++++++++++ .github/workflows/{python-app.yml => ci.yml} | 16 +++++++++----- .gitignore | 3 ++- testing.py | 10 ++++----- 4 files changed, 39 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/cd.yml rename .github/workflows/{python-app.yml => ci.yml} (72%) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000..611e83e --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,22 @@ + +name: Continious Deployment + +on: + workflow_run: + workflows: ["Continious Integration"] + types: + - completed + +jobs: + build: + + runs-on: self-hosted + + steps: + - name: pull Docker image + run: sudo docker pull vijayj0shi/remx_api:latest + - name: Delete Old docker container + run: sudo docker rm -f remx_api-container ||true + - name: Run Docker Container + run: sudo docker run -d -p 8080:8080 --name remx_api-container vijayj0shi/remx_api + diff --git a/.github/workflows/python-app.yml b/.github/workflows/ci.yml similarity index 72% rename from .github/workflows/python-app.yml rename to .github/workflows/ci.yml index 703d639..a15ff4b 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/ci.yml @@ -1,17 +1,13 @@ # This workflow will install Python dependencies, run tests and lint with a single version of Python # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python -name: Python application +name: Continious Integration on: push: branches: [ "main" ] pull_request: branches: [ "main" ] - -permissions: - contents: read - jobs: build: @@ -34,4 +30,14 @@ jobs: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Login Dockerhub + env: + DOCKER_USERNAME: ${{secrets.DOCKERHUB_USERNAME}} + DOCKER_PASSWORD: ${{secrets.DOCKERHUB_PASSWORD}} + run: docker login -u $DOCKER_USERNAME -P$DOCKER_PASSWORD + + - name: Build the Docker image + run: docker build -t vijayj0shi/remx_api . + - name: push Docker image + run: docker push vijayj0shi/remx_api:latest diff --git a/.gitignore b/.gitignore index 72a343c..755d886 100644 --- a/.gitignore +++ b/.gitignore @@ -50,7 +50,7 @@ coverage.xml .hypothesis/ .pytest_cache/ cover/ -testing.py + # Translations *.mo *.pot @@ -141,6 +141,7 @@ myenv.bak/ # mkdocs documentation /site +testing.py # mypy .mypy_cache/ .dmypy.json diff --git a/testing.py b/testing.py index f223fb6..b53f309 100644 --- a/testing.py +++ b/testing.py @@ -7,12 +7,10 @@ print(model) -# path = os.path.join("tests","tst.zip") -# files =[("files", open(path, "rb"))] +path = os.path.join("tests","tst.zip") +files =[("files", open(path, "rb"))] -# response = requests.post("http://127.0.0.1:8000/api/predict/upload", files=files) +response = requests.post("http://127.0.0.1:8000/api/predict/upload", files=files) -# # Check response - -# print(response.json()) \ No newline at end of file +print(response.json()) \ No newline at end of file From 8ec1ea75223632d41b90bb85c9046695bbe4601f Mon Sep 17 00:00:00 2001 From: Vijay-J0shi Date: Fri, 25 Apr 2025 22:23:56 +0530 Subject: [PATCH 2/4] continious Deployment testing --- .github/workflows/cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 611e83e..2de2904 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -16,7 +16,7 @@ jobs: - name: pull Docker image run: sudo docker pull vijayj0shi/remx_api:latest - name: Delete Old docker container - run: sudo docker rm -f remx_api-container ||true + run: sudo docker rm -f remx_api-container || true - name: Run Docker Container run: sudo docker run -d -p 8080:8080 --name remx_api-container vijayj0shi/remx_api From 3b41a1767b8e1d7e707ef7f939a4fc49f3f1585e Mon Sep 17 00:00:00 2001 From: Vijay-J0shi Date: Fri, 25 Apr 2025 22:42:27 +0530 Subject: [PATCH 3/4] cicd error fix --- .github/workflows/cd.yml | 4 ++-- .github/workflows/ci.yml | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 2de2904..e7271fa 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -1,9 +1,9 @@ -name: Continious Deployment +name: Continuous Deployment on: workflow_run: - workflows: ["Continious Integration"] + workflows: ["Continuous Integration"] types: - completed diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a15ff4b..744b275 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,7 +1,7 @@ # This workflow will install Python dependencies, run tests and lint with a single version of Python # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python -name: Continious Integration +name: Continuous Integration on: push: @@ -30,11 +30,11 @@ jobs: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Login Dockerhub + - name: Login to Docker Hub env: - DOCKER_USERNAME: ${{secrets.DOCKERHUB_USERNAME}} - DOCKER_PASSWORD: ${{secrets.DOCKERHUB_PASSWORD}} - run: docker login -u $DOCKER_USERNAME -P$DOCKER_PASSWORD + DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} + run: echo "${{ secrets.DOCKERHUB_PASSWORD }}" | docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin - name: Build the Docker image run: docker build -t vijayj0shi/remx_api . From f8e0bd464a2996eef9cf35dbb87975bb4ed4f635 Mon Sep 17 00:00:00 2001 From: Vijay-J0shi Date: Fri, 25 Apr 2025 22:45:20 +0530 Subject: [PATCH 4/4] trying to fix docker login issue --- .github/workflows/ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 744b275..69c5f25 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,14 +30,14 @@ jobs: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Login to Docker Hub + - name: Login Dockerhub env: - DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} - run: echo "${{ secrets.DOCKERHUB_PASSWORD }}" | docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin + DOCKER_USERNAME: ${{secrets.DOCKERHUB_USERNAME}} + DOCKER_PASSWORD: ${{secrets.DOCKERHUB_PASSWORD}} + run: docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD - name: Build the Docker image - run: docker build -t vijayj0shi/remx_api . + run: docker build -t vijayj0shi/remx_api:latest . - name: push Docker image run: docker push vijayj0shi/remx_api:latest