Skip to content

Commit c67c2fe

Browse files
committed
finish circle ci move
1 parent e5d20b1 commit c67c2fe

File tree

4 files changed

+144
-0
lines changed

4 files changed

+144
-0
lines changed

.circleci/config.yml

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
version: 2.1
2+
orbs:
3+
k8s: circleci/[email protected]
4+
commands:
5+
git_checkout_from_cache:
6+
description: "Git checkout and save cache"
7+
steps:
8+
- restore_cache:
9+
name: Git restore cache
10+
keys:
11+
- source-v1-{{ .Branch }}-{{ .Revision }}
12+
- source-v1-{{ .Branch }}-
13+
- source-v1-
14+
- run:
15+
name: Fetch git tags
16+
command: |
17+
mkdir -p ~/.ssh
18+
echo 'github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ== ' >> ~/.ssh/known_hosts
19+
# Fetch tags if git cache is present
20+
if [ -e /home/circleci/project/.git ]
21+
then
22+
git fetch origin --tags
23+
fi
24+
- checkout
25+
- run:
26+
name: Compress git objects
27+
command: git gc
28+
- save_cache:
29+
name: Git save cache
30+
key: source-v1-{{ .Branch }}-{{ .Revision }}
31+
paths:
32+
- ".git"
33+
npm_install:
34+
description: "Install npm modules"
35+
steps:
36+
- restore_cache:
37+
name: Restore npm cache
38+
keys:
39+
- npm-v1-{{ checksum "package.json" }}
40+
- npm-v1-
41+
- run:
42+
name: Install npm modules
43+
command: npm install
44+
- run:
45+
name: Bootstrap
46+
command: npm run bootstrap
47+
- save_cache:
48+
name: Save NPM cache
49+
key: npm-v1-{{ checksum "package.json" }}
50+
paths:
51+
- "node_modules"
52+
- "packages/bot/node_modules"
53+
- "packages/components/node_modules"
54+
- "packages/core/node_modules"
55+
- "packages/trader/node_modules"
56+
- "packages/shared/node_modules"
57+
- "packages/translations/node_modules"
58+
59+
build:
60+
description: "Build"
61+
steps:
62+
- run:
63+
name: "build packages"
64+
command: npm run build:local
65+
- run:
66+
name: "build core"
67+
command: node_modules/lerna/cli.js exec --scope deriv-core -- npm run build
68+
69+
docker:
70+
description: "Build and Push image to docker hub"
71+
steps:
72+
- setup_remote_docker
73+
- run:
74+
name: Building docker image
75+
command: |
76+
docker build -t ${DOCKHUB_ORGANISATION}/deriv-app:${CIRCLE_SHA1} .
77+
- run:
78+
name: Pushing Image to docker hub
79+
command: |
80+
echo $DOCKERHUB_PASSWORD | docker login -u $DOCKERHUB_USERNAME --password-stdin
81+
docker push ${DOCKHUB_ORGANISATION}/deriv-app:${CIRCLE_SHA1}
82+
k8s_deploy:
83+
description: "Deploy to k8s cluster"
84+
steps:
85+
- k8s/install-kubectl
86+
- run:
87+
name: Deploying to k8s cluster for service deriv-app
88+
command: |
89+
echo $CA_CRT | base64 --decode > ca.crt
90+
kubectl --server=${KUBE_SERVER} --certificate-authority=ca.crt --token=$SERVICEACCOUNT_TOKEN set image deployment/staging-deriv-app staging-deriv-app=${DOCKHUB_ORGANISATION}/deriv-app:${CIRCLE_SHA1}
91+
92+
jobs:
93+
release:
94+
docker:
95+
- image: circleci/node:12.13.0-stretch
96+
steps:
97+
- git_checkout_from_cache
98+
- npm_install
99+
- build
100+
- docker
101+
- k8s_deploy
102+
103+
workflows:
104+
release:
105+
jobs:
106+
- release:
107+
filters:
108+
branches:
109+
only: /^master$/
110+

.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.git
2+
Dockerfile
3+
node_modules
4+
*/**/node_modules

Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM nginx:alpine
2+
COPY ./packages/core/dist /usr/share/nginx/html
3+
COPY ./default.conf /etc/nginx/conf.d/default.conf

default.conf

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
server {
2+
listen 80;
3+
server_name localhost;
4+
5+
add_header Strict-Transport-Security "max-age=15552000; preload";
6+
add_header Cache-Control "public, max-age=7200, s-maxage=600, must-revalidate";
7+
charset UTF-8;
8+
root /usr/share/nginx/html;
9+
10+
error_page 404 /404.html;
11+
12+
location @custom_error_503 {
13+
return 503;
14+
}
15+
16+
location ~ /\.git {
17+
return 404;
18+
}
19+
20+
location / {
21+
index index.html index.htm;
22+
}
23+
24+
location ~ ^/(\w+/?)+ {
25+
try_files $uri $uri/ /$1/ $uri/index.html /index.html;
26+
}
27+
}

0 commit comments

Comments
 (0)