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 angular-frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Build stage
FROM node:14-alpine AS build
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build

# Runtime stage
FROM nginx:alpine

# Remove default NGINX config
RUN rm /etc/nginx/conf.d/default.conf

# Copy your custom config
COPY nginx.conf /etc/nginx/conf.d/default.conf

# Copy Angular build output
COPY --from=build /usr/src/app/dist/angular-frontend /usr/share/nginx/html

EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]


# # Use official Node.js image as the base image
# FROM node:14-alpine AS build

# # Set the working directory in the container
# WORKDIR /usr/src/app

# # Copy package.json and package-lock.json (if available)
# COPY package*.json ./

# # Install project dependencies
# RUN npm install

# # Copy the rest of the application code
# COPY . .

# # Build the Angular application
# RUN npm run build

# # Use NGINX as the production server
# FROM nginx:alpine

# # Copy the built artifact from the previous stage to NGINX web server directory
# COPY --from=build /usr/src/app/dist/angular-frontend /usr/share/nginx/html

# # Expose port 80 to the outside world
# EXPOSE 80

# # Start NGINX server when the container starts
# CMD ["nginx", "-g", "daemon off;"]
17 changes: 17 additions & 0 deletions angular-frontend/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
server {
listen 80;

root /usr/share/nginx/html;
index index.html;

location / {
try_files $uri $uri/ /index.html;
}

location /api/ {
proxy_pass http://backend:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
4 changes: 3 additions & 1 deletion angular-frontend/src/app/services/worker.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import { Worker } from '../models/worker';
})
export class WorkerService {

private getUrl: string = "http://localhost:8080/api/v1/workers";
// private getUrl: string = "http://54.83.90.121:8080/api/v1/workers";
private getUrl = "/api/v1/workers";


constructor(private _httpClient: HttpClient) { }

Expand Down
2 changes: 1 addition & 1 deletion angular-frontend/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
<title>AngularFrontend</title>
<title>myAngularFrontend</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
Expand Down
26 changes: 26 additions & 0 deletions backend-argocd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: backend
namespace: argocd
spec:
project: default

source:
repoURL: https://github.com/gauravrajlaxmi/angular-java.git
targetRevision: develop
path: helm/backend # ✅ IMPORTANT FIX
helm:
valueFiles:
- values.yaml

destination:
server: https://kubernetes.default.svc
namespace: apps

syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true
22 changes: 22 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: "3.9"

services:
backend:
image: ${BACKEND_IMAGE}
container_name: spring_backend
ports:
- "8080:8080"
environment:
SPRING_DATASOURCE_URL: jdbc:mysql://${DB_HOST}:${DB_PORT}/${DB_NAME}?${DB_PARAMS}
SPRING_DATASOURCE_USERNAME: ${DB_USER}
SPRING_DATASOURCE_PASSWORD: ${DB_PASSWORD}
restart: always

frontend:
image: ${FRONTEND_IMAGE}
container_name: angular_frontend
ports:
- "80:80"
depends_on:
- backend
restart: always
26 changes: 26 additions & 0 deletions frontend-argocd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: frontend
namespace: argocd
spec:
project: default

source:
repoURL: https://github.com/gauravrajlaxmi/angular-java.git
targetRevision: develop
path: helm/frontend
helm:
valueFiles:
- values.yaml

destination:
server: https://kubernetes.default.svc
namespace: apps

syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true
23 changes: 23 additions & 0 deletions helm/backend/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
31 changes: 31 additions & 0 deletions helm/backend/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
apiVersion: v2
name: backend
description: Spring Boot Backend
type: application
version: 0.1.0
appVersion: "1.0"

# apiVersion: v2
# name: backend
# description: A Helm chart for Kubernetes

# # A chart can be either an 'application' or a 'library' chart.
# #
# # Application charts are a collection of templates that can be packaged into versioned archives
# # to be deployed.
# #
# # Library charts provide useful utilities or functions for the chart developer. They're included as
# # a dependency of application charts to inject those utilities and functions into the rendering
# # pipeline. Library charts do not define any templates and therefore cannot be deployed.
# type: application

# # This is the chart version. This version number should be incremented each time you make changes
# # to the chart and its templates, including the app version.
# # Versions are expected to follow Semantic Versioning (https://semver.org/)
# version: 0.1.0

# # This is the version number of the application being deployed. This version number should be
# # incremented each time you make changes to the application. Versions are not expected to
# # follow Semantic Versioning. They should reflect the version the application is using.
# # It is recommended to use it with quotes.
# appVersion: "1.16.0"
8 changes: 8 additions & 0 deletions helm/backend/templates/configmap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: backend-config
data:
DB_HOST: {{ .Values.database.host | quote }}
DB_PORT: {{ .Values.database.port | quote }}
DB_NAME: {{ .Values.database.name | quote }}
60 changes: 60 additions & 0 deletions helm/backend/templates/deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: backend
spec:
replicas: {{ .Values.replicaCount }}

selector:
matchLabels:
app: backend

template:
metadata:
labels:
app: backend

spec:
containers:
- name: backend

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

ports:
- containerPort: 8080

env:

- name: DB_HOST
valueFrom:
configMapKeyRef:
name: backend-config
key: DB_HOST

- name: DB_PORT
valueFrom:
configMapKeyRef:
name: backend-config
key: DB_PORT

- name: DB_NAME
valueFrom:
configMapKeyRef:
name: backend-config
key: DB_NAME

- name: DB_USERNAME
valueFrom:
secretKeyRef:
name: backend-secret
key: DB_USERNAME

- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: backend-secret
key: DB_PASSWORD

resources:
{{ toYaml .Values.resources | indent 10 }}
9 changes: 9 additions & 0 deletions helm/backend/templates/secret.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
kind: Secret
metadata:
name: backend-secret
type: Opaque

stringData:
DB_USERNAME: {{ .Values.secret.username | quote }}
DB_PASSWORD: {{ .Values.secret.password | quote }}
15 changes: 15 additions & 0 deletions helm/backend/templates/service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: backend

spec:
selector:
app: backend

ports:
- name: http
port: 8080
targetPort: 8080

type: {{ .Values.service.type }}
Loading