Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
f5a502c
add docker file
nitesh4511 Dec 4, 2025
d677625
updated file
nitesh4511 Dec 4, 2025
6c9f5fd
Create inventory prod
nitesh4511 Dec 9, 2025
37b8352
Create deployment.yaml production
nitesh4511 Dec 9, 2025
5a85d93
Create inventory test
nitesh4511 Dec 9, 2025
44e101e
Delete website/envs/test/inventory directory
nitesh4511 Dec 9, 2025
366579b
Create inventory test created
nitesh4511 Dec 9, 2025
dc311a0
Create deployment.yaml test added
nitesh4511 Dec 9, 2025
cd7f4c8
Create inventory dev created
nitesh4511 Dec 9, 2025
03e40ac
Create deployment.yaml dev
nitesh4511 Dec 9, 2025
22d88a6
Update deployment.yaml updated
nitesh4511 Dec 9, 2025
94164a4
Update deployment.yaml production updated
nitesh4511 Dec 9, 2025
def3145
Update deployment.yaml updated
nitesh4511 Dec 9, 2025
a460062
Create deployment.yml ansible file
nitesh4511 Dec 10, 2025
52c1ce7
Update deployment.yml ansible deployemt file
nitesh4511 Dec 10, 2025
feb08a0
Update inventory
nitesh4511 Dec 10, 2025
1de9b51
Update inventory prod
nitesh4511 Dec 10, 2025
a935302
Update inventory test
nitesh4511 Dec 10, 2025
f66490a
Delete website/envs/dev/inventory/inventory dev
nitesh4511 Dec 10, 2025
e512699
Create inventory.ini dev
nitesh4511 Dec 10, 2025
18906b3
Delete website/envs/prod/inventory/inventory
nitesh4511 Dec 10, 2025
730a99f
Create inventory.ini production
nitesh4511 Dec 10, 2025
633338f
Update inventory.ini production
nitesh4511 Dec 10, 2025
e771bea
Delete website/envs/test/inventory/inventory test
nitesh4511 Dec 10, 2025
0eeaa72
Create inventory.ini test
nitesh4511 Dec 10, 2025
c1b88a9
Update inventory.ini removed
nitesh4511 Dec 10, 2025
4de4473
Remove comment from namespace definition
nitesh4511 Dec 22, 2025
7cf3bb4
Add host1 configuration to inventory.ini
nitesh4511 Dec 22, 2025
c1c10f3
Refactor deployment.yml variable names for clarity
nitesh4511 Dec 22, 2025
e75f827
Remove redundant comment in deployment.yml
nitesh4511 Dec 22, 2025
995b052
Specify full path for kubectl in deployment.yml
nitesh4511 Dec 22, 2025
24bf366
Add Jenkins pipeline for Docker deployment
nitesh4511 Dec 22, 2025
952f987
Replace shell commands with kubernetes module
nitesh4511 Dec 22, 2025
6ca9665
Add EKS development environment configuration
nitesh4511 Dec 22, 2025
9ab13d6
Rename EKS environment from dev to test
nitesh4511 Dec 22, 2025
4f630e0
Refactor deployment to use kubectl apply command
nitesh4511 Dec 23, 2025
a99e73e
Change Kubernetes module to shell command for apply
nitesh4511 Dec 23, 2025
3204dda
Refactor deployment.yml to use kubernetes module
nitesh4511 Dec 23, 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
25 changes: 25 additions & 0 deletions website/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/bin
**/charts
**/docker-compose*
**/compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
20 changes: 20 additions & 0 deletions website/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

FROM php:8.2-apache


RUN a2enmod rewrite


RUN docker-php-ext-install pdo pdo_mysql


WORKDIR /var/www/html


COPY . /var/www/html/

RUN sed -i 's/AllowOverride None/AllowOverride All/g' /etc/apache2/apache2.conf

EXPOSE 80

CMD ["apache2-foreground"]
47 changes: 47 additions & 0 deletions website/ansible/deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
- name: Deploy to EKS namespace using env-specific manifests
hosts: localhost
connection: local
gather_facts: no

vars:
target_env: "{{ env | default('dev') }}"
eks_cluster: "{{ cluster_name | default('eks_cluster-demo') }}"
aws_region: "{{ region | default('eu-west-2') }}"

env_dir: "envs/{{ target_env }}"
inventory_dir: "{{ env_dir }}/inventory"
k8s_dir: "{{ env_dir }}/k8s"
namespace: "{{ target_env }}"

