Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
e939fb7
feat-#131 dockerize
Apr 18, 2024
46381a4
feat-#131 changed readme for docker
LondheShubham153 Apr 18, 2024
0914a41
Update README.md with docker changes
LondheShubham153 Apr 18, 2024
f11ce8e
feat-#131 changed env files for docker
LondheShubham153 Apr 18, 2024
f0491b8
Update Dockerfile with tests
LondheShubham153 Apr 21, 2024
b7c1364
Update Dockerfile
LondheShubham153 Apr 21, 2024
ee78003
Update Dockerfile
LondheShubham153 Apr 21, 2024
d8dcd86
Update .env.docker
LondheShubham153 Apr 21, 2024
bd50330
Create Jenkinsfile
LondheShubham153 Apr 21, 2024
22fc9fb
Updated Dockerfile and env variables
May 26, 2024
c52d5bf
Added K8s manifests
DevMadhup May 26, 2024
0549310
Updated Manifests
May 26, 2024
0b2497b
Added kubeadm setup file
May 26, 2024
f17809b
Updated manifests
May 27, 2024
01134d1
Update kubeadm.md
DevMadhup May 27, 2024
3542024
Create README.md
DevMadhup May 27, 2024
de1ea15
Add files via upload
DevMadhup May 27, 2024
2b91e76
Create README.md
DevMadhup May 27, 2024
c642f7b
Update README.md
DevMadhup May 27, 2024
6505266
Update README.md
DevMadhup May 28, 2024
ce090fd
Create persistentVolume.yaml
DevMadhup May 28, 2024
debebf0
Create persistentVolumeClaim.yaml
DevMadhup May 28, 2024
a5c1195
Update mongodb.yaml
DevMadhup May 28, 2024
2d0c074
Update redis.yaml
DevMadhup May 28, 2024
0811795
Update persistentVolume.yaml
DevMadhup May 28, 2024
e5c34c9
Update persistentVolumeClaim.yaml
DevMadhup May 28, 2024
3ccbaeb
Update kubeadm.md
DevMadhup May 29, 2024
c3e8fb8
Update README.md
DevMadhup May 29, 2024
f441cf5
Update README.md
DevMadhup May 29, 2024
caae7ba
Update README.md
DevMadhup May 29, 2024
e0541fb
Update README.md
DevMadhup Jun 1, 2024
dabd14e
Update redis.yaml
DevMadhup Jun 1, 2024
9b764e4
Update kubeadm.md
DevMadhup Jun 1, 2024
4ed1e37
Update kubeadm.md
DevMadhup Jun 1, 2024
b7a6a1b
Added enhancement
DevMadhup Jun 1, 2024
1054209
Added enhancement
DevMadhup Jun 1, 2024
f0fdc8e
Create public-ipv4.sh
DevMadhup Jun 2, 2024
4502afe
Update public-ipv4.sh
DevMadhup Jun 3, 2024
c76ffb4
Added enhancements for automation
DevMadhup Jun 9, 2024
b2634fc
Delete Automations/public-ipv4.sh
DevMadhup Jun 9, 2024
dc8b03c
Update Jenkinsfile
DevMadhup Jun 9, 2024
df0c64a
Update Jenkinsfile
DevMadhup Jun 13, 2024
dcffe47
Create Jenkinsfile
DevMadhup Jun 13, 2024
18df5c3
Updated environment variables
Jun 13, 2024
d92022e
Updated environment variables
Jun 13, 2024
3b8dc12
Updated environment variables
Jun 13, 2024
cd13eed
Update Jenkinsfile
DevMadhup Jun 13, 2024
1b6def6
Updated environment variables
Jun 13, 2024
fc61e44
Updated environment variables
Jun 13, 2024
e630505
Updated environment variables
Jun 13, 2024
2b9df3a
Update Jenkinsfile
DevMadhup Jun 13, 2024
1b0bb5e
Update Jenkinsfile
DevMadhup Jun 13, 2024
2f562da
Create updatebackendnew.sh
DevMadhup Jul 8, 2024
287280b
Create updatefrontendnew.sh
DevMadhup Jul 8, 2024
b09bc9f
Update updatebackendnew.sh
DevMadhup Jul 8, 2024
228d59b
added enchancement
DevMadhup Jul 14, 2024
3acc289
Fix: wanderlust backend and frontend
DevMadhup Jul 15, 2024
12f0abc
updated project
Apr 28, 2026
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
31 changes: 31 additions & 0 deletions Automations/updateBackend.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

