Skip to content

test #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 43 commits into
base: main
Choose a base branch
from
Open

test #21

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
d58ec5e
modified web pages
niteshops Apr 1, 2025
572a0d9
added k8s and dockerfile
niteshops Apr 1, 2025
2274a58
implement github actions
niteshops Apr 2, 2025
b5933ab
Update go.mod
niteshautomates Apr 2, 2025
c76481e
go version change
niteshops Apr 2, 2025
873711e
go version change
niteshops Apr 2, 2025
bea5fc1
go version change
niteshops Apr 2, 2025
3a3cc67
go version change
niteshops Apr 2, 2025
5e17d7d
added sonarqube scan
niteshops Apr 3, 2025
668537c
changed checkout version
niteshops Apr 3, 2025
2a56583
changed set up go version
niteshops Apr 3, 2025
2444d32
Update ci.yml
niteshautomates Apr 3, 2025
f220a7b
Update ci.yml
niteshautomates Apr 3, 2025
be4d136
changed working dir
niteshops Apr 3, 2025
ea0234b
changed working dir
niteshops Apr 3, 2025
bb7445d
Update ci.yml
niteshautomates Apr 3, 2025
518db98
Update ci.yml
niteshautomates Apr 3, 2025
eac2000
Update ci.yml
niteshautomates Apr 3, 2025
08ffea8
Update ci.yml
niteshautomates Apr 3, 2025
8bd30e7
Update ci.yml
niteshautomates Apr 3, 2025
47c3d7e
Update ci.yml
niteshautomates Apr 3, 2025
655f32f
Update ci.yml
niteshautomates Apr 3, 2025
5bb91b7
Update ci.yml
niteshautomates Apr 3, 2025
bc6d0ce
Update ci.yml
niteshautomates Apr 3, 2025
1c737d0
Update ci.yml
niteshautomates Apr 3, 2025
aa19b63
Update about.html
niteshautomates Apr 4, 2025
e5791bc
Update ci.yml
niteshautomates Apr 4, 2025
1630b82
Update ci.yml
niteshautomates Apr 4, 2025
f2a039a
Update ci.yml
niteshautomates Apr 4, 2025
3b624ea
Update ci.yml
niteshautomates Apr 4, 2025
bc8d441
Update ci.yml
niteshautomates Apr 4, 2025
71f98b3
Update ci.yml
niteshautomates Apr 4, 2025
9577f82
Update ci.yml
niteshautomates Apr 4, 2025
be379c1
Update ci.yml
niteshautomates Apr 4, 2025
e5ca2bd
Update ci.yml
niteshautomates Apr 4, 2025
54c7cbb
Update ci.yml
niteshautomates Apr 4, 2025
4eee83c
Update ci.yml
niteshautomates Apr 4, 2025
4075efa
Update ci.yml
niteshautomates Apr 4, 2025
0d13ab0
added git tag update , build image and push to docker hub
niteshops Apr 4, 2025
6a8fec5
vars.DOCKERHUB_USERNAME
niteshops Apr 4, 2025
6827652
Fixed:- FromAsCasing: 'as' and 'FROM' keywords' casing do not match
niteshops Apr 4, 2025
364f6b6
Fixed: go package downloader
niteshops Apr 4, 2025
bdaf258
added orject to idx
niteshautomates Apr 8, 2025
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
138 changes: 138 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
name: CI

on:
push:
branches:
- main
paths-ignore:
- "helm/**"
- "README.md"

jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Print GITHUB_WORKSPACE
run: echo ${GITHUB_WORKSPACE}

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '1.23'

- name: Install dependencies
run: go mod download

- name: Run tests
run: go test ./...

#code-quality:
#needs: [build-and-test]
#runs-on: ubuntu-latest
#steps:
# - name: Checkout code
# uses: actions/checkout@v4

#- name: Run Golang Lint
# uses: golangci/golangci-lint-action@v6
#with:
# version: v1.56.2



sonarqube-analysis-and-quality-check:
needs: [build-and-test]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Print GITHUB_WORKSPACE
run: echo ${GITHUB_WORKSPACE}


- name: Sonarqube Scan
uses: SonarSource/sonarqube-scan-action@v4
with:
projectBaseDir: /home/runner/work/go-web-app/go-web-app
args: >
-Dsonar.organization=niteshops-github-action
-Dsonar.projectKey=GO-Web-Application
-Dsonar.qualitygate.wait=true
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}


# Check the Quality Gate status.
- name: SonarQube Quality Gate check
id: sonarqube-quality-gate-check
uses: sonarsource/sonarqube-quality-gate-action@master
with:
pollingTimeoutSec: 600
scanMetadataReportFile: .scannerwork/report-task.txt
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} #OPTIONAL

# Optionally you can use the output from the Quality Gate in another step.
# The possible outputs of the `quality-gate-status` variable are `PASSED`, `WARN` or `FAILED`.
- name: "Example show SonarQube Quality Gate Status value"
run: echo "The Quality Gate status is ${{ steps.sonarqube-quality-gate-check.outputs.quality-gate-status }}"

build-docker-img-and-push:
needs: sonarqube-analysis-and-quality-check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
# Add support for more platforms with QEMU (optional)
# https://github.com/docker/setup-qemu-action
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up docker Buildx
uses: docker/setup-buildx-action@v3
with:
platforms: linux/amd64,linux/arm64

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and Push action
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ vars.DOCKERHUB_USERNAME }}/go-web-app:${{github.run_id}}

