Skip to content

Commit

Permalink
Merge pull request #42 from choxx/jenkins_setup
Browse files Browse the repository at this point in the history
Jenkins support
  • Loading branch information
ChakshuGautam authored Oct 19, 2022
2 parents 533512f + 3bd0d5c commit 4db7007
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ redisinsight
broker
.env
migrations/
dist/
dist/
.idea
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM node:16 AS builder

# Create app directory
WORKDIR /app

#RUN cp .env .env
RUN mkdir -p broker
RUN mkdir -p redisinsight
RUN chown -R 1001:1001 broker
RUN chown -R 1001:1001 redisinsight

COPY package.json ./
COPY yarn.lock ./

# Install app dependencies
RUN yarn install

COPY . .

# Generate build
RUN yarn run build

CMD [ "npx", "nx", "serve", "api" ]
34 changes: 34 additions & 0 deletions build/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
node() {
properties([
parameters([
string(name: 'docker_repo', defaultValue: 'yaus-web', description: 'Docker Image Name'),
string(name: 'docker_server', defaultValue: 'localhost:5000', description: 'Docker Registry URL'),

])
])
stage('Checkout') {
cleanWs()
checkout scm
commit_hash = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim()
env.commit_id = sh(script: 'echo ' + env.docker_repo + '_' + commit_hash + '_' + env.BRANCH_NAME, returnStdout: true).trim()
echo "${env.commit_id}"
}

stage('docker-build') {
sh '''
# docker build -f <location-of-docker-file> -t <tag-of-docker-image> <context-for-docker-image>
docker build -f ./Dockerfile -t $docker_server/$docker_repo:$commit_id .
'''
}

stage('docker-push') {
sh '''
docker push $docker_server/$docker_repo:$commit_id
'''
}
stage('ArchiveArtifacts') {
sh("echo ${commit_id} > commit_id.txt")
archiveArtifacts 'commit_id.txt'
currentBuild.description = "${commit_id}"
}
}

0 comments on commit 4db7007

Please sign in to comment.