-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDocker-Image.Jenkins
More file actions
63 lines (63 loc) · 1.87 KB
/
Docker-Image.Jenkins
File metadata and controls
63 lines (63 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
pipeline {
agent {
kubernetes {
cloud 'home-kubernetes'
yaml '''
apiVersion: v1
kind: Pod
spec:
nodeSelector:
kubernetes.io/arch: arm64
securityContext:
runAsUser: 0
runAsGroup: 0
fsGroup: 0
containers:
- name: buildkit
image: moby/buildkit:master
tty: true
resources:
requests:
cpu: "1"
memory: "4Gi"
limits:
cpu: "1"
memory: "4Gi"
securityContext:
privileged: true
'''
}
}
environment {
ACR_AUTH = credentials('ecv-vardyngportfolio-azure')
DOCKERHUB_PASSWORD = credentials('dockerhub-vardyng-password')
}
stages {
stage('Config config.json') {
steps {
container('buildkit') {
sh '''
echo "Configuring config.json"
mkdir -p ~/.docker
echo "{\\"auths\\":{\\"https://index.docker.io/v1/\\":{\\"auth\\":\\"${DOCKERHUB_PASSWORD}\\"},\\"vardyngportfolio.azurecr.io\\":{\\"auth\\":\\"${ACR_AUTH}\\"}}}" >> ~/.docker/config.json
'''
}
}
}
stage('Build and Push Docker Images') {
steps {
container('buildkit') {
checkout([$class: 'GitSCM', branches: [[name: 'prod']], extensions: [], userRemoteConfigs: [[credentialsId: 'vardyng-github-pat', url: 'https://github.com/VardyNg/Portfolio.git']]])
sh '''
echo "Building Docker Image"
buildctl build \
--frontend dockerfile.v0 \
--local context=. \
--local dockerfile=. \
--output type=image,\\"name=vardyng/portfolio:latest,vardyngportfolio.azurecr.io/portfolio:latest\\",push=true
'''
}
}
}
}
}