Skip to content

Commit

Permalink
move helper images into own build
Browse files Browse the repository at this point in the history
Instead of building the helper images (cassandra, redis, postgres, selenium) in the main canvas-lms build,
move the images to be built in a separate Jenkins build to prevent accidental overwriting.

refs DE-196
flag = none

Test plan:
- Ensure cassandra image is built and pushed to starlord
- Ensure redis image is built and pushed to starlord
- Ensure dynamodb image is built and pushed to starlord
- Ensure postgres image is built and pushed to starlord
- Ensure Jenkins build passes with the images created by the helpers
- Ensure Jenkins build passess with the original Jenkinsfile

Change-Id: I1be5f4d0ff5fa28a0c3ec01e209f54379f58c173
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/246802
Reviewed-by: Aaron Ogata <[email protected]>
Reviewed-by: James Butters <[email protected]>
QA-Review: Andrea Cirulli <[email protected]>
Tested-by: Service Cloud Jenkins <[email protected]>
Product-Review: James Butters <[email protected]>
  • Loading branch information
kerby82 committed Sep 15, 2020
1 parent 93ab685 commit 91398a2
Show file tree
Hide file tree
Showing 5 changed files with 227 additions and 13 deletions.
54 changes: 54 additions & 0 deletions Jenkinsfile.cassandra
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env groovy

/*
* Copyright (C) 2020 - present Instructure, Inc.
*
* This file is part of Canvas.
*
* Canvas is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation, version 3 of the License.
*
* Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/

pipeline {
agent { label 'canvas-docker' }
options {
ansiColor('xterm')
timestamps()
}

stages {
stage ('Parameters Check') {
steps {
script {
if (!params.TARGET) {
currentBuild.result = 'ABORTED'
error('TARGET parameter must be specified.')
}
}
}
}
stage('Build Cassandra Image') {
steps {
script {
sh "docker build -f build/docker-compose/cassandra/Dockerfile.cachable -t $TARGET build/docker-compose/cassandra"
}
}
}
stage('Push Cassandra Image') {
steps {
script {
sh "./build/new-jenkins/docker-with-flakey-network-protection.sh push $TARGET"
}
}
}
}
}
54 changes: 54 additions & 0 deletions Jenkinsfile.dynamodb
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env groovy

/*
* Copyright (C) 2020 - present Instructure, Inc.
*
* This file is part of Canvas.
*
* Canvas is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation, version 3 of the License.
*
* Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/

pipeline {
agent { label 'canvas-docker' }
options {
ansiColor('xterm')
timestamps()
}

stages {
stage ('Parameters Check') {
steps {
script {
if (!params.TARGET) {
currentBuild.result = 'ABORTED'
error('TARGET parameter must be specified.')
}
}
}
}
stage('Build DynamoDB Image') {
steps {
script {
sh "docker build -t $TARGET build/docker-compose/dynamodb"
}
}
}
stage('Push DynamoDB Image') {
steps {
script {
sh "./build/new-jenkins/docker-with-flakey-network-protection.sh push $TARGET"
}
}
}
}
}
54 changes: 54 additions & 0 deletions Jenkinsfile.postgres
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env groovy

/*
* Copyright (C) 2020 - present Instructure, Inc.
*
* This file is part of Canvas.
*
* Canvas is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation, version 3 of the License.
*
* Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/

pipeline {
agent { label 'canvas-docker' }
options {
ansiColor('xterm')
timestamps()
}

stages {
stage ('Parameters Check') {
steps {
script {
if (!params.TARGET || !params.POSTGRES) {
currentBuild.result = 'ABORTED'
error('TARGET and POSTGRES parameters must be specified.')
}
}
}
}
stage('Build Postgres Image') {
steps {
script {
sh "docker build -t $TARGET --build-arg POSTGRES=\"$POSTGRES\" docker-compose/postgres"
}
}
}
stage('Push Postgres Image') {
steps {
script {
sh "./build/new-jenkins/docker-with-flakey-network-protection.sh push $TARGET"
}
}
}
}
}
61 changes: 61 additions & 0 deletions Jenkinsfile.redis
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/env groovy

/*
* Copyright (C) 2020 - present Instructure, Inc.
*
* This file is part of Canvas.
*
* Canvas is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation, version 3 of the License.
*
* Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/

pipeline {
agent { label 'canvas-docker' }
options {
ansiColor('xterm')
timestamps()
}

stages {
stage ('Parameters Check') {
steps {
script {
if (!params.TARGET) {
currentBuild.result = 'ABORTED'
error('TARGET parameter must be specified.')
}
}
}
}
stage('Pull Redis Image') {
steps {
script {
sh "./build/new-jenkins/docker-with-flakey-network-protection.sh pull redis:alpine"
}
}
}
stage('Tag Redis Image') {
steps {
script {
sh "docker tag redis:alpine $TARGET"
}
}
}
stage('Push Redis Image') {
steps {
script {
sh "./build/new-jenkins/docker-with-flakey-network-protection.sh push $TARGET"
}
}
}
}
}
17 changes: 4 additions & 13 deletions build/new-jenkins/docker-compose-pull.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,13 @@ POSTGIS=${POSTGIS:-2.5}
./build/new-jenkins/docker-with-flakey-network-protection.sh pull $PATCHSET_TAG

# redis
./build/new-jenkins/docker-with-flakey-network-protection.sh pull $REGISTRY_BASE/redis:alpine || \
(./build/new-jenkins/docker-with-flakey-network-protection.sh pull redis:alpine && \
docker tag redis:alpine $REGISTRY_BASE/redis:alpine && \
./build/new-jenkins/docker-with-flakey-network-protection.sh push $REGISTRY_BASE/redis:alpine)
./build/new-jenkins/docker-with-flakey-network-protection.sh pull $REGISTRY_BASE/redis:alpine

# postgres database with postgis preinstalled
./build/new-jenkins/docker-with-flakey-network-protection.sh pull $POSTGRES_IMAGE_TAG || \
(docker build -t $POSTGRES_IMAGE_TAG --build-arg POSTGRES="$POSTGRES" build/docker-compose/postgres && \
./build/new-jenkins/docker-with-flakey-network-protection.sh push $POSTGRES_IMAGE_TAG)
./build/new-jenkins/docker-with-flakey-network-protection.sh pull $POSTGRES_IMAGE_TAG

# cassandra:2:2
./build/new-jenkins/docker-with-flakey-network-protection.sh pull $CASSANDRA_IMAGE_TAG || \
(docker build -f build/docker-compose/cassandra/Dockerfile.cachable -t $CASSANDRA_IMAGE_TAG build/docker-compose/cassandra && \
./build/new-jenkins/docker-with-flakey-network-protection.sh push $CASSANDRA_IMAGE_TAG)
./build/new-jenkins/docker-with-flakey-network-protection.sh pull $CASSANDRA_IMAGE_TAG

# dynamodb-local
./build/new-jenkins/docker-with-flakey-network-protection.sh pull $DYNAMODB_IMAGE_TAG || \
(docker build -t $DYNAMODB_IMAGE_TAG build/docker-compose/dynamodb && \
./build/new-jenkins/docker-with-flakey-network-protection.sh push $DYNAMODB_IMAGE_TAG)
./build/new-jenkins/docker-with-flakey-network-protection.sh pull $DYNAMODB_IMAGE_TAG

0 comments on commit 91398a2

Please sign in to comment.