diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml new file mode 100644 index 000000000..5f9489f08 --- /dev/null +++ b/.github/workflows/ci-cd.yml @@ -0,0 +1,55 @@ +name: Build and Deploy + +on: + push: + branches: + - main # or any other branch you want to trigger the workflow + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: priyanshiorufy + password: orufy@123 + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: priyanshiorufy/wisecow-app:latest + + deploy: + needs: build + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Install kubectl + run: | + sudo apt-get update + sudo apt-get install -y kubectl + + - name: Configure kubectl + env: + KUBECONFIG_DATA: ${{ secrets.KUBECONFIG }} + run: | + mkdir -p $HOME/.kube + echo "${KUBECONFIG}" | base64 --decode > $HOME/.kube/config + + - name: Deploy to Kubernetes + run: | + kubectl set image deployment/wisecow-deployment wisecow-deployment=priyannshiorufy/wisecow-app:latest + kubectl rollout status deployment/wisecow-deployment diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..9452afc1a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +# Use the official Alpine image from the Docker Hub +FROM alpine:latest + +# Install necessary packages +RUN apk add --no-cache bash + +# Set the working directory in the container +WORKDIR /app + +# Copy the script into the container +COPY wisecow.sh . + +# Give execution rights to the script +RUN chmod +x wisecow.sh + +# Specify the command to run the script +CMD ["./wisecow.sh"] diff --git a/k8s/cert-manager.yaml b/k8s/cert-manager.yaml new file mode 100644 index 000000000..df6419a8e --- /dev/null +++ b/k8s/cert-manager.yaml @@ -0,0 +1,14 @@ +apiVersion: cert-manager.io/v1 +kind: ClusterIssuer +metadata: + name: letsencrypt +spec: + acme: + server: https://acme-v02.api.letsencrypt.org/directory + email: priyanshinair.work@gmail.com + privateKeySecretRef: + name: letsencrypt + solvers: + - http01: + ingress: + class: nginx diff --git a/k8s/deployment.yaml b/k8s/deployment.yaml new file mode 100644 index 000000000..da08b65d7 --- /dev/null +++ b/k8s/deployment.yaml @@ -0,0 +1,19 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: wisecow-deployment +spec: + replicas: 2 + selector: + matchLabels: + app: wisecow + template: + metadata: + labels: + app: wisecow + spec: + containers: + - name: wisecow + image: priyanshiorufy/wisecow:latest + ports: + - containerPort: 80 diff --git a/k8s/index.js b/k8s/index.js new file mode 100644 index 000000000..8b10ffe04 --- /dev/null +++ b/k8s/index.js @@ -0,0 +1,3 @@ +ChannelMergerNode +nothing +ok \ No newline at end of file diff --git a/k8s/ingress.yaml b/k8s/ingress.yaml new file mode 100644 index 000000000..5afc79c18 --- /dev/null +++ b/k8s/ingress.yaml @@ -0,0 +1,22 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: wisecow-ingress + annotations: + cert-manager.io/cluster-issuer: "letsencrypt" +spec: + tls: + - hosts: + - example.com + secretName: wisecow-tls + rules: + - host: example.com + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: wisecow-service + port: + number: 80 diff --git a/k8s/service.yaml b/k8s/service.yaml new file mode 100644 index 000000000..c311483ec --- /dev/null +++ b/k8s/service.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: wisecow-service +spec: + type: LoadBalancer + ports: + - port: 80 + targetPort: 80 + selector: + app: wisecow