diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 000000000..520b12ae5 --- /dev/null +++ b/Jenkinsfile @@ -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' + + } + } + } + + } +} diff --git a/dockerfile b/dockerfile new file mode 100644 index 000000000..5b477bc75 --- /dev/null +++ b/dockerfile @@ -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;"] diff --git a/src/App.js b/src/App.js index 1bd853c72..c13583784 100644 --- a/src/App.js +++ b/src/App.js @@ -14,7 +14,7 @@ function App() { {" "} | Developed by{" "} - Gaurav Ghai + Biwas Pudasaini {" "} | Powered by{" "}