From 13a925fcfbe16ff0cb5fd643acb729de62623b63 Mon Sep 17 00:00:00 2001 From: Jonathan Ervine Date: Tue, 21 Jul 2020 19:40:12 +0800 Subject: [PATCH] Switched to node builder and updated to Alpine 3.12 --- Dockerfile | 15 +++++++-------- Jenkinsfile | 47 ++++++++++++++++++++++++++++++++--------------- 2 files changed, 39 insertions(+), 23 deletions(-) diff --git a/Dockerfile b/Dockerfile index 61a6428..dd6cbf3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Base on latest (edge) alpine image -FROM harbor.ervine.dev/library/x86_64/alpine/alpine-3.11 +FROM harbor.ervine.dev/library/x86_64/alpine/alpine-3.12 MAINTAINER “Jonathan Ervine” @@ -10,13 +10,12 @@ ENV LANG='en_US.UTF-8' \ ADD requirements.txt /tmp/requirements.txt -RUN apk update -RUN apk -U upgrade -RUN apk -U add python3 gcc python3-dev musl-dev libffi-dev -RUN adduser -D python -RUN pip3 install -r /tmp/requirements.txt - -RUN rm -rf /tmp/src && rm -rf /var/cache/apk/* && rm -f /tmp/requirements.txt +RUN apk update && \ + apk -U upgrade --ignore alpine-baselayout && \ + apk -U add python3 gcc python3-dev musl-dev libffi-dev && \ + adduser -D python && \ + pip3 install -r /tmp/requirements.txt && \ + rm -rf /tmp/src && rm -rf /var/cache/apk/* && rm -f /tmp/requirements.txt EXPOSE 3000 diff --git a/Jenkinsfile b/Jenkinsfile index c967b6f..4fac1af 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,17 +1,34 @@ -node("docker-node") { - docker.withRegistry('https://harbor.ervine.dev', 'jenkins-to-harbor') { - - git branch: "3.11.6", url: "ssh://git@git.ervine.org/jonny/x86_64-alpine-python", credentialsId: 'jenkins-to-git' - - sh "git rev-parse HEAD > .git/commit-id" - def commit_id = readFile('.git/commit-id').trim() - println commit_id - - stage "build" - def app = docker.build "library/x86_64/alpine/python" - - stage "publish" - app.push("${env.BUILD_NUMBER}") - app.push("latest") +podTemplate(yaml: """ +kind: Pod +spec: + containers: + - name: kaniko + image: gcr.io/kaniko-project/executor:debug-539ddefcae3fd6b411a95982a830d987f4214251 + imagePullPolicy: Always + command: + - /busybox/cat + tty: true + volumeMounts: + - name: jenkins-docker-cfg + mountPath: /kaniko/.docker + volumes: + - name: jenkins-docker-cfg + projected: + sources: + - secret: + name: regcred + items: + - key: .dockerconfigjson + path: config.json +""" + ) { + + node(POD_LABEL) { + stage('Build with Kaniko') { + git url: 'ssh://git@git.ervine.org/jonny/x86_64-alpine.git', credentialsId: 'jenkins-to-git' + container('kaniko') { + sh '/kaniko/executor -f `pwd`/Dockerfile -c `pwd` --cache=true --destination=harbor.ervine.dev/library/x86_64/alpine/python:3.12.0 --destination=harbor.ervine.dev/library/x86_64/alpine/python:3.12' + } } + } }