Skip to content

Commit

Permalink
Merge pull request #90 from zooniverse/kubeify
Browse files Browse the repository at this point in the history
Kubeify Designator
  • Loading branch information
zwolf authored Feb 21, 2020
2 parents fb1a535 + 14c0f72 commit 52924e2
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ script:
- docker-compose run -e MIX_ENV=test test mix test
after_success:
- if [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ]; then docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD";
docker push zooniverse/cellect_ex; fi
docker push zooniverse/designator; fi
env:
global:
secure: RBaqpYxaZC+FOMFNndHAY3YsPC3PBTUhvxcnvv3LGbc5i1ivDP7HfiyvCIabFj7glxfQZVKUgG/OQN17eGSFyfOjISpJNGVlprwRQsg10JGV9QYuGZQYQJLnp07TqHvNTZuYAo/VWmRMbJ80VRkT8ocVp4Vt7yuTwq6V/anZKgvX+0PxQHJ/dHlS+ONTQASeUdW51rXejghbYIUi3Qsd6R59j5MA7jKP4sAt7czBXqroiknXLXPlfkt4sNMTeVbQ+wTA2gIEuoWMRspJ8DHjVVG3WAW7nTcIec++iwzoo2Ydg0262SoccscbckGC57osyYCHVKQ0VZcI6KL4f1Oiioim8fxlkRK+PipoluRLz4ia0w/Aj0lfO8arzYFDwe4NTjljuKgn6a0epP7k8Ut4W80Dl97pCZmxMO11W0O4rIVB1Bd0NlQ33Kr1sJ5KxdhzGcAKwLc8YJyEyq0lu5yCvZNqDhgUagWqYC/7HDrmERiWoYrwg19pLQiqJo2OxEnqS+aUTGlOtwtO9WbDJlOuirOsc1+/d7QsqlEw/zPDSfWBU5lMLSE1c5RvakhUM0O/0DJ8YZ8KNRA8zO5Od6Wwet7KiErvIrESlDVc/V7Fjudyz+cJg9seEgjkancy+BK5THgIuKCEliu6IIBArjnfs2dkRWpulN9LngO2WA51nh8=
63 changes: 63 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!groovy

pipeline {
agent none

options {
disableConcurrentBuilds()
}

stages {
stage('Build Docker image') {
agent any
steps {
script {
def dockerRepoName = 'zooniverse/designator'
def dockerImageName = "${dockerRepoName}:${GIT_COMMIT}"
def newImage = docker.build(dockerImageName)

if (BRANCH_NAME == 'master') {
stage('Update latest tag') {
newImage.push()
newImage.push('latest')
}
}
}
}
}

stage('Deploy staging to Kubernetes') {
when { branch 'master' }
agent any
steps {
sh "sed 's/__IMAGE_TAG__/${GIT_COMMIT}/g' kubernetes/deployment-staging.tmpl | kubectl --context azure apply --record -f -"
}
}
}

post {
success {
script {
if (BRANCH_NAME == 'master' || env.TAG_NAME == 'production-release') {
slackSend (
color: '#00FF00',
message: "SUCCESSFUL: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})",
channel: "#ops"
)
}
}
}

failure {
script {
if (BRANCH_NAME == 'master' || env.TAG_NAME == 'production-release') {
slackSend (
color: '#FF0000',
message: "FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})",
channel: "#ops"
)
}
}
}
}
}
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ services:

web:
build: ./
image: zooniverse/cellect_ex
image: zooniverse/designator
volumes:
- ./:/app
- build_cache:/app/_build
Expand All @@ -25,7 +25,7 @@ services:
- postgres:pg

test:
image: zooniverse/cellect_ex
image: zooniverse/designator
volumes:
- ./:/app
- build_cache:/app/_build
Expand Down
81 changes: 81 additions & 0 deletions kubernetes/deployment-staging.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: designator-staging-app
labels:
app: designator-staging-app
spec:
replicas: 1
selector:
matchLabels:
app: designator-staging-app
template:
metadata:
labels:
app: designator-staging-app
spec:
containers:
- name: designator-staging-app
image: zooniverse/designator:__IMAGE_TAG__
env:
- name: MIX_ENV
value: staging
- name: POSTGRES_USER
value: cellect_ex
- name: POSTGRES_DB
value: panoptes
- name: POSTGRES_POOL_SIZE
value: 2
- name: APPSIGNAL_APP_NAME
value: cellect_ex-staging
- name: APPSIGNAL_APP_NAME
value: cellect_ex-staging
- name: APPSIGNAL_ENVIRONMENT
value: prod
- name: DESIGNATOR_AUTH_USERNAME
value: staging
- name: SECRET_KEY_BASE
valueFrom:
secretKeyRef:
name: designator-staging-env
key: SECRET_KEY_BASE
- name: POSTGRES_HOST
valueFrom:
secretKeyRef:
name: designator-staging-env
key: POSTGRES_HOST
- name: POSTGRES_PASS
valueFrom:
secretKeyRef:
name: designator-staging-env
key: POSTGRES_PASS
- name: ROLLBAR_ACCESS_TOKEN
valueFrom:
secretKeyRef:
name: designator-staging-env
key: ROLLBAR_ACCESS_TOKEN
- name: APPSIGNAL_PUSH_API_KEY
valueFrom:
secretKeyRef:
name: designator-staging-env
key: APPSIGNAL_PUSH_API_KEY
- name: DESIGNATOR_AUTH_PASSWORD
valueFrom:
secretKeyRef:
name: designator-staging-env
key: DESIGNATOR_AUTH_PASSWORD
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: designator-staging-app
spec:
selector:
app: designator-staging-app
ports:
- protocol: TCP
port: 80
targetPort: 80
type: NodePort

0 comments on commit 52924e2

Please sign in to comment.