moves dockerfile stage

This commit is contained in:
Hyatt 2021-12-09 09:36:49 -06:00
parent 36ff86ed86
commit 6c794f1139
Signed by: nhyatt
GPG Key ID: C50D0BBB5BC40BEA

View File

@ -44,8 +44,44 @@ spec:
// Set working directory // Set working directory
def workspace = pwd() def workspace = pwd()
// Set dockerfile stage ("Prepare Kaniko") {
def dockerFile = """ container ("kaniko") {
withCredentials([usernameColonPassword(
credentialsId: repositoryCreds,
variable: "dCreds",
)]) {
def dockerJSON = """{
"auths": {
"${repository}": {
"auth": "${dcreds.bytes.encodeBase64().toString()}"
}
}
}"""
sh """
set +x
echo '${dockerJSON}' > /kaniko/.docker/config.json
"""
}
}
}
stage ("Get Paper-MC Version") {
container ("alpine") {
sh "apk add --no-cache curl jq"
paperDownload = sh (
script: """
paperBuild=\$(curl --silent --location --fail https://papermc.io/api/v2/projects/paper/versions/${paperVersion} | jq '.builds | max')
paperFile=\$(curl --silent --location --fail https://papermc.io/api/v2/projects/paper/versions/${paperVersion}/builds/\${paperBuild} | jq '.downloads.application.name')
echo https://papermc.io/api/v2/projects/paper/versions/${paperVersion}/builds/\${paperBuild}/downloads/\${paperFile}
""",
returnStdout: true
).trim()
}
}
stage ("Create Dockerfile") {
// Set dockerfile
def dockerFile = """
FROM ${buildImage}:${buildImageTag} as builder FROM ${buildImage}:${buildImageTag} as builder
@ -68,46 +104,9 @@ WORKDIR /minecraft/data
CMD ["java", "-Xms${memoryMin}", "-Xmx${memoryMax}", "-jar ../paper-mc.jar"] CMD ["java", "-Xms${memoryMin}", "-Xmx${memoryMax}", "-jar ../paper-mc.jar"]
""" """
stage ("Prepare Kaniko") {
container ("kaniko") {
withCredentials([usernameColonPassword(
credentialsId: repositoryCreds,
variable: "dCreds",
)]) {
def dockerJSON = """{
"auths": {
"${repository}": {
"auth": "${dcreds.bytes.encodeBase64().toString()}"
}
}
}"""
sh """
set +x
echo '${dockerJSON}' > /kaniko/.docker/config.json
"""
}
}
}
stage ("Create Dockerfile") {
writeFile(file: workspace + '/Dockerfile', text: dockerFile) writeFile(file: workspace + '/Dockerfile', text: dockerFile)
} }
stage ("Get Paper-MC Version") {
container ("alpine") {
sh "apk add --no-cache curl jq"
paperDownload = sh (
script: """
paperBuild=\$(curl --silent --location --fail https://papermc.io/api/v2/projects/paper/versions/${paperVersion} | jq '.builds | max')
paperFile=\$(curl --silent --location --fail https://papermc.io/api/v2/projects/paper/versions/${paperVersion}/builds/\${paperBuild} | jq '.downloads.application.name')
echo https://papermc.io/api/v2/projects/paper/versions/${paperVersion}/builds/\${paperBuild}/downloads/\${paperFile}
""",
returnStdout: true
).trim()
}
}
stage ("Build & Push") { stage ("Build & Push") {
container ("kaniko") { container ("kaniko") {
sh """ sh """