diff --git a/build-satasfactory.jenkins b/build-satasfactory.jenkins index d005e0d..e7d3bb6 100644 --- a/build-satasfactory.jenkins +++ b/build-satasfactory.jenkins @@ -1,51 +1,7 @@ -def label = "jenkins-${UUID.randomUUID().toString()}" - def repository = "registry.c.test-chamber-13.lan" -def kanikoImage = "${repository}/library/kaniko:latest" def repositoryCreds = "harbor-repository-creds" -podTemplate( - label: label, - name: "pipeline-worker", - yaml: """--- -apiVersion: v1 -kind: Pod -spec: - containers: - - name: kaniko - image: ${kanikoImage} - tty: true - command: - - /busybox/cat -""", -) { - node (label) { - 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("Kaniko Build & Push") { - container ("kaniko") { - def dockerfile = """ +def dockerfile = """ FROM ${repository}/dockerhub/cm2network/steamcmd:latest EXPOSE 15777/udp @@ -59,9 +15,31 @@ WORKDIR /home/steam/SatisfactoryDedicatedServer ENTRYPOINT ["/bin/bash" "-c" "./FactoryServer.sh -multihome=0.0.0.0"] """ - writeFile (file: workspace + "/Dockerfile", text: dockerfile) - sh "/kaniko/executor --context \"${workspace}\" -f \"${workspace}/Dockerfile\" --destination \"${repository}/library/statafactory-server:latest\"" - } - } - } -} \ No newline at end of file + +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) { + functions.buildContainer( + repository: repository, + imageDest: "${repository}/library/statafactory-server:latest", + dockerFile: dockerFile, + repoCreds: repositoryCreds, + ) + functions.deletePod( + kubeAuth: "rancher-admin-token", + kubeURL: "https://rancher.test-chamber-13.lan/k8s/clusters/c-mc9cq", + namespace: "game-servers", + selector: "app=satasfactory" + ) + } +}