Browse Source
feat: add Dockerfile and docker-compose.yml for containerized application setup
master
feat: add Dockerfile and docker-compose.yml for containerized application setup
master
4 changed files with 106 additions and 0 deletions
-
7.dockerignore
-
28Dockerfile
-
46Jenkinsfile
-
25docker-compose.yml
@ -0,0 +1,7 @@ |
|||
node_modules |
|||
.next |
|||
.git |
|||
.gitignore |
|||
README.md |
|||
.env* |
|||
npm-debug.log* |
|||
@ -0,0 +1,28 @@ |
|||
FROM node:20-alpine AS base |
|||
|
|||
FROM base AS deps |
|||
RUN apk add --no-cache libc6-compat |
|||
WORKDIR /app |
|||
COPY package.json package-lock.json* ./ |
|||
RUN npm ci |
|||
|
|||
FROM base AS builder |
|||
WORKDIR /app |
|||
COPY --from=deps /app/node_modules ./node_modules |
|||
COPY . . |
|||
ARG NEXT_PUBLIC_API_URL |
|||
ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL |
|||
RUN npm run build |
|||
|
|||
FROM base AS runner |
|||
WORKDIR /app |
|||
ENV NODE_ENV=production |
|||
RUN addgroup --system --gid 1001 nodejs && \ |
|||
adduser --system --uid 1001 nextjs |
|||
COPY --from=builder /app/public ./public |
|||
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ |
|||
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static |
|||
USER nextjs |
|||
EXPOSE 3000 |
|||
ENV PORT=3000 HOSTNAME="0.0.0.0" |
|||
CMD ["node", "server.js"] |
|||
@ -0,0 +1,46 @@ |
|||
pipeline { |
|||
environment { |
|||
develop_server_ip = '' |
|||
develop_server_name = '' |
|||
production_server_ip = "88.99.212.243" |
|||
production_server_name = "newhorizon_germany_001_server" |
|||
project_path = "/najm/marriage" |
|||
version = "master" |
|||
gitBranch = "origin/master" |
|||
} |
|||
agent any |
|||
stages { |
|||
stage('deploy') { |
|||
steps { |
|||
script { |
|||
if (gitBranch == "origin/master") { |
|||
try { |
|||
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"' |
|||
} |
|||
} catch (Exception e) { |
|||
def lastCommit = sh(script: 'git log -1 --pretty=format:"%h - %s (%an)"', returnStdout: true).trim() |
|||
sh """ |
|||
curl -F chat_id=-1002316394394 \ |
|||
-F message_thread_id=1629 \ |
|||
-F document=@/var/jenkins_home/jobs/${env.JOB_NAME}/builds/${env.BUILD_NUMBER}/log \ |
|||
-F caption='Project name: #${env.JOB_NAME} \nBuild status is FAILED \nBuild url: ${BUILD_URL} \nLast Commit: ${lastCommit}' \ |
|||
https://api.telegram.org/bot7207581748:AAFeymryw7S44D86LYfWqYK-tSNeV3TOwBs/sendDocument |
|||
""" |
|||
currentBuild.result = 'FAILURE' |
|||
throw e |
|||
} |
|||
def lastCommit = sh(script: 'git log -1 --pretty=format:"%h - %s (%an)"', returnStdout: true).trim() |
|||
sh """ |
|||
curl -F chat_id=-1002316394394 \ |
|||
-F message_thread_id=1629 \ |
|||
-F document=@/var/jenkins_home/jobs/${env.JOB_NAME}/builds/${env.BUILD_NUMBER}/log \ |
|||
-F caption='Project name: #${env.JOB_NAME} \nBuild status is SUCCESS \nBuild url: ${BUILD_URL} \nLast Commit: ${lastCommit}' \ |
|||
https://api.telegram.org/bot7207581748:AAFeymryw7S44D86LYfWqYK-tSNeV3TOwBs/sendDocument |
|||
""" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,25 @@ |
|||
services: |
|||
web: |
|||
build: |
|||
context: . |
|||
dockerfile: Dockerfile |
|||
args: |
|||
NEXT_PUBLIC_API_URL: http://localhost:3000/api |
|||
ports: |
|||
- "5561:3000" |
|||
environment: |
|||
- NODE_ENV=production |
|||
- NEXT_PUBLIC_API_URL=http://localhost:3000/api |
|||
restart: unless-stopped |
|||
healthcheck: |
|||
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3000"] |
|||
interval: 30s |
|||
timeout: 10s |
|||
retries: 3 |
|||
start_period: 40s |
|||
networks: |
|||
- najm_najm |
|||
|
|||
networks: |
|||
najm_najm: |
|||
external: true |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue