Skip to content

Commit 4776eaf

Browse files
committed
Refactor: Improve containerization and deployment
1 parent 75a7050 commit 4776eaf

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Jenkinsfile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ pipeline {
5252
}
5353
}
5454
}
55-
stage('Containerize') {
55+
stage('Creating Image') {
5656
steps {
57+
docker.build("my-image:${env.BUILD_ID}")
5758
script {
58-
sh 'echo "Containerizing..."'
59-
sh 'docker build -t app .'
59+
sh 'echo "Creating Image..."'
6060
// Create manifest file for container
6161
sh '''cat <<EOF > app.yaml
6262
apiVersion: apps/v1
@@ -75,18 +75,18 @@ pipeline {
7575
spec:
7676
containers:
7777
- name: app
78-
image: app
78+
image: my-image:${env.BUILD_ID}
7979
ports:
8080
- containerPort: 3000
8181
EOF'''
8282
}
8383
}
8484
}
85-
stage('Deploy Container') {
85+
stage('Deploy') {
8686
steps {
8787
script {
8888
withKubeConfig([credentialsId: 'kubeconfig', serverUrl: 'https://kubernetes.default.svc.cluster.local']) {
89-
sh 'echo "Deploying Container..."'
89+
sh 'echo "Deploying..."'
9090
sh 'kubectl apply -f app.yaml'
9191
sh 'kubectl get pods --watch'
9292
sh 'until kubectl get pods | grep app | grep -m 1 "Running"; do sleep 5; done'

0 commit comments

Comments
 (0)