Commit 9a396936 authored by Josh Steinberg's avatar Josh Steinberg

update dockerfile and jenkinsfile

parent 7b60daa4
FROM maven:3.6.0-jdk-11-slim AS TEMP_BUILD_IMAGE # FROM maven:3.6.0-jdk-11-slim AS TEMP_BUILD_IMAGE
# RUN gradle build || return 0 # # RUN gradle build || return 0
COPY src /home/app/src # COPY src /home/app/src
COPY pom.xml /home/app # COPY pom.xml /home/app
RUN mvn -f /home/app/pom.xml clean package # RUN mvn -f /home/app/pom.xml clean package
# actual container # actual container
FROM openjdk:11-jre-slim FROM amazoncorretto:11-alpine-jdk
COPY --from=TEMP_BUILD_IMAGE /home/app/target/spring-boot-complete-0.0.1-SNAPSHOT.jar /usr/local/lib/hello-world.jar COPY target/spring-boot-complete-0.0.1-SNAPSHOT.jar /usr/local/lib/hello-world.jar
EXPOSE 8080 EXPOSE 8082
ENTRYPOINT ["java","-jar","/usr/local/lib/hello-world.jar"] ENTRYPOINT ["java","-jar","/usr/local/lib/hello-world.jar"]
\ No newline at end of file
pipeline { pipeline {
agent{ agent {
kubernetes { kubernetes {
//cloud 'kubernetes' //cloud 'kubernetes'
defaultContainer 'kaniko' defaultContainer 'kaniko'
yaml ''' yaml '''
...@@ -17,18 +17,9 @@ pipeline { ...@@ -17,18 +17,9 @@ pipeline {
volumeMounts: volumeMounts:
- name: jenkins-docker-cfg - name: jenkins-docker-cfg
mountPath: /kaniko/.docker mountPath: /kaniko/.docker
volumes:
- name: jenkins-docker-cfg
projected:
sources:
- secret:
name: regcred
items:
- key: .dockerconfigjson
path: config.json
''' '''
} }
}
tools{ tools{
maven 'maven' maven 'maven'
} }
...@@ -67,43 +58,44 @@ pipeline { ...@@ -67,43 +58,44 @@ pipeline {
} }
} }
} }
// stage("Pulbish to Nexus"){ stage("Pulbish to Nexus"){
// steps{ steps{
// script{ script{
// pom = readMavenPom file: "pom.xml"; pom = readMavenPom file: "pom.xml";
// filesByGlob = findFiles(glob: "target/*.${pom.packaging}"); filesByGlob = findFiles(glob: "target/*.${pom.packaging}");
// echo "${filesByGlob[0].name} ${filesByGlob[0].path} ${filesByGlob[0].directory} ${filesByGlob[0].length} ${filesByGlob[0].lastModified}" echo "${filesByGlob[0].name} ${filesByGlob[0].path} ${filesByGlob[0].directory} ${filesByGlob[0].length} ${filesByGlob[0].lastModified}"
// artifactPath = filesByGlob[0].path; artifactPath = filesByGlob[0].path;
// artifactExists = fileExists artifactPath; artifactExists = fileExists artifactPath;
// if(artifactExists) { if(artifactExists) {
// echo "*** File: ${artifactPath}, group: ${pom.groupId}, packaging: ${pom.packaging}, version ${pom.version}"; echo "*** File: ${artifactPath}, group: ${pom.groupId}, packaging: ${pom.packaging}, version ${pom.version}";
// nexusArtifactUploader( nexusArtifactUploader(
// nexusVersion: NEXUS_VERSION, nexusVersion: NEXUS_VERSION,
// protocol: NEXUS_PROTOCOL, protocol: NEXUS_PROTOCOL,
// nexusUrl: NEXUS_URL, nexusUrl: NEXUS_URL,
// groupId: pom.groupId, groupId: pom.groupId,
// version: pom.version, version: pom.version,
// repository: NEXUS_REPOSITORY, repository: NEXUS_REPOSITORY,
// credentialsId: NEXUS_CREDENTIAL_ID, credentialsId: NEXUS_CREDENTIAL_ID,
// artifacts: [ artifacts: [
// [artifactId: pom.artifactId, [artifactId: pom.artifactId,
// classifier: '', classifier: '',
// file: artifactPath, file: artifactPath,
// type: pom.packaging], type: pom.packaging],
// [artifactId: pom.artifactId, [artifactId: pom.artifactId,
// classifier: '', classifier: '',
// file: "pom.xml", file: "pom.xml",
// type: "pom"] type: "pom"]
// ] ]
// ); );
// } else { } else {
// error "*** File: ${artifactPath}, could not be found"; error "*** File: ${artifactPath}, could not be found";
// } }
// } }
// } }
// } }
stage("Publish Docker Image to Nexus"){ stage("Pull Artifact and Build Container"){
steps{ steps{
container(name: 'kaniko', shell: '/busybox/sh'){ container(name: 'kaniko', shell: '/busybox/sh'){
sh "pwd" sh "pwd"
sh "ls" sh "ls"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment