Browse Source

production

main
root 3 days ago
parent
commit
ea2ed9fc37
  1. 24
      Dockerfile
  2. 27
      Jenkinsfile
  3. 16
      docker-compose.yml
  4. 12
      runner.sh

24
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"]

27
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"
}
}
}
}
}
}
}

16
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

12
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
Loading…
Cancel
Save