Skip to content

Commit

Permalink
feat: Initialize the project
Browse files Browse the repository at this point in the history
  • Loading branch information
dinushchathurya committed Jun 7, 2023
0 parents commit 217d6ca
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/deploy-to-minikube-github-actions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Deploy to Minikube using GitHub Actions

on: [push]

jobs:
job1:
runs-on: ubuntu-latest
name: build Node.js Docker Image and deploy to minikube
steps:
- uses: actions/checkout@v2
- name: Start minikube
uses: medyagh/setup-minikube@master
- name: Try the cluster !
run: kubectl get pods -A
- name: Build image
run: |
export SHELL=/bin/bash
eval $(minikube -p minikube docker-env)
docker build -f ./Dockerfile -t devopshint/node-app:latest .
echo -n "verifying images:"
docker images
- name: Deploy to minikube
run:
kubectl apply -f k8s-node-app.yaml
- name: Test service URLs
run: |
minikube service list
minikube service nodejs-app --url
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM node:14
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
RUN npm install express
COPY . .
EXPOSE 3000
CMD [ "node", "server.js" ]
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# deploy-to-minikube-using-github-actions
Deploy to Minikube using GitHub Actions
37 changes: 37 additions & 0 deletions k8s-node-app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
kind: Deployment
apiVersion: apps/v1
metadata:
name: nodejs-app
namespace: default
labels:
app: nodejs-app
spec:
replicas: 1
selector:
matchLabels:
app: nodejs-app
template:
metadata:
labels:
app: nodejs-app
spec:
containers:
- name: nodejs-app
image: "devopshint/node-app:latest"
ports:
- containerPort: 3000
---
apiVersion: v1
kind: Service
metadata:
name: nodejs-app
namespace: default
spec:
selector:
app: nodejs-app
type: NodePort
ports:
- name: http
targetPort: 3000
port: 80
13 changes: 13 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "docker_web_app",
"version": "1.0.0",
"description": "Node.js on Docker",
"author": "First Last <first.last@example.com>",
"main": "server.js",
"scripts": {
"start": "node server.js"
},
"dependencies": {
"express": "^4.16.1"
}
}
16 changes: 16 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'use strict';

const express = require('express');

// Constants
const PORT = 3000;
const HOST = '0.0.0.0';

// App
const app = express();
app.get('/', (req, res) => {
res.send('Hello World');
});

app.listen(PORT, HOST);
console.log(`Running on http://${HOST}:${PORT}`);

0 comments on commit 217d6ca

Please sign in to comment.