diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..54efa35 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +# Base image +FROM node:18-alpine + +# Set working directory +WORKDIR /usr/src/app + +# Copy package.json and yarn.lock +COPY package.json yarn.lock ./ + +# Install dependencies +RUN yarn install + +# Copy the rest of the application code +COPY . . + +# Build the Next.js application +RUN yarn build + +# Expose the port the app runs on +EXPOSE 3000 + +# Start the application +CMD ["yarn", "start"] diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..7644e79 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,34 @@ +pipeline { + environment { + develop_server_ip = '' + develop_server_name = '' + production_server_ip = "88.99.212.243" + production_server_name = "newhorizon_germany_001_server" + project_path = "/projects/mesbahi/mesbahi_dashboard_frontend" + version = "master" + gitBranch = "origin/master" + } + agent any + stages { + stage('deploy'){ + steps{ + script{ + if(gitBranch=="origin/master"){ + withCredentials([usernamePassword(credentialsId: production_server_name, usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) { + sh 'sshpass -p $PASSWORD ssh -p 1782 $USERNAME@$production_server_ip -o StrictHostKeyChecking=no "cd $project_path && ./runner.sh"' + + def lastCommit = sh(script: 'git log -1 --pretty=format:"%h - %s (%an)"', returnStdout: true).trim() + sh """ + curl -F chat_id=1457670318 \ + -F document=@/var/jenkins_home/jobs/${env.JOB_NAME}/builds/${env.BUILD_NUMBER}/log \ + -F caption='Project name: #${env.JOB_NAME} \nBuild status is ${currentBuild.currentResult} \nBuild url: ${BUILD_URL} \nLast Commit: ${lastCommit}' \ + https://api.telegram.org/bot7207581748:AAFeymryw7S44D86LYfWqYK-tSNeV3TOwBs/sendDocument + """ + } + } + } + } + } + } +} +//TestLine diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..4bed960 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,15 @@ +version: "3.7" +services: + web: + container_name: mesbahi_front + ports: + - 7221:3000 + build: + context: . + dockerfile: Dockerfile + restart: always + networks: + - mesbahi_backend_mesbahi +networks: + mesbahi_backend_mesbahi: + external: true diff --git a/runner.sh b/runner.sh new file mode 100755 index 0000000..b5e9283 --- /dev/null +++ b/runner.sh @@ -0,0 +1 @@ +git pull origin master && docker compose up -d --build