Add CI/CD setup
Some checks failed
moritz/project-x/pipeline/head There was a failure building this commit

This commit is contained in:
Markus Köbele
2023-11-27 20:31:04 +01:00
parent 5e03d752c3
commit dd715cef39
3 changed files with 119 additions and 0 deletions

0
.gitignore vendored Normal file
View File

63
Jenkinsfile vendored Normal file
View File

@@ -0,0 +1,63 @@
podTemplate(
yaml: '''
apiVersion: v1
kind: Pod
spec:
containers:
- name: docker
image: docker:24.0.7-cli
command:
- sleep
args:
- 99d
resources:
requests:
cpu: "512m"
memory: "1Gi"
limits:
memory: "1Gi"
- name: helmfile
image: ghcr.io/helmfile/helmfile:v0.158.1
command:
- sleep
args:
- 99d
''') {
node(POD_LABEL) {
ansiColor('xterm') {
stage('Checkout') {
checkout scm
}
container('docker') {
stage('build and push image') {
withCredentials([file(credentialsId: 'harbor-docker-config', variable: 'DOCKER_CONFIG_FILE')]) {
sh "mkdir .docker"
sh "cp ${DOCKER_CONFIG_FILE} ${WORKSPACE}/.docker/config.json"
withEnv(["DOCKER_CONFIG=${WORKSPACE}/.docker/"]) {
sh """
docker buildx create --name buildkitd --driver remote tcp://buildkitd.buildkitd.svc.cluster.local:12345
docker buildx use buildkitd
docker buildx install
docker build --push -t core.harbor.koebele-online.de/library/project-x:$BUILD_NUMBER .
"""
}
}
}
}
container('helmfile') {
withCredentials([usernamePassword(credentialsId: 'harbor-robot', passwordVariable: 'HARBOR_PASSWORD', usernameVariable: 'HARBOR_USER')]) {
stage('helmfile lint') {
sh 'helmfile lint'
}
if (env.BRANCH_NAME == "main") {
stage('helmfile sync') {
sh 'helmfile sync'
}
}
}
}
}
}
}

56
helmfile.yaml Normal file
View File

@@ -0,0 +1,56 @@
repositories:
- name: gabibbo97
url: https://gabibbo97.github.io/charts/
- name: bjw-s
url: https://bjw-s.github.io/helm-charts
releases:
- name: project-x
namespace: project-x
chart: bjw-s
values:
- controllers:
main:
imagePullSecrets:
- registry-credentials
strategy: Recreate
containers:
main:
image:
repository: core.harbor.koebele-online.de/library/project-x
tag: {{ requiredEnv "BUILD_NUMBER"}}
pullPolicy: IfNotPresent
- service:
main:
ports:
http:
port: 80
- ingress:
main:
enabled: true
annotations:
kubernetes.io/ingress.class: "nginx"
cert-manager.io/cluster-issuer: "letsencrypt-prod"
hosts:
- host: project-x.moritz.koebele-online.de
paths:
- path: /
pathType: ImplementationSpecific
service:
name: main
port: http
tls:
- hosts:
- project-x.moritz.koebele-online.de
secretName: epaper-weekly-calendar-tls
wait: true
- name: imagepullsecrets
namespace: project-x
chart: gabibbo97/imagepullsecrets
version: 3.0.0
values:
- imagePullSecret:
secretName: registry-credentials
registryURL: core.harbor.koebele-online.de
username: {{ requiredEnv "HARBOR_USER"}}
password: {{ requiredEnv "HARBOR_PASSWORD"}}