diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..069870e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ + +# Base image +FROM node:18-alpine + +# Set working directory +WORKDIR /app + +# Install dependencies +COPY package*.json ./ +RUN yarn install +#RUN npm install + +# Copy project files +COPY . . + + +RUN yarn build + +# Expose port +EXPOSE 3000 +CMD ["yarn", "start"] + +# Start the application in development mode +#CMD ["npm", "run", "dev"] diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..f8f7adb --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,27 @@ +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/aqila/aqila_frontend/" + version = "main" + gitBranch = "origin/main" + } + agent any + stages { + stage('deploy'){ + steps{ + script{ + if(gitBranch=="origin/main"){ + withCredentials([usernamePassword(credentialsId: production_server_name, usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) { + sh 'sshpass -p $PASSWORD ssh $USERNAME@$production_server_ip -o StrictHostKeyChecking=no "cd $project_path && ./runner.sh"' + sh "curl -F chat_id=-1002316394394 -F message_thread_id=11 -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}' https://api.telegram.org/bot7207581748:AAFeymryw7S44D86LYfWqYK-tSNeV3TOwBs/sendDocument" + } + } + } + } + } + } +} + diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..dac1fc4 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,16 @@ +version: "3.7" +services: + web: + # container_name: aqila_react + ports: + - 9015:3000 + build: + context: . + dockerfile: Dockerfile + restart: always + networks: + - aqila_backend_aqila + +networks: + aqila_backend_aqila: + external: true diff --git a/runner.sh b/runner.sh new file mode 100755 index 0000000..51b91a0 --- /dev/null +++ b/runner.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# Check if the '--dev' argument is provided +if [ "$1" == "--dev" ]; then + echo "Run development docker" + DOCKER_BUILDKIT=1 COMPOSE_DOCKER_CLI_BUILD=1 docker compose -f docker-compose.yml up -d --build +else + echo "Run Production docker" + + git pull origin main + DOCKER_BUILDKIT=1 COMPOSE_DOCKER_CLI_BUILD=1 docker compose -f docker-compose.yml up -d --build +fi