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
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
USER=KALISA
PASS=1234
154 changes: 154 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
name: CI

on:
pull_request:
branches:
- innox-edits
- main
- master

push:
branches:
- innox-edits
- main
- master

jobs:

# ==========================================================
# 1. BUILD
# ==========================================================
build:
name: Build application
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm

- name: Install dependencies
run: npm ci

- name: Check application syntax
run: node --check index.js

- name: Build application
run: npm run build --if-present


# ==========================================================
# 2. TESTS
# ==========================================================
test:
name: Run tests
needs: build
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm

- name: Install dependencies
run: npm ci

- name: Run tests
run: npm test


# ==========================================================
# 3. VULNERABILITY SCAN
# ==========================================================
vulnerability-scan:
name: Vulnerability scan
needs: test
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm

- name: Install dependencies
run: npm ci

- name: Run npm vulnerability scan
run: npm audit --audit-level=high


# ==========================================================
# 4. DOCKER BUILD + PUSH
# Only after code is pushed/merged to the target branch
# ==========================================================
docker:
name: Build and push Docker image
needs:
- build
- test
- vulnerability-scan

# Don't push Docker images from pull requests
if: github.event_name == 'push'

runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build Docker image
run: |
docker build \
-t ${{ secrets.DOCKER_USERNAME }}/my-demo-repo:${{ github.sha }} .

- name: Push Docker image
run: |
docker push \
${{ secrets.DOCKER_USERNAME }}/my-demo-repo:${{ github.sha }}


# ==========================================================
# 5. HELM
# ==========================================================
helm:
name: Validate Helm chart
needs: build
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Helm
uses: azure/setup-helm@v4

- name: Check Helm
run: helm version

- name: Lint Helm chart
run: helm lint ./web-app

- name: Render Helm templates
run: helm template web-app ./web-app
41 changes: 41 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Release

on:
push:
tags:
- 'v*'

jobs:
docker:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Get version
run: echo "VERSION=${GITHUB_REF_NAME}" >> $GITHUB_ENV

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build Docker image
run: |
docker build \
-t ${{ secrets.DOCKER_USERNAME }}/my-demo-repo:${VERSION} .

# - name: Vulnerability scan
# uses: aquasecurity/trivy-action@0.28.0
# with:
# image-ref: ${{ secrets.DOCKER_USERNAME }}/my-demo-repo:${{ env.VERSION }}
# severity: CRITICAL,HIGH
# exit-code: '1'
# ignore-unfixed: true

- name: Push Docker image
run: |
docker push \
${{ secrets.DOCKER_USERNAME }}/my-demo-repo:${VERSION}
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@
"titleBar.inactiveBackground": "#cf6d2899",
"titleBar.inactiveForeground": "#15202b99"
},
"peacock.color": "#cf6d28"
"peacock.color": "#cf6d28",
"workbench.colorTheme": "Dark 2026",
"window.autoDetectColorScheme": false
}
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Use an official lightweight Node.js image
FROM node:20-alpine

# Set the working directory inside the container
WORKDIR /app

# Copy package files first to leverage Docker's cache layer
COPY package*.json ./

# Install only production dependencies
RUN npm ci --only=production

# Copy the remaining application source code
COPY . .

# Expose the port your app listens on (e.g., 3000)
EXPOSE 3000

# Start the application
CMD ["node", "index.js"]
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

Simple node.js app that servers "hello world"


# INNOX Edits

I just editted README.md in my forked repo.

Great for testing simple deployments to the cloud

## Run It
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const port = process.env.PORT || 3000;

const server = http.createServer((req, res) => {
res.statusCode = 200;
const msg = 'Hello Node!\n'
const msg = 'Hello Node!\n This is another version 2'
res.end(msg);
});

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"description": "",
"main": "index.js",
"scripts": {
"start": "node index.js"
"start": "node index.js",
"test": "echo \"Error: Test passed\""
},
"repository": {
"type": "git",
Expand Down
6 changes: 6 additions & 0 deletions web-app/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: web-app
description: My first Helm chart for a Kubernetes web application
type: application
version: 0.1.0
appVersion: "1.0"
10 changes: 10 additions & 0 deletions web-app/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: ConfigMap

metadata:
name: {{ .Release.Name }}-config

data:
APP_NAME: {{ .Values.config.APP_NAME | quote }}
ENVIRONMENT: {{ .Values.config.ENVIRONMENT | quote }}
LOG_LEVEL: {{ .Values.config.LOG_LEVEL | quote }}
80 changes: 80 additions & 0 deletions web-app/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
apiVersion: apps/v1
kind: Deployment

metadata:
name: {{ .Release.Name }}-web-app

labels:
app: web-app

spec:
replicas: {{ .Values.replicaCount }}

selector:
matchLabels:
app: web-app

template:
metadata:
labels:
app: web-app

spec:
containers:
- name: web-app

image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"

imagePullPolicy: {{ .Values.image.pullPolicy }}

ports:
- containerPort: 3000

envFrom:
- configMapRef:
name: {{ .Release.Name }}-config

- secretRef:
name: {{ .Release.Name }}-secret

resources:
requests:
cpu: {{ .Values.resources.requests.cpu | quote }}
memory: {{ .Values.resources.requests.memory | quote }}

limits:
cpu: {{ .Values.resources.limits.cpu | quote }}
memory: {{ .Values.resources.limits.memory | quote }}


# -------------------------
# Liveness probe
# -------------------------
{{- if .Values.livenessProbe.enabled }}
livenessProbe:
httpGet:
path: {{ .Values.livenessProbe.httpGet.path }}
port: {{ .Values.livenessProbe.httpGet.port }}

initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
successThreshold: {{ .Values.livenessProbe.successThreshold }}
{{- end }}

# -------------------------
# Readiness probe
# -------------------------
{{- if .Values.readinessProbe.enabled }}
readinessProbe:
httpGet:
path: {{ .Values.readinessProbe.httpGet.path }}
port: {{ .Values.readinessProbe.httpGet.port }}

initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
successThreshold: {{ .Values.readinessProbe.successThreshold }}
{{- end }}
26 changes: 26 additions & 0 deletions web-app/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{{- if .Values.autoscaling.enabled }}

apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler

metadata:
name: {{ .Release.Name }}-hpa

spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ .Release.Name }}-web-app

minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}

metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}

{{- end }}
Loading