# Initializing variables
file_to_find="../backend/.env.docker"
alreadyUpdate=$(sed -n "4p" ../backend/.env.docker)
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m'

# Use curl to fetch the public IPv4 address from the metadata service
ipv4_address=$(curl -s http://169.254.169.254/latest/meta-data/public-ipv4)

echo -e " ${GREEN}System Public Ipv4 address ${NC} : ${ipv4_address}"

if [[ "${alreadyUpdate}" == "FRONTEND_URL=\"http://${ipv4_address}:5173\"" ]]
then
echo -e "${YELLOW}${file_to_find} file is already updated to the current host's Ipv4 ${NC}"
exit -1;
else
if [ -f ${file_to_find} ]
then
echo -e "${GREEN}${file_to_find}${NC} found.."
echo -e "${YELLOW}Configuring env variables in ${NC} ${file_to_find}"
sleep 7s;
sed -i -e "s|FRONTEND_URL.*|FRONTEND_URL=\"http://${ipv4_address}:5173\"|g" ${file_to_find}
echo -e "${GREEN}env variables configured..${NC}"
else
echo -e "${RED}ERROR : File not found..${NC}"
fi
fi
31 changes: 31 additions & 0 deletions Automations/updateFrontend.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

# Initializing variables
file_to_find="../frontend/.env.docker"
alreadyUpdate=$(cat ../frontend/.env.docker)
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m'

# Use curl to fetch the public IPv4 address from the metadata service
ipv4_address=$(curl -s http://169.254.169.254/latest/meta-data/public-ipv4)

echo -e " ${GREEN}System Public Ipv4 address ${NC} : ${ipv4_address}"

if [[ "${alreadyUpdate}" == "VITE_API_PATH=\"http://${ipv4_address}:31100\"" ]]
then
echo -e "${YELLOW}${file_to_find} file is already updated to the current host's Ipv4 ${NC}"
exit -1;
else
if [ -f ${file_to_find} ]
then
echo -e "${GREEN}${file_to_find}${NC} found.."
echo -e "${YELLOW}Configuring env variables in ${NC} ${file_to_find}"
sleep 7s;
sed -i -e "s|VITE_API_PATH.*|VITE_API_PATH=\"http://${ipv4_address}:31100\"|g" ${file_to_find}
echo -e "${GREEN}env variables configured..${NC}"
else
echo -e "${RED}ERROR : File not found..${NC}"
fi
fi
36 changes: 36 additions & 0 deletions Automations/updatebackendnew.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

# Set the Instance ID and path to the .env file
INSTANCE_ID="i-0c7c9d3d4e8c3a012"

# Retrieve the public IP address of the specified EC2 instance
ipv4_address=$(aws ec2 describe-instances --instance-ids $INSTANCE_ID --query 'Reservations[0].Instances[0].PublicIpAddress' --output text)

# Initializing variables
file_to_find="../backend/.env.docker"
alreadyUpdate=$(sed -n "4p" ../backend/.env.docker)
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m'

# Use curl to fetch the public IPv4 address from the metadata service

echo -e " ${GREEN}System Public Ipv4 address ${NC} : ${ipv4_address}"

if [[ "${alreadyUpdate}" == "FRONTEND_URL=\"http://${ipv4_address}:5173\"" ]]
then
echo -e "${YELLOW}${file_to_find} file is already updated to the current host's Ipv4 ${NC}"
exit -1;
else
if [ -f ${file_to_find} ]
then
echo -e "${GREEN}${file_to_find}${NC} found.."
echo -e "${YELLOW}Configuring env variables in ${NC} ${file_to_find}"
sleep 7s;
sed -i -e "s|FRONTEND_URL.*|FRONTEND_URL=\"http://${ipv4_address}:5173\"|g" ${file_to_find}
echo -e "${GREEN}env variables configured..${NC}"
else
echo -e "${RED}ERROR : File not found..${NC}"
fi
fi
34 changes: 34 additions & 0 deletions Automations/updatefrontendnew.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

# Set the Instance ID and path to the .env file
INSTANCE_ID="i-0c7c9d3d4e8c3a012"

# Retrieve the public IP address of the specified EC2 instance
ipv4_address=$(aws ec2 describe-instances --instance-ids $INSTANCE_ID --query 'Reservations[0].Instances[0].PublicIpAddress' --output text)

# Initializing variables
file_to_find="../frontend/.env.docker"
alreadyUpdate=$(cat ../frontend/.env.docker)
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m'

echo -e " ${GREEN}System Public Ipv4 address ${NC} : ${ipv4_address}"

if [[ "${alreadyUpdate}" == "VITE_API_PATH=\"http://${ipv4_address}:31100\"" ]]
then
echo -e "${YELLOW}${file_to_find} file is already updated to the current host's Ipv4 ${NC}"
exit -1;
else
if [ -f ${file_to_find} ]
then
echo -e "${GREEN}${file_to_find}${NC} found.."
echo -e "${YELLOW}Configuring env variables in ${NC} ${file_to_find}"
sleep 7s;
sed -i -e "s|VITE_API_PATH.*|VITE_API_PATH=\"http://${ipv4_address}:31100\"|g" ${file_to_find}
echo -e "${GREEN}env variables configured..${NC}"
else
echo -e "${RED}ERROR : File not found..${NC}"
fi
fi
78 changes: 78 additions & 0 deletions GitOps/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
@Library('Shared') _
pipeline {
agent {label 'Node'}

parameters {
string(name: 'FRONTEND_DOCKER_TAG', defaultValue: '', description: 'Frontend Docker tag of the image built by the CI job')
string(name: 'BACKEND_DOCKER_TAG', defaultValue: '', description: 'Backend Docker tag of the image built by the CI job')
}

stages {
stage("Workspace cleanup"){
steps{
script{
cleanWs()
}
}
}

stage('Git: Code Checkout') {
steps {
script{
code_checkout("https://github.com/DevMadhup/wanderlust.git","devops")
}
}
}

stage('Verify: Docker Image Tags') {
steps {
script{
echo "FRONTEND_DOCKER_TAG: ${params.FRONTEND_DOCKER_TAG}"
echo "BACKEND_DOCKER_TAG: ${params.BACKEND_DOCKER_TAG}"
}
}
}


stage("Update: Kubernetes manifests"){
steps{
script{
dir('kubernetes'){
sh """
sed -i -e 's/backend-wanderlust.*/backend-wanderlust:${params.BACKEND_DOCKER_TAG}/g' backend.yaml
"""
}

dir('kubernetes'){
sh """
sed -i -e 's/frontend-wanderlust.*/frontend-wanderlust:${params.FRONTEND_DOCKER_TAG}/g' frontend.yaml
"""
}

}
}
}

stage("Git: Code update and push to GitHub"){
steps{
script{
withCredentials([gitUsernamePassword(credentialsId: 'Github-cred', gitToolName: 'Default')]) {
sh '''
echo "Checking repository status: "
git status

echo "Adding changes to git: "
git add .

echo "Commiting changes: "
git commit -m "Updated environment variables"

echo "Pushing changes to github: "
git push https://github.com/DevMadhup/wanderlust.git devops
'''
}
}
}
}
}
}
119 changes: 119 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
@Library('Shared') _
pipeline {
agent any

environment{
SONAR_HOME = tool "Sonar"
}
stages {

stage("Workspace cleanup"){
steps{
script{
cleanWs()
}
}
}

stage('Git: Code Checkout') {
steps {
script{
code_checkout("https://github.com/DevMadhup/wanderlust.git","devops")
}
}
}

stage("OWASP: Dependency check"){
steps{
script{
owasp_dependency()
}
}
post{
success{
archiveArtifacts artifacts: '**/dependency-check-report.xml', followSymlinks: false, onlyIfSuccessful: true
}
}
}

stage("Trivy: Filesystem scan"){
steps{
script{
trivy_scan()
}
}
}

stage("SonarQube: Code Analysis"){
steps{
script{
sonarqube_analysis("Sonar","wanderlust","wanderlust")
}
}
}

stage("SonarQube: Code Quality Gates"){
steps{
script{
sonarqube_code_quality()
}
}
}

stage('Exporting environment variables') {
parallel{
stage("Backend env setup"){
steps {
script{
dir("Automations"){
sh "bash updateBackend.sh"
}
}
}
}

stage("Frontend env setup"){
steps {
script{
dir("Automations"){
sh "bash updateFrontend.sh"
}
}
}
}
}
}

stage("Docker: Build Images"){
steps{
script{
dir('backend'){
docker_build("backend-wanderlust","test-image-donot-use","madhupdevops")
}

dir('frontend'){
docker_build("frontend-wanderlust","test-image-donot-use","madhupdevops")
}
}
}
}

stage("Docker: Push to DockerHub"){
steps{
script{
docker_push("backend-wanderlust","test-image-donot-use","madhupdevops")
docker_push("frontend-wanderlust","test-image-donot-use","madhupdevops")
}
}
}
}

post{
success{
build job: "Wanderlust-CD", parameters: [
string(name: 'FRONTEND_DOCKER_TAG', value: "test-image-donot-use"),
string(name: 'BACKEND_DOCKER_TAG', value: "test-image-donot-use")
]
}
}
}
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,33 @@ _I'd love for you to make the most of this project - it's all about learning, he
npm run dev
```

### Setting up with Docker

1. **Ensure Docker and Docker Compose are Installed**

2. **Clone the Repository**

``` bash

git clone https://github.com/{your-username}/wanderlust.git
```
3. **Navigate to the Project Directory**

```bash

cd wanderlust

```
4. **Update Environment Variables** - If you anticipate the IP address of the instance might change, update the `.env.sample` file with the new IP address.

5. **Run Docker Compose**

```bash

docker-compose up
```
This command will build the Docker images and start the containers for the backend and frontend, enabling you to access the Wanderlust application.

## 🌟 Ready to Contribute?

Kindly go through [CONTRIBUTING.md](https://github.com/krishnaacharyaa/wanderlust/blob/main/.github/CONTRIBUTING.md) to understand everything from setup to contributing guidelines.
Expand Down
9 changes: 9 additions & 0 deletions backend/.env.docker
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
MONGODB_URI="mongodb://mongo-service/wanderlust"
REDIS_URL="redis://redis-service:6379"
PORT=5000
ACCESS_COOKIE_MAXAGE=120000
ACCESS_TOKEN_EXPIRES_IN='120s'
REFRESH_COOKIE_MAXAGE=120000
REFRESH_TOKEN_EXPIRES_IN='120s'
JWT_SECRET=70dd8b38486eee723ce2505f6db06f1ee503fde5eb06fc04687191a0ed665f3f98776902d2c89f6b993b1c579a87fedaf584c693a106f7cbf16e8b4e67e9d6df
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Remove committed JWT secret and inject it from secrets management.

Line 8 contains a live secret in source control. This is a blocker security issue and should be rotated immediately.

Proposed fix
-JWT_SECRET=70dd8b38486eee723ce2505f6db06f1ee503fde5eb06fc04687191a0ed665f3f98776902d2c89f6b993b1c579a87fedaf584c693a106f7cbf16e8b4e67e9d6df
+JWT_SECRET=${JWT_SECRET}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
JWT_SECRET=70dd8b38486eee723ce2505f6db06f1ee503fde5eb06fc04687191a0ed665f3f98776902d2c89f6b993b1c579a87fedaf584c693a106f7cbf16e8b4e67e9d6df
JWT_SECRET=${JWT_SECRET}
🧰 Tools
🪛 dotenv-linter (4.0.0)

[warning] 8-8: [UnorderedKey] The JWT_SECRET key should go before the MONGODB_URI key

(UnorderedKey)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@backend/.env.docker` at line 8, Remove the hard-coded JWT_SECRET from
backend/.env.docker and replace it with a placeholder (e.g.
JWT_SECRET=<SECRET_FROM_SECRETS>) so no live secrets are committed; rotate the
exposed secret immediately. Update deployment/compose and CI to read the real
secret from your secrets manager or Docker secrets and inject it into the
container at runtime (ensure the secret name used matches the placeholder), and
update any startup/config code that reads JWT_SECRET to accept the injected
secret. Verify no other files commit the same value and add a short note in ops
docs describing how to provision the new secret in the secrets manager.

NODE_ENV=Development
2 changes: 1 addition & 1 deletion backend/.env.sample
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
MONGODB_URI="mongodb://127.0.0.1/wanderlust"
REDIS_URL="127.0.0.1:6379"
REDIS_URL="127.0.0.1:6379"
Loading
Loading