-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
44 lines (39 loc) · 2.29 KB
/
Jenkinsfile
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
@Library('podTemplateLib')
import net.santiment.utils.podTemplates
properties([buildDiscarder(logRotator(artifactDaysToKeepStr: '30', artifactNumToKeepStr: '', daysToKeepStr: '30', numToKeepStr: ''))])
slaveTemplates = new podTemplates()
slaveTemplates.dockerTemplate { label ->
node(label) {
stage('Build') {
container('docker') {
def scmVars = checkout scm
def gitHead = scmVars.GIT_COMMIT.substring(0,7)
if (env.BRANCH_NAME == "master") {
withCredentials([
string(
credentialsId: 'SECRET_KEY_BASE',
variable: 'SECRET_KEY_BASE'
),
string(
credentialsId: 'aws_account_id',
variable: 'aws_account_id'
)
]) {
// We are building two docker images - for stage and prod respectively. The app requires an env var BACKEND_URL set at build time.
def awsRegistry = "${env.aws_account_id}.dkr.ecr.eu-central-1.amazonaws.com"
docker.withRegistry("https://${awsRegistry}", "ecr:eu-central-1:ecr-credentials") {
sh "docker build --build-arg GQL_SERVER_URL=http://sanbase.default.svc.cluster.local/graphql --build-arg API_FETCH_ORIGIN=https://app-stage.santiment.net --build-arg BACKEND_URL=https://api-stage.santiment.net --build-arg GIT_HEAD=${gitHead} -t ${awsRegistry}/insights-app-stage:${env.BRANCH_NAME} -t ${awsRegistry}/insights-app-stage:${scmVars.GIT_COMMIT} ."
sh "docker push ${awsRegistry}/insights-app-stage:${env.BRANCH_NAME}"
sh "docker push ${awsRegistry}/insights-app-stage:${scmVars.GIT_COMMIT}"
}
docker.withRegistry("https://${awsRegistry}", "ecr:eu-central-1:ecr-credentials") {
sh "docker build --build-arg GQL_SERVER_URL=http://sanbase.default.svc.cluster.local/graphql --build-arg API_FETCH_ORIGIN=https://app.santiment.net --build-arg BACKEND_URL=https://api.santiment.net --build-arg GIT_HEAD=${gitHead} -t ${awsRegistry}/insights-app-prod:${env.BRANCH_NAME} -t ${awsRegistry}/insights-app-prod:${scmVars.GIT_COMMIT} ."
sh "docker push ${awsRegistry}/insights-app-prod:${env.BRANCH_NAME}"
sh "docker push ${awsRegistry}/insights-app-prod:${scmVars.GIT_COMMIT}"
}
}
}
}
}
}
}