Skip to content

Commit 27b8010

Browse files
authoredMay 29, 2019
re #1086, initial staging configuration (#1087)
1 parent 507b0b2 commit 27b8010

File tree

4 files changed

+91
-0
lines changed

4 files changed

+91
-0
lines changed
 

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.DS_Store
22
.env
33
.env.production
4+
.env.staging
45
.vscode/
56
node_modules/
67
npm-debug.log

‎.travis.yml

+5
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ deploy:
3838
skip_cleanup: true
3939
on:
4040
branch: master
41+
- provider: script
42+
script: ./deploy-staging.sh
43+
skip_cleanup: true
44+
on:
45+
branch: feature/public-api
4146

4247
env:
4348
global:

‎deploy_staging.sh

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
docker-compose build --no-cache
6+
docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
7+
docker tag $APP_IMAGE_NAME $DOCKER_USERNAME/$DOCKER_STAGING_REPOSITORY:$TRAVIS_COMMIT
8+
docker tag $APP_IMAGE_NAME $DOCKER_USERNAME/$DOCKER_STAGING_REPOSITORY:latest
9+
docker push $DOCKER_USERNAME/$DOCKER_STAGING_REPOSITORY:$TRAVIS_COMMIT
10+
docker push $DOCKER_USERNAME/$DOCKER_STAGING_REPOSITORY:latest
11+
12+
echo $GCLOUD_SERVICE_KEY_PRD | base64 --decode -i > ${HOME}/gcloud-service-key.json
13+
gcloud auth activate-service-account --key-file ${HOME}/gcloud-service-key.json
14+
15+
gcloud --quiet config set project $PROJECT_NAME_PRD
16+
gcloud --quiet config set container/cluster $CLUSTER_NAME_PRD
17+
gcloud --quiet config set compute/zone ${CLOUDSDK_COMPUTE_ZONE}
18+
gcloud --quiet container clusters get-credentials $CLUSTER_NAME_PRD
19+
20+
kubectl config view
21+
kubectl config current-context
22+
23+
kubectl set image deployment/${KUBE_DEPLOYMENT_NAME} ${KUBE_DEPLOYMENT_CONTAINER_NAME}=index.docker.io/$DOCKER_USERNAME/$DOCKER_STAGING_REPOSITORY:$TRAVIS_COMMIT --namespace=staging

‎kubernetes_app.yml

+62
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,65 @@ spec:
118118
# - secretRef:
119119
# name: web-editor-credentials
120120
# restartPolicy: Never
121+
---
122+
apiVersion: v1
123+
kind: Namespace
124+
metadata:
125+
name: staging
126+
labels:
127+
name: staging
128+
---
129+
apiVersion: v1
130+
kind: Service
131+
metadata:
132+
name: web-editor-node
133+
namespace: staging
134+
labels:
135+
app: web-editor
136+
spec:
137+
# if your cluster supports it, uncomment the following to automatically create
138+
# an external load-balanced IP for the frontend service.
139+
type: LoadBalancer
140+
# type: NodePort
141+
ports:
142+
- port: 8001
143+
targetPort: 8000
144+
selector:
145+
app: web-editor
146+
---
147+
apiVersion: apps/v1
148+
kind: Deployment
149+
metadata:
150+
name: web-editor-node
151+
namespace: staging
152+
spec:
153+
selector:
154+
matchLabels:
155+
app: web-editor
156+
replicas: 1
157+
template:
158+
metadata:
159+
labels:
160+
app: web-editor
161+
spec:
162+
containers:
163+
- name: web-editor-app
164+
image: index.docker.io/catarak/p5.js-web-editor:latest
165+
# temp, just to test kubernetes
166+
# envFrom:
167+
# - configMapRef:
168+
# name: web-editor-env
169+
envFrom:
170+
- secretRef:
171+
name: web-editor-credentials
172+
imagePullPolicy: Always
173+
resources:
174+
requests:
175+
cpu: 100m
176+
memory: 100Mi
177+
ports:
178+
- containerPort: 8000
179+
readinessProbe:
180+
httpGet:
181+
path: /health
182+
port: 8000

0 commit comments

Comments
 (0)