From 7b31efd4f5659db281e8e9b7f6423c6936f74d28 Mon Sep 17 00:00:00 2001 From: Soham Date: Wed, 2 Oct 2024 17:49:36 +0530 Subject: [PATCH] fix --- .github/workflows/build-and-run.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-run.yml b/.github/workflows/build-and-run.yml index 41ca6d0..47fd26f 100644 --- a/.github/workflows/build-and-run.yml +++ b/.github/workflows/build-and-run.yml @@ -14,5 +14,11 @@ jobs: - uses: actions/checkout@v4 - name: Build the Docker image run: sudo docker build -t backend . + - name: Stop and remove existing container if it exists + run: | + if [ "$(sudo docker ps -aq -f name=backend)" ]; then + sudo docker stop backend + sudo docker rm backend + fi - name: Run the Docker container on port 8000 - run: sudo docker stop backend && sudo docker run -d -p 8000:8000 backend + run: sudo docker run -d -p 8000:8000 backend