diff --git a/.github/workflows/docker-ci.yml b/.github/workflows/docker-ci.yml new file mode 100644 index 0000000..391a928 --- /dev/null +++ b/.github/workflows/docker-ci.yml @@ -0,0 +1,61 @@ +name: Docker CI Pipeline +run-name: ${{ github.actor }} is running our Docker CI Pipeline 🚀 + +on: + push: + +jobs: + hello-world-job: + runs-on: ubuntu-latest + steps: + - name: Clone the code + uses: actions/checkout@v4 + + - name: Build the image + run: docker build -t ${{ vars.DOCKERHUB_USERNAME }}/helloworld-demo-python:v4 . + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ vars.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Push the image + run: docker push ${{ vars.DOCKERHUB_USERNAME }}/helloworld-demo-python:v4 + + - name: Run the container + run: docker run --name helloworld-demo-python -itd -p 8080:8080 ${{ vars.DOCKERHUB_USERNAME }}/helloworld-demo-python:v4 + + - name: View the container + run: docker ps + + k8s-implementation: + needs: hello-world-job + runs-on: ubuntu-latest + steps: + - name: Clone the code + uses: actions/checkout@v4 + + - name: Start minikube + uses: medyagh/setup-minikube@latest + + - name: Try the cluster + run: kubectl get pods -A + + - name: Create Deployment and Service + run: | + kubectl apply -f K8s/deployment.yaml + kubectl apply -f K8s/services.yaml + kubectl wait --for=condition=ready pod -l app=hello-world-python + + - name: View Deployment and Service + run: | + kubectl get deployments + kubectl get service + + - name: Test service URLs + run: | + minikube service list + minikube service hello-world-service --url + echo "------------------opening the service------------------" + curl "$(minikube service hello-world-service --url)" diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..cbf67a7 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM python:3.14.2-alpine3.22 +LABEL version="1.0" +MAINTAINER Vijayraj +ENV MY_APP="hello-world-python" +RUN mkdir /app +WORKDIR /app +COPY . /app +EXPOSE 8080 +CMD ["python3", "app.py"] diff --git a/app.py b/app.py index d3725f0..ab959e6 100644 --- a/app.py +++ b/app.py @@ -16,7 +16,7 @@ def do_GET(self): \____\_______/ -Hello from Docker! +Hello from Docker! - Vijayraj ''') def run():