// Node Label 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 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 --insecure --skip-tls-verify --context \"${workspace}\" -f \"${workspace}/Dockerfile\" --destination \"${pushRepo}/${pushImage}:${pushTag}\"" } } } }