Skip to content
This repository was archived by the owner on Dec 14, 2023. It is now read-only.

Commit ce5615a

Browse files
butlerxDanielBrierton
authored andcommitted
Kube/deploy (#268)
* Added staging config to circle.yml * Update circle.yml to use new staging app * [#147342465] Mary wants the child alias/user ID to be auto-generated * Enhancement/staging sadv2 (#266) * Refactor agreements to what's needed fix tests * Add unhandled scenario when trying to save a charter that shouldn't happen "Fix" test for agreements * Allow agreement to be loaded individually usage : cdf admin review * add k8 deploy * Update kube.sh * set args depending on branch
1 parent 11f8e1a commit ce5615a

File tree

3 files changed

+36
-13
lines changed

3 files changed

+36
-13
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
FROM mhart/alpine-node:0.10.48
22
MAINTAINER butlerx <[email protected]>
3-
3+
ARG DEP_VERSION=latest
44
RUN apk add --update git build-base python postgresql-client && \
55
mkdir -p /usr/src/app
66
WORKDIR /usr/src/app
77
COPY . /usr/src/app/
88
RUN npm install && \
9-
rm -rf /root/.npm && \
9+
npm install cp-translations@$DEP_VERSION && \
1010
apk del build-base python && \
1111
rm -rf /tmp/* /root/.npm /root/.node-gyp
1212
EXPOSE 10303

circle.yml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
---
12
machine:
23
node:
34
version: 0.10.40
5+
services:
6+
- docker
47
environment:
58
LANG: en_US.utf8
69
dependencies:
@@ -27,14 +30,5 @@ deployment:
2730
deployment_config: CodeDeployDefault.OneAtATime
2831
staging:
2932
branch: staging
30-
codedeploy:
31-
cp-users-service-staging:
32-
application_root: /
33-
region: eu-west-1
34-
revision_location:
35-
revision_type: S3
36-
s3_location:
37-
bucket: zen-deployments
38-
key_pattern: staging/applications/cp-users-service-staging-{SHORT_COMMIT}-{BUILD_NUM}.zip
39-
deployment_group: staging-zen
40-
deployment_config: CodeDeployDefault.OneAtATime
33+
commands:
34+
- GIT_SHA1=$CIRCLE_SHA1 GIT_BRANCH=$CIRCLE_BRANCH ./deploy/kube.sh

deploy/kube.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
if [ "$GIT_BRANCH" = "master" ]; then
6+
DEP_VER=latest
7+
HOST=$PROD_HOST
8+
echo "$PROD_CA_CERT" | base64 -i --decode > ca.pem
9+
echo "$PROD_ADMIN_KEY" | base64 -i --decode > admin-key.pem
10+
echo "$PROD_ADMIN_CERT" | base64 -i --decode > admin.pem
11+
elif [ "$GIT_BRANCH" = "staging" ]; then
12+
DEP_VER=staging
13+
HOST=$STAGING_HOST
14+
echo "$STAGING_CA_CERT" | base64 -i --decode > ca.pem
15+
echo "$STAGING_ADMIN_KEY" | base64 -i --decode > admin-key.pem
16+
echo "$STAGING_ADMIN_CERT" | base64 -i --decode > admin.pem
17+
else
18+
exit 0
19+
fi
20+
docker build --rm=false --build-arg DEP_VERSION=$DEP_VER -t coderdojo/cp-users-service:"$GIT_SHA1" .
21+
docker login -u "$DOCKER_USER" -p "$DOCKER_PASS" -e "$DOCKER_EMAIL"
22+
docker push coderdojo/cp-users-service:"$GIT_SHA1"
23+
curl -O https://storage.googleapis.com/kubernetes-release/release/v1.6.1/bin/linux/amd64/kubectl
24+
chmod +x kubectl
25+
./kubectl config set-cluster default-cluster --server=https://"$HOST" --certificate-authority=ca.pem
26+
./kubectl config set-credentials default-admin --certificate-authority=ca.pem --client-key=admin-key.pem --client-certificate=admin.pem
27+
./kubectl config set-context default-system --cluster=default-cluster --user=default-admin
28+
./kubectl config use-context default-system
29+
./kubectl patch deployment users -p '{"spec":{"template":{"spec":{"containers":[{"name":"users","image":"coderdojo/cp-users-service:'"$GIT_SHA1"'"}]}}}}'

0 commit comments

Comments
 (0)