75 lines
2.5 KiB
Plaintext
75 lines
2.5 KiB
Plaintext
def repository = "registry.c.test-chamber-13.lan"
|
|
def repositoryCreds = "harbor-repository-creds"
|
|
|
|
def paperVersion = "1.18.1"
|
|
def memoryMin = "1g"
|
|
def memoryMax = "48g"
|
|
|
|
def dockerFile = """FROM registry.c.test-chamber-13.lan/library/alpine:latest as builder
|
|
|
|
ARG paperDownload
|
|
|
|
RUN addgroup -S -g 1000 minecraft && \\
|
|
adduser --disabled-password -G minecraft --gecos "application account" --home "/minecraft" --shell "/sbin/nologin" --uid 1000 minecraft && \\
|
|
apk add --no-cache curl && \\
|
|
mkdir /minecraft/data && \\
|
|
mkdir /minecraft/html && \\
|
|
curl --location --fail --silent \${paperDownload} -o /minecraft/paper-mc.jar
|
|
|
|
FROM gcr.io/distroless/java17:latest
|
|
|
|
LABEL org.opencontainers.image.authors="The_Spider <spider@smoothnet.org>"
|
|
|
|
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
|
COPY --from=builder /etc/passwd /etc/group /etc/
|
|
COPY --from=builder --chown=minecraft:minecraft /minecraft/ /minecraft/
|
|
|
|
USER minecraft
|
|
|
|
WORKDIR /minecraft/data
|
|
|
|
ENTRYPOINT ["/usr/bin/java", "-Xms${memoryMin}", "-Xmx${memoryMax}", "-jar"]
|
|
CMD ["../paper-mc.jar"]
|
|
"""
|
|
|
|
def label = "kubernetes-${UUID.randomUUID().toString()}"
|
|
def templateName = "pipeline-worker"
|
|
podTemplate(
|
|
label: label,
|
|
name: templateName,
|
|
yaml: functions.podYaml(
|
|
repo: repository,
|
|
templateName: templateName,
|
|
kaniko: true,
|
|
alpine: true
|
|
)
|
|
) {
|
|
node (label) {
|
|
def workspace = pwd()
|
|
|
|
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()
|
|
}
|
|
}
|
|
|
|
functions.buildContainer(
|
|
repository: repository,
|
|
imageDest: "${repository}/library/the-spider:latest",
|
|
dockerFile: dockerFile,
|
|
repoCreds: repositoryCreds,
|
|
[
|
|
"paperDownload=${paperDownload}"
|
|
]
|
|
)
|
|
}
|
|
}
|