Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
8416cf8
Preparing V2.5.1 (#1345)
morteza-binary Mar 3, 2020
7b31c1e
Merge branch 'master' of github.com:binary-com/mobile into afshin/add…
Mar 22, 2020
9ee7774
add circleci pipeline
Mar 22, 2020
f667e77
change yarn to npm
Mar 22, 2020
771e057
change node tag
Mar 22, 2020
e8da9c1
add release_beta workflows
Mar 22, 2020
b8ff5a6
change release tag match
Mar 22, 2020
73feeb8
change release tag match
Mar 22, 2020
923268a
change release tag match
Mar 22, 2020
7e5ad30
change yarn to npm
Mar 22, 2020
12dc484
change npm to yarn
Mar 22, 2020
dab337b
change npm to yarn
Mar 22, 2020
d55c37c
change build command
Mar 23, 2020
3ae630c
change build image
Mar 23, 2020
9f159db
change build image
Mar 23, 2020
c6232b5
test build
Mar 23, 2020
95271d6
test build
Mar 23, 2020
ac55296
change build image
Mar 23, 2020
bf9eb52
build test
Mar 23, 2020
11fe5f2
change image
Mar 23, 2020
bc6f4af
build test
Mar 23, 2020
bb7786c
build test
Mar 23, 2020
5d01676
build test
Mar 23, 2020
0f6cc6f
change image
Mar 23, 2020
48ddf91
change image to 11.15.0
Mar 23, 2020
3b94d51
add production release workflow
Mar 23, 2020
2757046
fix production release workflow & add context
Mar 23, 2020
d9cb4f3
fix yaml
Mar 23, 2020
b907608
fix tag
Mar 23, 2020
9b30ae6
fix node version
Mar 23, 2020
a5665f2
workflow test
Mar 23, 2020
b41b1bc
add circleci pipeline
Mar 23, 2020
51fda02
change context
Mar 24, 2020
3401f5f
Add Release pattern to README
Mar 24, 2020
dc3f4ca
add release format and workflow
Mar 25, 2020
2a958c5
fix docker build tag
Mar 25, 2020
1866f1e
fix k8s workflow
Mar 25, 2020
bf78909
change upload artifact tag
Mar 25, 2020
39f75e6
test circleci workflow
Mar 25, 2020
4afacf1
fix circleci workflow
Mar 25, 2020
363d91b
multiple clusters
Mar 25, 2020
0a26caa
add context to staging
Mar 25, 2020
322c128
rename step docker_build_push
Mar 25, 2020
10c7585
circleci master/dev release
Mar 30, 2020
38548ca
release does't always TAG
Mar 30, 2020
fd91f18
edit README
Mar 30, 2020
8ae4fed
change gulp build
Mar 30, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
158 changes: 158 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
version: 2.1
orbs:
k8s: circleci/kubernetes@0.7.0
s3: circleci/aws-s3@1.0.13
commands:
git_checkout_from_cache:
description: "Git checkout and save cache"
steps:
- restore_cache:
name: Git restore cache
keys:
- source-v1-{{ .Branch }}-{{ .Revision }}
- source-v1-{{ .Branch }}-
- source-v1-
- run:
name: Fetch git tags
command: |
mkdir -p ~/.ssh
echo 'github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ== ' >> ~/.ssh/known_hosts
# Fetch tags if git cache is present
if [ -e /home/circleci/project/.git ]
then
git fetch origin --tags
fi
- checkout
- run:
name: Compress git objects
command: git gc
- save_cache:
name: Git save cache
key: source-v1-{{ .Branch }}-{{ .Revision }}
paths:
- ".git"
npm_install:
description: "Install npm modules"
steps:
- restore_cache:
name: Restore npm cache
keys:
- npm-v1-{{ checksum "package.json" }}
- npm-v1-
- run:
name: Install npm modules
command: npm install && ./node_modules/.bin/bower install
- save_cache:
name: Save NPM cache
key: npm-v1-{{ checksum "package.json" }}
paths:
- "node_modules"
build:
description: "Build"
steps:
- run:
name: "gulp build"
command: npx gulp build
compress:
description: "Compress"
steps:
- run:
name: "Compress"
command: |
pushd www/
tar -cvf artifact.tar *
mv artifact.tar ${OLDPWD}/
- run:
name: "Tag commit id as artifact identifer"
command: echo "${CIRCLE_SHA1}" > artifact-info.txt
upload_artifact:
description: "upload artifact to s3"
steps:
- s3/copy:
from: artifact.tar
to: 's3://${CONTEXT_ARTIFACT_S3_BUCKET}/${CIRCLE_PROJECT_REPONAME}/'
aws-access-key-id: env_CONTEXT_ARTIFACT_S3_AWS_ACCESS_KEY_ID
aws-secret-access-key: env_CONTEXT_ARTIFACT_S3_AWS_SECRET_ACCESS_KEY
aws-region: env_CONTEXT_ARTIFACT_S3_AWS_REGION
arguments: '--metadata "{\"x-amz-artifact-id\": \"${CIRCLE_SHA1}\" }"'
upload_checksum:
description: "upload artifact commit id to s3"
steps:
- s3/copy:
from: artifact-info.txt
to: 's3://${CONTEXT_ARTIFACT_S3_BUCKET}/${CIRCLE_PROJECT_REPONAME}/'
aws-access-key-id: env_CONTEXT_ARTIFACT_S3_AWS_ACCESS_KEY_ID
aws-secret-access-key: env_CONTEXT_ARTIFACT_S3_AWS_SECRET_ACCESS_KEY
aws-region: env_CONTEXT_ARTIFACT_S3_AWS_REGION
docker_build_push:
description: "Build and Push image to docker hub"
steps:
- setup_remote_docker
- run:
name: Building docker image for production
command: |
docker build -t ${DOCKHUB_ORGANISATION}/ticktrade-mobile:${CIRCLE_SHA1} -t ${DOCKHUB_ORGANISATION}/ticktrade-mobile:latest .
- run:
name: Pushing Image to docker hub
command: |
echo $DOCKERHUB_PASSWORD | docker login -u $DOCKERHUB_USERNAME --password-stdin
docker push ${DOCKHUB_ORGANISATION}/ticktrade-mobile
k8s_deploy:
description: "Deploy to k8s cluster"
steps:
- k8s/install-kubectl
- run:
name: Deploying to k8s cluster for service ticktrade-binary-com
command: |
for SERVER_ID in {1..5}
do
KUBE_SERVER_REF="KUBE_SERVER_$SERVER_ID"
SERVICEACCOUNT_TOKEN_REF="SERVICEACCOUNT_TOKEN_$SERVER_ID"
CA_CRT_REF="CA_CRT_$SERVER_ID"
if [ ! -z "${!KUBE_SERVER_REF}" ]
then
echo "Deploying to cluster $SERVER_ID"
CA_CRT="${!CA_CRT_REF}"
KUBE_SERVER="${!KUBE_SERVER_REF}"
SERVICEACCOUNT_TOKEN="${!SERVICEACCOUNT_TOKEN_REF}"
echo $CA_CRT | base64 --decode > ca.crt
kubectl --server=${KUBE_SERVER} --certificate-authority=ca.crt --token=$SERVICEACCOUNT_TOKEN set image deployment/ticktrade-binary-com ticktrade-binary-com=${DOCKHUB_ORGANISATION}/ticktrade-mobile:${CIRCLE_SHA1}
fi
done


jobs:
test:
docker:
- image: circleci/node:11.15.0
steps:
- git_checkout_from_cache
- npm_install
- build
release_production:
docker:
- image: circleci/node:11.15.0
steps:
- git_checkout_from_cache
- npm_install
- build
- compress
- upload_artifact # uploading the built code to s3 to create a backup of key services separate from Kubernetes deployment
- upload_checksum # uploading compressed artifact checksum to cross match artifact fingerprint before actual deployment
- docker_build_push
- k8s_deploy

workflows:
test:
jobs:
- test:
filters:
branches:
ignore: /^master$/
release:
jobs:
- release_production:
filters:
branches:
only: /^master$/
context: binary-frontend-artifact-upload
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.git
Dockerfile
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM nginx:alpine
COPY ./www /usr/share/nginx/html
COPY ./default.conf /etc/nginx/conf.d/default.conf
22 changes: 22 additions & 0 deletions default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
server {
listen 80;
server_name localhost;

add_header Cache-Control "public, max-age=7200, s-maxage=600, must-revalidate";
charset UTF-8;

error_page 404 /404.html;

location @custom_error_503 {
return 503;
}

location ~ /\.git {
return 404;
}

location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
}