Updated Mincraft builder to use kaniko and 1.16.1.
This commit is contained in:
parent
b04798bb5c
commit
1ebd511d29
@ -1,10 +1,55 @@
|
|||||||
def dockerFile = """
|
// Node Label
|
||||||
FROM alpine:latest
|
def nodeLabel = "${UUID.randomUUID().toString()}"
|
||||||
|
|
||||||
|
// Kaniko Image
|
||||||
|
def kanikoImage = "gcr.io/kaniko-project/executor:debug"
|
||||||
|
|
||||||
|
// Repository Locations
|
||||||
|
def pushRepo = "registry.test-chamber-13.lan:5000"
|
||||||
|
def pushImage = "minecraft"
|
||||||
|
def pushTag = "latest"
|
||||||
|
|
||||||
|
// Container Variables
|
||||||
|
def baseImage = "alpine"
|
||||||
|
def baseImageTag = "3.12"
|
||||||
|
def alpineJavaPackage = "openjdk11"
|
||||||
|
|
||||||
|
// PaperMC URL
|
||||||
|
def paperMCDownload = "https://papermc.io/api/v1/paper/1.16.1/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 ("Pre-Build") {
|
||||||
|
def dockerFile = """
|
||||||
|
FROM ${baseImage}:${baseImageTag}
|
||||||
|
|
||||||
MAINTAINER The_Spider <spider@smoothnet.org>
|
MAINTAINER The_Spider <spider@smoothnet.org>
|
||||||
|
|
||||||
RUN \\
|
RUN \\
|
||||||
apk add --no-cache openjdk11 curl && \\
|
apk add --no-cache ${alpineJavaPackage} curl && \\
|
||||||
addgroup -S -g 1000 minecraft && \\
|
addgroup -S -g 1000 minecraft && \\
|
||||||
adduser -S minecraft -G minecraft -h /minecraft -u 1000
|
adduser -S minecraft -G minecraft -h /minecraft -u 1000
|
||||||
|
|
||||||
@ -13,63 +58,21 @@ USER minecraft
|
|||||||
WORKDIR /minecraft
|
WORKDIR /minecraft
|
||||||
|
|
||||||
RUN \
|
RUN \
|
||||||
curl -Ls https://papermc.io/api/v1/paper/1.15.2/latest/download -o /minecraft/paper-mc.jar && \\
|
curl -Ls "${paperMCDownload}" -o /minecraft/paper-mc.jar && \\
|
||||||
mkdir /minecraft/data && \\
|
mkdir /minecraft/data && \\
|
||||||
mkdir /minecraft/html && \\
|
mkdir /minecraft/html && \\
|
||||||
cd /minecraft/data && \\
|
cd /minecraft/data && \\
|
||||||
java -jar ../paper-mc.jar; exit 0
|
java -jar ../paper-mc.jar; exit 0
|
||||||
|
|
||||||
CMD cd data; java -Xms1g -Xmx48g -jar ../paper-mc.jar
|
CMD cd data; java -Xms${memoryMin} -Xmx${memoryMax} -jar ../paper-mc.jar
|
||||||
"""
|
"""
|
||||||
|
|
||||||
podTemplate(
|
writeFile(file: workspace + '/Dockerfile', text: dockerFile)
|
||||||
containers: [
|
}
|
||||||
containerTemplate(
|
|
||||||
name: "docker",
|
stage ("Build & Push") {
|
||||||
image: "docker:19.03",
|
container ("kaniko") {
|
||||||
command: "sleep",
|
sh "/kaniko/executor --cleanup --insecure --skip-tls-verify --context \"${workspace}\" -f \"${workspace}/Dockerfile\" --destination \"${pushRepo}/${pushImage}:${pushTag}\""
|
||||||
args: "99d",
|
|
||||||
envVars: [
|
|
||||||
envVar(
|
|
||||||
key: "DOCKER_HOST",
|
|
||||||
value: "tcp://localhost:2375"
|
|
||||||
)
|
|
||||||
]
|
|
||||||
),
|
|
||||||
containerTemplate(
|
|
||||||
name: "docker-daemon",
|
|
||||||
image: "docker:19.03-dind",
|
|
||||||
command: "dockerd-entrypoint.sh",
|
|
||||||
args: "--insecure-registry registry.test-chamber-13.lan:5000",
|
|
||||||
privileged: true,
|
|
||||||
envVars: [
|
|
||||||
envVar(
|
|
||||||
key: "DOCKER_TLS_CERTDIR",
|
|
||||||
value: ""
|
|
||||||
)
|
|
||||||
],
|
|
||||||
)
|
|
||||||
]
|
|
||||||
) {
|
|
||||||
node(POD_LABEL) {
|
|
||||||
container("docker") {
|
|
||||||
stage("Test DinD Daemon") {
|
|
||||||
sh """
|
|
||||||
docker version
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
stage("Write Dockerfile"){
|
|
||||||
writeFile(file: "Dockerfile", text: dockerFile)
|
|
||||||
}
|
|
||||||
stage("Build Container"){
|
|
||||||
sh """
|
|
||||||
docker build --tag registry.test-chamber-13.lan:5000/minecraft:latest ./
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
stage("Push Container"){
|
|
||||||
sh """
|
|
||||||
docker push registry.test-chamber-13.lan:5000/minecraft:latest
|
|
||||||
"""
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user