Skip to content
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

dishab #486

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
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
43 changes: 43 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
pipeline{
agent any
environment{
SONAR_HOME= tool "Sonar"
}
stages{
stage("Clone Code from GitHub"){
steps{
git url: "https://github.com/krishnaacharyaa/wanderlust.git", branch: "devops"
}
}
stage("SonarQube Quality Analysis"){
steps{
withSonarQubeEnv("Sonar"){
sh "$SONAR_HOME/bin/sonar-scanner -Dsonar.projectName=wanderlust -Dsonar.projectKey=wanderlust"
}
}
}
stage("OWASP Dependency Check"){
steps{
dependencyCheck additionalArguments: '--scan ./', odcInstallation: 'dc'
dependencyCheckPublisher pattern: '**/dependency-check-report.xml'
}
}
stage("Sonar Quality Gate Scan"){
steps{
timeout(time: 2, unit: "MINUTES"){
waitForQualityGate abortPipeline: false
}
}
}
stage("Trivy File System Scan"){
steps{
sh "trivy fs --format table -o trivy-fs-report.html ."
}
}
stage("Deploy using Docker compose"){
steps{
sh "docker-compose up -d"
}
}
}
}
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
2 changes: 2 additions & 0 deletions backend/.env.docker
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
MONGODB_URI="mongodb://mongo/wanderlust"
REDIS_URL="redis://redis:6379"
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"
31 changes: 31 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Stage 1
FROM node:21 AS backend-builder

# setup the working dir
WORKDIR /app

# code
COPY . .

# packages install
RUN npm i

# tests
RUN npm run test

# Stage 2
FROM node:21-slim

# setup the working dir
WORKDIR /app

# copy the above stage as compressed
COPY --from=backend-builder /app .

COPY .env.docker .env

# Port
EXPOSE 5000

# App
CMD ["npm", "start"]
39 changes: 39 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
version: "3.3"
services:
mongodb:
container_name: mongo
image: mongo:latest
volumes:
- ./backend/data:/data
ports:
- "27017:27017"

backend:
container_name: backend
build: ./backend
env_file:
- ./backend/.env.docker
ports:
- "5000:5000"
depends_on:
- mongodb

frontend:
container_name: frontend
build: ./frontend
env_file:
- ./frontend/.env.docker
ports:
- "5173:5173"

redis:
container_name: redis
restart: unless-stopped
image: redis:7.0.5-alpine
expose:
- 6379
depends_on:
- mongodb

volumes:
data:
1 change: 1 addition & 0 deletions frontend/.env.docker
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_API_PATH="http://wanderlust.trainwithshubham.com:5000"
2 changes: 1 addition & 1 deletion frontend/.env.sample
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VITE_API_PATH="http://localhost:5000"
VITE_API_PATH="http://localhost:5000"
33 changes: 33 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# ------------------- Stage 1: Build Stage ------------------------------
FROM node:21 AS frontend-builder

# Set the working directory to /app
WORKDIR /app

# Copy the package.json and package-lock.json for dependency installation
COPY package*.json ./

# Install dependencies
RUN npm install

# Copy the rest of the application code
COPY . .

# ------------------- Stage 2: Final Stage ------------------------------
FROM node:21-slim

# Set the working directory to /app
WORKDIR /app

# Copy built assets and dependencies from frontend-builder stage
COPY --from=frontend-builder /app .

# Copy the .env.sample file to .env.local
COPY .env.docker .env.local

# Expose port 5173 for the Node.js application
EXPOSE 5173

# Define the default command to run the application in development mode
CMD ["npm", "run", "dev", "--", "--host"]

Loading