Switched to node builder

This commit is contained in:
Jonathan Ervine 2020-07-20 22:54:18 +08:00
parent 34900e61f5
commit c45b361335
2 changed files with 36 additions and 29 deletions

View File

@ -9,15 +9,14 @@ ENV LANG='en_US.UTF-8' \
FLASK_APP=/data/app-dev/app.py
RUN apk update && \
apk -U upgrade && \
apk -U add python3 gcc py3-pip python3-dev musl-dev libffi-dev git && \
adduser -D python
apk -U upgrade && \
apk -U add python3 gcc py3-pip python3-dev musl-dev libffi-dev git && \
adduser -D python
RUN mkdir /data && cd /data && git clone --single-branch --branch dev https://git.ervine.org/jonny/gcp-hockey-results /data
RUN pip3 install -r /data/requirements.txt
RUN rm -rf /tmp/src && rm -rf /var/cache/apk/*
RUN pip3 install -r /data/requirements.txt && \
rm -rf /tmp/src && rm -rf /var/cache/apk/*
EXPOSE 3000

54
Jenkinsfile vendored
View File

@ -1,26 +1,34 @@
node("docker-node") {
docker.withRegistry('https://harbor.ervine.dev', 'jenkins-to-harbor') {
git branch: "master", url: "ssh://git@git.ervine.org/jonny/x86_64-alpine-hockey", credentialsId: 'jenkins-to-git'
sh "git rev-parse HEAD > .git/commit-id"
def commit_id = readFile('.git/commit-id').trim()
println commit_id
try {
stage "build"
def app = docker.build "library/x86_64/alpine/hockey"
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
"""
) {
stage('Deploy on K8s'){
sh "/usr/local/bin/kubectl -n dev delete po --all"
}
}
catch (err) {
currentBuild.result = 'FAILURE'
}
node(POD_LABEL) {
stage('Build with Kaniko') {
git url: 'ssh://git@git.ervine.org/jonny/x86_64-alpine-hockey.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/hockey:3.12.0 --destination=harbor.ervine.dev/library/x86_64/alpine/hockey:3.12'
}
}
}
}