diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..59dff9b --- /dev/null +++ b/Jenkinsfile @@ -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' + } + } + } + } + } + } +} diff --git a/helmfile.yaml b/helmfile.yaml new file mode 100644 index 0000000..5d9ebf0 --- /dev/null +++ b/helmfile.yaml @@ -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"}}