Skip to content

Test #13

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 22 commits into
base: master
Choose a base branch
from
Open

Test #13

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
41 changes: 41 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
pipeline {
agent any

stages {
stage('Checkout') {
steps {
git branch: 'master', url: 'https://github.com/uniquebiwas/weatherApp-Reactjs'
}
}

stage('Cleanup') {
steps {
script {
// Remove unused Docker images and containers
sh 'docker image prune -f'
sh 'docker container prune -f'
}
}
}

stage('Stop and Remove Container') {
steps {
script {
// Stop and remove the existing container if it exists
sh 'docker-compose down || true'
}
}
}

stage('Build and Run') {
steps {
script {
// Build the Docker image and run the container
sh 'docker-compose up -d'

}
}
}

}
}
29 changes: 29 additions & 0 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Use an official Node runtime as a 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 to the working directory
COPY package*.json ./

# Install dependencies
RUN npm install

# Copy the application code to the container
COPY . .

# Build the React app
RUN npm run build

# Use Nginx as the base image for serving static files
FROM nginx:alpine

# Copy the built app from the previous stage to the Nginx public directory
COPY --from=build /usr/src/app/build /usr/share/nginx/html

# Expose port 80 for the Nginx server
EXPOSE 80

# The default command to start Nginx when the container runs
CMD ["nginx", "-g", "daemon off;"]
2 changes: 1 addition & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function App() {
</a>{" "}
| Developed by{" "}
<a target="_blank" href="https://www.gauravghai.dev/">
Gaurav Ghai
Biwas Pudasaini
</a>{" "}
| Powered by{" "}
<a target="_blank" href="https://www.htmlhints.com/">
Expand Down