-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathJenkinsfile
More file actions
30 lines (29 loc) · 1.07 KB
/
Jenkinsfile
File metadata and controls
30 lines (29 loc) · 1.07 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
pipeline {
agent any
stages {
stage('Checkout') {
steps {
checkout scm
}
}
stage('Build') {
steps {
sh 'docker build . -t $AWS_ACCOUNT_ID.dkr.ecr.$REGION.amazonaws.com/frontend'
}
}
stage('Push Image') {
steps {
sh 'aws ecr get-login-password --region $REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$REGION.amazonaws.com'
sh 'aws ecr describe-repositories --repository-names frontend || aws ecr create-repository --repository-name frontend'
sh 'docker push $AWS_ACCOUNT_ID.dkr.ecr.$REGION.amazonaws.com/frontend'
}
}
stage('Deploy') {
steps {
sh 'docker pull $AWS_ACCOUNT_ID.dkr.ecr.$REGION.amazonaws.com/frontend'
sh 'docker rm -f frontend || true'
sh 'docker run -d -p "2001:80" --name frontend $AWS_ACCOUNT_ID.dkr.ecr.$REGION.amazonaws.com/frontend'
}
}
}
}