diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index f4ec832..acca1eb 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -147,13 +147,23 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up Minikube - uses: manuel-packeisen/setup-minikube@v2.0.0 - with: - minikube version: 'latest' - kubernetes version: 'v1.28.0' - driver: 'docker' - start args: '--cpus=2 --memory=4g --disk-size=20g' + - name: Install Minikube + run: | + curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 + chmod +x minikube + sudo mv minikube /usr/local/bin/ + + - name: Start Minikube + run: | + minikube start --driver=docker + + # - name: Set up Minikube + # uses: manuel-packeisen/setup-minikube@v1.35.0 + # with: + # minikube version: 'latest' + # kubernetes version: 'v1.28.0' + # driver: 'docker' + # start args: '--cpus=2 --memory=4g --disk-size=20g' - name: Configure kubectl run: | @@ -176,12 +186,20 @@ jobs: minikube kubectl -- rollout status deployment/spreadsheet-app -n spreadsheet-app # Get the service URL and test the application - SERVICE_URL=$(minikube service spreadsheet-app -n spreadsheet-app --url) + SERVICE_URL=$(minikube service spreadsheet-app-service -n spreadsheet-app --url) echo "Waiting for service to be available..." - until curl -f $SERVICE_URL/health; do + MAX_WAIT=60 # Wait for max 60 seconds + WAITED=0 + until curl -f $SERVICE_URL/health || [ $WAITED -ge $MAX_WAIT ]; do echo "Service not ready yet, waiting..." sleep 5 + WAITED=$((WAITED + 5)) done + + if [ $WAITED -ge $MAX_WAIT ]; then + echo "ERROR: Service did not become available in time" + exit 1 + fi echo "Application is available at: $SERVICE_URL" @@ -192,7 +210,6 @@ jobs: minikube kubectl -- logs deployment/spreadsheet-app -n spreadsheet-app # Verify service is accessible - curl -f $SERVICE_URL/health || exit 1 # Optional: Run additional tests against the deployed application # Example: curl -f $SERVICE_URL/api/endpoint || exit 1 \ No newline at end of file diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml deleted file mode 100644 index 20954e0..0000000 --- a/.github/workflows/docker-build.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: Docker Build and Push - -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - -jobs: - build-and-push: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Debug Secrets - run: | - echo "Docker Hub Username: ${{ secrets.DOCKERHUB_USERNAME }}" - echo "Docker Hub Token exists: ${{ secrets.DOCKERHUB_TOKEN != '' }}" - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - registry: docker.io - - - name: Build and push - uses: docker/build-push-action@v4 - with: - context: . - push: true - tags: ${{ secrets.DOCKERHUB_USERNAME }}/spreadsheet-app:latest \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 302027e..0dc62f6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -36,6 +36,7 @@ EXPOSE 5000 # Set environment variables ENV FLASK_APP=backend/app.py ENV FLASK_ENV=production +ENV PYTHONPATH=/app # Start the application CMD ["python", "backend/app.py"] \ No newline at end of file