diff --git a/1 b/1 new file mode 100644 index 0000000000000..a514896a2bc40 --- /dev/null +++ b/1 @@ -0,0 +1,26 @@ +# Stage 1: Build and install dependencies +FROM node:18-alpine AS builder +WORKDIR /app +COPY package.json package-lock.json ./ +RUN npm install + +# Copy the rest of your application code +COPY . . + +# Build your application if necessary (uncomment the next line if you have a build script) +# RUN npm run build + +# Stage 2: Setup the production environment +FROM node:18-alpine +WORKDIR /app + +# Only copy necessary files from the builder stage +COPY --from=builder /app/node_modules ./node_modules +COPY --from=builder /app . + +# Expose the port the app runs on +EXPOSE 3000 + +# Define the command to run your app +CMD ["node", "server.js"] + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000000..3cd8e100cc36b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +# مرحلة البناء +FROM node:20-alpine AS build + +WORKDIR /usr/src/app + +COPY . . + +RUN npm install --legacy-peer-deps + +# مرحلة الإنتاج +FROM node:20-alpine + +WORKDIR /usr/src/app + +COPY --from=build /usr/src/app . + +ENV HOST=0.0.0.0 + +EXPOSE 3000 + +CMD ["npx", "turbo", "dev"] + diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000000000..183e4493ebc1a --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,66 @@ +pipeline { + agent any + + environment { + DOCKER_HUB_CREDENTIALS = 'docker-hub-credentials' // ID الخاص بـ Docker Hub Credentials + DOCKER_IMAGE = 'bedomm180/ci-app' // اسم الصورة على Docker Hub + GITHUB_CREDENTIALS = 'github-credentials2' // ID الخاص بـ GitHub Credentials + GITHUB_REPO = 'https://github.com/abdelrahmanonline4/nodejs.org' // رابط الـ GitHub Repo + } + + stages { + stage('Checkout or Fetch Code') { + steps { + // جلب الكود من GitHub باستخدام الـ credentials + git credentialsId: "${GITHUB_CREDENTIALS}", url: "${GITHUB_REPO}" + } + } + + stage('Install Dependencies') { + steps { + script { + // تثبيت التبعيات باستخدام npm + sh 'npm install' + } + } + } + + stage('Run Unit Testing') { + steps { + script { + // تشغيل اختبارات الوحدة + sh 'npm test' + } + } + } + + stage('Dockerize') { + steps { + script { + // بناء الصورة باستخدام Dockerfile الموجود في المستودع + docker.build("${DOCKER_IMAGE}") + } + } + } + + stage('Push Docker Image') { + steps { + script { + // استخدام الـ credentials لدفع الصورة إلى Docker Hub + docker.withRegistry('https://index.docker.io/v1/', "${DOCKER_HUB_CREDENTIALS}") { + docker.image("${DOCKER_IMAGE}").push('latest') + } + } + } + } + } + + post { + success { + echo 'Build, test, and push completed successfully!' + } + failure { + echo 'Build, test, or push failed!' + } + } +}