Skip to content

Commit

Permalink
re #1086, initial staging configuration (#1087)
Browse files Browse the repository at this point in the history
  • Loading branch information
catarak authored May 29, 2019
1 parent 507b0b2 commit 27b8010
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.DS_Store
.env
.env.production
.env.staging
.vscode/
node_modules/
npm-debug.log
Expand Down
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ deploy:
skip_cleanup: true
on:
branch: master
- provider: script
script: ./deploy-staging.sh
skip_cleanup: true
on:
branch: feature/public-api

env:
global:
Expand Down
23 changes: 23 additions & 0 deletions deploy_staging.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

set -e

docker-compose build --no-cache
docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
docker tag $APP_IMAGE_NAME $DOCKER_USERNAME/$DOCKER_STAGING_REPOSITORY:$TRAVIS_COMMIT
docker tag $APP_IMAGE_NAME $DOCKER_USERNAME/$DOCKER_STAGING_REPOSITORY:latest
docker push $DOCKER_USERNAME/$DOCKER_STAGING_REPOSITORY:$TRAVIS_COMMIT
docker push $DOCKER_USERNAME/$DOCKER_STAGING_REPOSITORY:latest

echo $GCLOUD_SERVICE_KEY_PRD | base64 --decode -i > ${HOME}/gcloud-service-key.json
gcloud auth activate-service-account --key-file ${HOME}/gcloud-service-key.json

gcloud --quiet config set project $PROJECT_NAME_PRD
gcloud --quiet config set container/cluster $CLUSTER_NAME_PRD
gcloud --quiet config set compute/zone ${CLOUDSDK_COMPUTE_ZONE}
gcloud --quiet container clusters get-credentials $CLUSTER_NAME_PRD

kubectl config view
kubectl config current-context

kubectl set image deployment/${KUBE_DEPLOYMENT_NAME} ${KUBE_DEPLOYMENT_CONTAINER_NAME}=index.docker.io/$DOCKER_USERNAME/$DOCKER_STAGING_REPOSITORY:$TRAVIS_COMMIT --namespace=staging
62 changes: 62 additions & 0 deletions kubernetes_app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,65 @@ spec:
# - secretRef:
# name: web-editor-credentials
# restartPolicy: Never
---
apiVersion: v1
kind: Namespace
metadata:
name: staging
labels:
name: staging
---
apiVersion: v1
kind: Service
metadata:
name: web-editor-node
namespace: staging
labels:
app: web-editor
spec:
# if your cluster supports it, uncomment the following to automatically create
# an external load-balanced IP for the frontend service.
type: LoadBalancer
# type: NodePort
ports:
- port: 8001
targetPort: 8000
selector:
app: web-editor
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: web-editor-node
namespace: staging
spec:
selector:
matchLabels:
app: web-editor
replicas: 1
template:
metadata:
labels:
app: web-editor
spec:
containers:
- name: web-editor-app
image: index.docker.io/catarak/p5.js-web-editor:latest
# temp, just to test kubernetes
# envFrom:
# - configMapRef:
# name: web-editor-env
envFrom:
- secretRef:
name: web-editor-credentials
imagePullPolicy: Always
resources:
requests:
cpu: 100m
memory: 100Mi
ports:
- containerPort: 8000
readinessProbe:
httpGet:
path: /health
port: 8000

0 comments on commit 27b8010

Please sign in to comment.