update-image-tag-in-helm-chart:
runs-on: ubuntu-latest
needs: build-docker-img-and-push
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.TOKEN }}

- name: Update image tag in Helm chart
run: |
echo "Updating image tag in Helm chart"
sed -i 's/tag: .*/tag: "${{github.run_id}}"/' helm/go-web-app-chart/values.yaml
cat helm/go-web-app/values.yaml
echo "Image tag updated in Helm chart"

- name: Commit and push changes
run: |
git config --global user.email "niteshwayafalkar@gmail.com"
git config --global user.name "Nitesh Wayafalkar"
git add helm/go-web-app-chart/values.yaml
git commit -m "Update tag in Helm chart"
git push
61 changes: 61 additions & 0 deletions .idx/dev.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# To learn more about how to use Nix to configure your environment
# see: https://developers.google.com/idx/guides/customize-idx-env
{ pkgs, ... }: {
# Which nixpkgs channel to use.
channel = "stable-24.05"; # or "unstable"

# Use https://search.nixos.org/packages to find packages
packages = [
pkgs.go
# pkgs.python311
# pkgs.python311Packages.pip
# pkgs.nodejs_20
# pkgs.nodePackages.nodemon
pkgs.docker-buildx
pkgs.docker
pkgs.kubernetes
pkgs.helm
pkgs.kubernetes-helm
pkgs.javaPackages.openjfx17
];

# Sets environment variables in the workspace
env = {};
idx = {
# Search for the extensions you want on https://open-vsx.org/ and use "publisher.id"
extensions = [
# "vscodevim.vim"
];

# Enable previews
previews = {
enable = true;
previews = {
# web = {
# # Example: run "npm run dev" with PORT set to IDX's defined port for previews,
# # and show it in IDX's web preview panel
# command = ["npm" "run" "dev"];
# manager = "web";
# env = {
# # Environment variables to set for your server
# PORT = "$PORT";
# };
# };
};
};

# Workspace lifecycle hooks
workspace = {
# Runs when a workspace is first created
onCreate = {
# Example: install JS dependencies from NPM
# npm-install = "npm install";
};
# Runs when the workspace is (re)started
onStart = {
# Example: start a background task to watch and re-build backend code
# watch-backend = "npm run watch-backend";
};
};
};
}
3 changes: 3 additions & 0 deletions .idx/integrations.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"cloud_run_deploy": {}
}
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"IDX.aI.enableInlineCompletion": true,
"IDX.aI.enableCodebaseIndexing": true
}
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM golang:1.22.5 AS base

WORKDIR /app

COPY go.mod ./

RUN go mod tidy && go mod vendor

COPY . .

RUN go build -o /app/main .

########################
#Reduce images size by using multistage dockerfile
#########################
FROM gcr.io/distroless/base

COPY --from=base /app/main .

COPY --from=base /app/static ./static

EXPOSE 8080

CMD ["./main"]


14 changes: 14 additions & 0 deletions eks-cluster/cluster-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig

metadata:
name: go-app
region: ap-south-1

nodeGroups:
- name: go-app-node
instanceType: m5.xlarge
desiredCapacity: 1
volumeSize: 100
ssh:
allow: true
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/iam-veeramalla/go-web-app
module github.com/niteshtheqa/go-web-app

go 1.22.5
go 1.23
23 changes: 23 additions & 0 deletions helm/go-web-app-chart/.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/
24 changes: 24 additions & 0 deletions helm/go-web-app-chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: go-web-app-chart
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"
34 changes: 34 additions & 0 deletions helm/go-web-app-chart/templates/deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: go-web-app
namespace: go-web-app
labels:
app: go-web-app
spec:
selector:
matchLabels:
app: go-web-app
replicas: 1
template:
metadata:
labels:
app: go-web-app
spec:
# initContainers:
# Init containers are exactly like regular containers, except:
# - Init containers always run to completion.
# - Each init container must complete successfully before the next one starts.
containers:
- name: go-web-app
image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
ports:
- containerPort: 8080
imagePullPolicy: Always
resources:
requests:
memory: "64Mi"
cpu: "250m"
limits:
memory: "128Mi"
cpu: "500m"
23 changes: 23 additions & 0 deletions helm/go-web-app-chart/templates/ingress.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# https://kubernetes.io/docs/concepts/services-networking/ingress/#the-ingress-resource

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: go-web-app-ingress
namespace: go-web-app
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
ingressClassName: nginx
rules:
- host: www.youtube-academy.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: go-web-svc
port:
number: 80

4 changes: 4 additions & 0 deletions helm/go-web-app-chart/templates/namespace.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: go-web-app
17 changes: 17 additions & 0 deletions helm/go-web-app-chart/templates/service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: v1
kind: Service
metadata:
name: go-web-svc
namespace: go-web-app
spec:
selector:
app: go-web-app
type: NodePort
ports:
- name: http
protocol: TCP
port: 80
targetPort: 8080
# If you set the `spec.type` field to `NodePort` and you want a specific port number,
# you can specify a value in the `spec.ports[*].nodePort` field.

Loading