Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
14 changes: 14 additions & 0 deletions k8s/cert-manager.yaml
Original file line number Diff line number Diff line change
@@ -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
19 changes: 19 additions & 0 deletions k8s/deployment.yaml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions k8s/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ChannelMergerNode
nothing
ok
22 changes: 22 additions & 0 deletions k8s/ingress.yaml
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions k8s/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: wisecow-service
spec:
type: LoadBalancer
ports:
- port: 80
targetPort: 80
selector:
app: wisecow