tasks:
- name: Show deployment parameters
debug:
msg:
- "Environment: {{ target_env }}"
- "Namespace : {{ namespace }}"
- "ENV_DIR : {{ env_dir }}"
- "Inventory : {{ inventory_dir }}"
- "K8S_DIR : {{ k8s_dir }}"
- "Cluster : {{ eks_cluster }}"
- "Region : {{ aws_region }}"

- name: Apply Kubernetes manifests
kubernetes.core.k8s:
state: present
namespace: "{{ namespace }}"
src: "{{ item }}"
with_fileglob:
- "{{ k8s_dir }}/*.yaml"
register: inventory_output
changed_when: "'created' in inventory_output.stdout or 'configured' in inventory_output.stdout"

- name: Apply Kubernetes manifests
kubernetes.core.k8s:
state: present
namespace: "{{ namespace }}"
src: "{{ item }}"
with_fileglob:
- "{{ k8s_dir }}/*.yaml"
register: k8s_output
changed_when: "'created' in k8s_output.stdout or 'configured' in k8s_output.stdout"
7 changes: 7 additions & 0 deletions website/envs/dev/inventory/inventory.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[eks_dev]
host1 ansible_host=10.0.1.210

[eks_dev:vars]
aws_region=eu-west-2
eks_cluster_name=eks_cluster-demo
k8s_manifest_dir=./website
20 changes: 20 additions & 0 deletions website/envs/dev/k8s/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: php-app-deployment
namespace: dev # Explicitly define the namespace
spec:
replicas: 1
selector:
matchLabels:
app: my-php-app
template:
metadata:
labels:
app: my-php-app
spec:
containers:
- name: my-container
image: apand84/php-app/your-image-name
ports:
- containerPort: 80
4 changes: 4 additions & 0 deletions website/envs/prod/inventory/inventory.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[eks_prod:vars]
aws_region=eu-west-2
eks_cluster_name=eks_cluster-demo
k8s_manifest_dir=./website
20 changes: 20 additions & 0 deletions website/envs/prod/k8s/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: php-app-deployment
namespace: prod # Explicitly define the namespace
spec:
replicas: 2
selector:
matchLabels:
app: my-php-app
template:
metadata:
labels:
app: my-php-app
spec:
containers:
- name: my-container
image: apand84/php-app/your-image-name
ports:
- containerPort: 80
6 changes: 6 additions & 0 deletions website/envs/test/inventory/inventory.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[eks_test]
host1 ansible_host=10.0.1.210

[eks_test:vars]
aws_region=eu-west-2
eks_cluster_name=eks_cluster-demo
20 changes: 20 additions & 0 deletions website/envs/test/k8s/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: php-app-deployment
namespace: test # Explicitly define the namespace
spec:
replicas: 1
selector:
matchLabels:
app: my-php-app
template:
metadata:
labels:
app: my-php-app
spec:
containers:
- name: my-container
image: apand84/php-app/your-image-name
ports:
- containerPort: 80
79 changes: 79 additions & 0 deletions website/jenkins
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
pipeline {
agent any

environment {
DOCKER_IMAGE = "apand84/php-app"
DOCKER_CREDENTIALS_ID = 'dockerhub-login-details'
}
parameters {

choice(name: 'NAMESPACE', choices: ['dev', 'test', 'prod'], description: 'Target K8s Namespace')
}

stages {
stage('Clone Repository') {
steps {
git credentialsId: 'GITHUB_CREDENTIAL', url: 'https://github.com/nitesh4511/projCert/'
}
}

stage('Build Docker Image') {
steps {
script {
def builtImage = docker.build("${DOCKER_IMAGE}:${env.BUILD_NUMBER}","./website")
builtImage.tag("latest")
dockerImage = builtImage
}
}
}

stage('Test (Optional Placeholder)') {
steps {
sh 'echo "Running tests... (Add your PHP unit tests here)"'
// Example of running tests inside the built container:
// dockerImage.inside {
// sh 'php artisan test'
// }
}
}

stage('Push Image to Docker Hub') {
steps {
script {
docker.withRegistry('https://registry.hub.docker.com', DOCKER_CREDENTIALS_ID) {
dockerImage.push("${env.BUILD_NUMBER}")
dockerImage.push("latest")
}
}
}
}
stage('Deploy Dev') {
steps {
script {
sh "ansible-playbook -i ./website/envs/dev/inventory/inventory.ini ./website/ansible/deployment.yml"
}
}
}

stage('Deploy Test') {
steps {
script {
sh "ansible-playbook -i ./website/envs/test/inventory/inventory.ini ./website/ansible/deployment.yml"
}
}
}

stage('Deploy Prod') {
when {

branch 'master'
}
steps {
script {

sh "ansible-playbook -i ./website/envs/prod/inventory/inventory.ini ./website/ansible/deployment.yml"
}
}
}
}
}