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