95 lines
2.1 KiB
Plaintext
95 lines
2.1 KiB
Plaintext
// Node Label
|
|
def nodeLabel = "${UUID.randomUUID().toString()}"
|
|
|
|
// Kaniko Image
|
|
def repository = "registry.test-chamber-13.lan"
|
|
def kanikoImage = "${repository}/nhyatt/kaniko:latest"
|
|
def repositoryCreds = "quay-repository-creds"
|
|
|
|
// Container Variables
|
|
def baseImage = "${repository}/nhyatt/alpine"
|
|
def baseImageTag = "latest"
|
|
def alpineJavaPackage = "openjdk11"
|
|
|
|
// PaperMC URL
|
|
def paperMCDownload = "https://papermc.io/api/v1/paper/1.16.3/latest/download"
|
|
|
|
// Minecraft Configuration
|
|
def memoryMin = "1g"
|
|
def memoryMax = "48g"
|
|
|
|
podTemplate(
|
|
name: "pipelineContainer",
|
|
label: nodeLabel,
|
|
yaml: """---
|
|
apiVersion: v1
|
|
kind: Pod
|
|
metadata:
|
|
name: kaniko
|
|
spec:
|
|
containers:
|
|
- name: kaniko
|
|
image: ${kanikoImage}
|
|
imagePullPolicy: Always
|
|
tty: true
|
|
command:
|
|
- /busybox/cat
|
|
""") {
|
|
node (nodeLabel) {
|
|
// Set working directory
|
|
def workspace = pwd()
|
|
|
|
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 ("Pre-Build") {
|
|
def dockerFile = """
|
|
FROM ${baseImage}:${baseImageTag}
|
|
|
|
MAINTAINER The_Spider <spider@smoothnet.org>
|
|
|
|
RUN \\
|
|
apk add --no-cache ${alpineJavaPackage} curl && \\
|
|
addgroup -S -g 1000 minecraft && \\
|
|
adduser -S minecraft -G minecraft -h /minecraft -u 1000
|
|
|
|
USER minecraft
|
|
|
|
WORKDIR /minecraft
|
|
|
|
RUN \
|
|
curl -Ls "${paperMCDownload}" -o /minecraft/paper-mc.jar && \\
|
|
mkdir /minecraft/data && \\
|
|
mkdir /minecraft/html
|
|
|
|
CMD cd data; java -Xms${memoryMin} -Xmx${memoryMax} -jar ../paper-mc.jar
|
|
"""
|
|
|
|
writeFile(file: workspace + '/Dockerfile', text: dockerFile)
|
|
}
|
|
|
|
stage ("Build & Push") {
|
|
container ("kaniko") {
|
|
sh "/kaniko/executor --cleanup --context \"${workspace}\" -f \"${workspace}/Dockerfile\" --destination \"${repository}/nhyatt/minecraft:latest\""
|
|
}
|
|
}
|
|
}
|
|
} |