This commit is contained in:
areeqakbr 2025-02-25 10:43:07 +07:00
parent 6de2533ec7
commit eb5315a3fa
1 changed files with 38 additions and 4 deletions

42
Jenkinsfile vendored
View File

@ -1,5 +1,26 @@
pipeline { pipeline {
agent {dockerfile true} agent {
kubernetes {
yaml '''
apiVersion: v1
kind: Pod
spec:
containers:
- name: docker
image: docker:latest
command:
- cat
tty: true
volumeMounts:
- name: docker-sock
mountPath: /var/run/docker.sock
volumes:
- name: docker-sock
hostPath:
path: /var/run/docker.sock
'''
}
}
environment { environment {
REGISTRY_URL = 'git.winteraccess.id' REGISTRY_URL = 'git.winteraccess.id'
@ -25,10 +46,23 @@ pipeline {
} }
stage('Build and Push Docker Image') { stage('Build and Push Docker Image') {
steps{ steps {
sh 'go --version' container('docker') { // Runs in the Docker container inside Kubernetes
script {
def imageTag = "dev-${env.SHORT_SHA}"
sh """
docker build -t ${REGISTRY_URL}/${IMAGE_NAME}:${imageTag} \
-t ${REGISTRY_URL}/${IMAGE_NAME}:dev \
-t ${REGISTRY_URL}/${IMAGE_NAME}:latest \
-f deploy/docker/Dockerfile .
docker push ${REGISTRY_URL}/${IMAGE_NAME}:${imageTag}
docker push ${REGISTRY_URL}/${IMAGE_NAME}:dev
docker push ${REGISTRY_URL}/${IMAGE_NAME}:latest
"""
}
}
} }
} }
stage('Deploy to Kubernetes') { stage('Deploy to Kubernetes') {