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
53 changes: 53 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: React-app-mulearn Native Deploy Pipeline

on:
push:
branches: ["task-3"]

# Specific permissions for deploying directly to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Prevent redundant builds from running at the same time and crashing into each other
concurrency:
group: "pages" # this is used to group the builds together.
cancel-in-progress: true # this is used to cancel the previous build if a new build is started.

jobs:
deploy:
# Here the enviornment is set to github-pages. This is needed because it automatically gives us that nice link in the Actions tab.
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

runs-on: ubuntu-latest
steps:
- name: move code to Runner
uses: actions/checkout@v4

- name: Setup Node (because its a react app)
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install dependencies (npm i)
run: npm install
working-directory: ./sharonshaji-1@mulearn/Task-3

- name: Build the app (npm run build)
run: npm run build
working-directory: ./sharonshaji-1@mulearn/Task-3

- name: Setup GitHub Pages natively # This is needed to deploy the app directly to the GitHub Pages environment. earlier we used to do this manually by going to settings and enabling GitHub Pages. Now we can do it directly from the workflow.
uses: actions/configure-pages@v4 # The permissions we gave at the top are used here.

- name: Upload the dist folder as an artifact # This takes everything Vite outputs and bundles it into a zip package
uses: actions/upload-pages-artifact@v3
with:
path: './sharonshaji-1@mulearn/Task-3/dist' # This is the folder that contains the built app.

- name: Deploy the artifact directly to the GitHub Pages environment # This is the final step that deploys the app to the GitHub Pages environment.
id: deployment
uses: actions/deploy-pages@v4
2 changes: 2 additions & 0 deletions sharonshaji-1@mulearn/FinalProject/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM nginx:alpine
COPY index.html /usr/share/nginx/html/index.html
31 changes: 31 additions & 0 deletions sharonshaji-1@mulearn/FinalProject/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: docker-x-k8s
#spec : what k8s should do
spec:
replicas: 3
selector:
# Deployment selector tells Kubernetes which pods belong to this Deployment
matchLabels:
app: simple-web-app
# template acts as a blueprint for the pods
template:
metadata:
labels:
app: simple-web-app
# pod's own spec - what pods do
spec:
containers:
# container name inside the pod - a simple label used by k8s to identify the container
- name: web-app
# the name of the image created using dockerfile
image: web-app:v1
# since using kind, the image is pulled locally, if not found try to download it.
imagePullPolicy: IfNotPresent
# declares the port the container listens on.
ports:
- containerPort: 80
env:
- name: STUDENT_NAME
value: "sharon"
47 changes: 47 additions & 0 deletions sharonshaji-1@mulearn/FinalProject/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>docker x k8s</title>
<style>
* {
margin:0;
padding:0;
box-sizing: border-box;
}
body {
font-family: Arial, sans-serif;
background: #f4f4f4;
display: grid;
place-items: center;
height: 100vh;
position: relative;
}
.card {
display: inherit;
place-items: center;
border: 1px solid #000;
background: white;
padding: 2rem 3rem;
border-radius: 12px;
box-shadow: 8px 8px 0px rgba(0,0,0);
text-align: center;
}
img {
display: block;
margin-bottom: 1rem;
}
p {
color: #555;
}
</style>
</head>
<body>
<div class="card">
<img src="https://media.tenor.com/jfqBMAeIcZ8AAAAM/cool-fun.gif" />
<p>Running with Docker + Kubernetes</p>
<p>Name : Sharon Shaji</p>
</div>
</body>
</html>
8 changes: 8 additions & 0 deletions sharonshaji-1@mulearn/FinalProject/kind-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
extraPortMappings:
- containerPort: 30080
hostPort: 30080
protocol: TCP
13 changes: 13 additions & 0 deletions sharonshaji-1@mulearn/FinalProject/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: docker-x-k8s-service
spec:
type: NodePort
selector:
app: simple-web-app
ports:
- protocol: TCP
port: 80
targetPort: 80
nodePort: 30080
10 changes: 10 additions & 0 deletions sharonshaji-1@mulearn/Task-2/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM python:3.12-slim
#base image

WORKDIR /app
#working dir inside container.

COPY script.py .
#move the script to /app in container

CMD ["python", "-u", "script.py"]
7 changes: 7 additions & 0 deletions sharonshaji-1@mulearn/Task-2/script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import time

print("🚀 Container Started")

while True:
print("Hello World")
time.sleep(5)
24 changes: 24 additions & 0 deletions sharonshaji-1@mulearn/Task-3/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
16 changes: 16 additions & 0 deletions sharonshaji-1@mulearn/Task-3/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# React + Vite

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Currently, two official plugins are available:

- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Oxc](https://oxc.rs)
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/)

## React Compiler

The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).

## Expanding the ESLint configuration

If you are developing a production application, we recommend using TypeScript with type-aware lint rules enabled. Check out the [TS template](https://github.com/vitejs/vite/tree/main/packages/create-vite/template-react-ts) for information on how to integrate TypeScript and [`typescript-eslint`](https://typescript-eslint.io) in your project.
29 changes: 29 additions & 0 deletions sharonshaji-1@mulearn/Task-3/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import js from '@eslint/js'
import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import { defineConfig, globalIgnores } from 'eslint/config'

export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{js,jsx}'],
extends: [
js.configs.recommended,
reactHooks.configs.flat.recommended,
reactRefresh.configs.vite,
],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
parserOptions: {
ecmaVersion: 'latest',
ecmaFeatures: { jsx: true },
sourceType: 'module',
},
},
rules: {
'no-unused-vars': ['error', { varsIgnorePattern: '^[A-Z_]' }],
},
},
])
13 changes: 13 additions & 0 deletions sharonshaji-1@mulearn/Task-3/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>task-3</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.jsx"></script>
</body>
</html>
Loading