Skip to content

Commit f2f0db3

Browse files
authored
Merge pull request #189 from ThinkDeepTech/hm/deployment-pipeline
2 parents 9d7e092 + bb98712 commit f2f0db3

File tree

129 files changed

+922
-8434
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+922
-8434
lines changed

.circleci/config.yml

Lines changed: 203 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,228 @@
11
version: 2.1
2+
23
orbs:
34
browser-tools: circleci/[email protected]
4-
jobs:
5-
deploy:
6-
docker:
7-
- image: 'cimg/node:14.17.6'
8-
9-
working_directory: ~/repo
10-
11-
steps:
12-
13-
- checkout
14-
15-
- run: yarn install --force
16-
17-
- run: yarn run build
18-
19-
- run: curl -sL https://firebase.tools | bash
20-
21-
- run: which firebase
22-
23-
- run: firebase --token $FIREBASE_TOKEN deploy
24-
25-
build:
26-
docker:
27-
- image: 'cimg/node:14.17.6-browsers'
28-
29-
working_directory: ~/repo
5+
kubernetes: circleci/[email protected]
6+
k8s: digitalocean/[email protected]
307

31-
steps:
32-
- browser-tools/install-browser-tools
8+
commands:
9+
install_monorepo:
10+
steps:
11+
- run: yarn install
12+
- run: yarn add -W apollo-datasource-mongodb && yarn add -W mongodb
3313

34-
- checkout
14+
login_docker:
15+
steps:
16+
- run: echo "$DOCKER_PASSWORD" | docker login --username $DOCKER_USERNAME --password-stdin
3517

36-
- run: node --version
18+
test_monorepo:
19+
steps:
20+
- run: yarn run tests
3721

38-
- run: yarn --version
22+
build_ui_command:
23+
steps:
24+
- run: yarn run build
3925

40-
- run: yarn install --force
26+
deploy_ui_command:
27+
steps:
28+
- run: curl -sL https://firebase.tools | bash
29+
- run: firebase --token $FIREBASE_TOKEN deploy
4130

42-
# TODO: There's something wrong with the yarn install above. It seems to avoid installation of apollo-datasource-mongodb as
43-
# well as mongodb itself. This is a patch solution, but isn't scalable. After build fix, troubleshoot.
44-
- run: yarn add -W apollo-datasource-mongodb
45-
46-
- run: yarn add -W mongodb
31+
jobs:
4732

48-
- run: yarn run tests
33+
deploy_mongodb:
34+
docker:
35+
- image: 'cimg/base:stable'
36+
37+
working_directory: ~/project
38+
39+
steps:
40+
- checkout
41+
- setup_remote_docker:
42+
version: 20.10.7
43+
- login_docker
44+
- k8s/install
45+
- k8s/initialize:
46+
cluster: predecos-kubernetes-cluster
47+
- kubernetes/delete-resource:
48+
now: true
49+
resource-names: mongodb-deployment
50+
resource-types: deployments
51+
wait: true
52+
- kubernetes/create-or-update-resource:
53+
get-rollout-status: true
54+
resource-file-path: ./packages/deep-microservice-collection/k8s/mongodb-deployment.yml
55+
resource-name: deployment/mongodb-deployment
56+
show-kubectl-command: true
57+
58+
deploy_postgres:
59+
docker:
60+
- image: 'cimg/base:stable'
61+
62+
working_directory: ~/project
63+
64+
steps:
65+
- checkout
66+
- setup_remote_docker:
67+
version: 20.10.7
68+
- login_docker
69+
- k8s/install
70+
- k8s/initialize:
71+
cluster: predecos-kubernetes-cluster
72+
- kubernetes/delete-resource:
73+
now: true
74+
resource-names: postgres-deployment
75+
resource-types: deployments
76+
wait: true
77+
- run:
78+
command: envsubst < postgres-deployment.yaml | kubectl apply -f -
79+
working_directory: ./packages/deep-microservice-analysis/k8s
80+
81+
build_and_deploy_microservice_collection:
82+
docker:
83+
- image: 'cimg/base:stable'
84+
85+
working_directory: ~/project
86+
87+
steps:
88+
- checkout
89+
- setup_remote_docker:
90+
version: 20.10.7
91+
- login_docker
92+
- k8s/install
93+
- k8s/initialize:
94+
cluster: predecos-kubernetes-cluster
95+
- run:
96+
command: docker build -t thinkdeeptech/deep-microservice-collection:${CIRCLE_BUILD_NUM} -t thinkdeeptech/deep-microservice-collection:latest --build-arg PREDECOS_MONGODB_CONNECTION_STRING=$PREDECOS_MONGODB_CONNECTION_STRING --build-arg PREDECOS_TWITTER_BEARER=$PREDECOS_TWITTER_BEARER --build-arg NODE_ENV=$NODE_ENV .
97+
working_directory: ./packages/deep-microservice-collection
98+
- run: docker push thinkdeeptech/deep-microservice-collection:${CIRCLE_BUILD_NUM}
99+
- run: docker push thinkdeeptech/deep-microservice-collection:latest
100+
- kubernetes/delete-resource:
101+
now: true
102+
resource-names: deep-microservice-collection-deployment
103+
resource-types: deployments
104+
wait: true
105+
- kubernetes/create-or-update-resource:
106+
get-rollout-status: true
107+
resource-file-path: ./packages/deep-microservice-collection/k8s/deep-microservice-collection-deployment.yml
108+
resource-name: deployment/deep-microservice-collection-deployment
109+
show-kubectl-command: true
110+
111+
112+
build_and_deploy_microservice_analysis:
113+
docker:
114+
- image: 'cimg/base:stable'
115+
116+
working_directory: ~/project
117+
118+
steps:
119+
- checkout
120+
- setup_remote_docker:
121+
version: 20.10.7
122+
- login_docker
123+
- k8s/install
124+
- k8s/initialize:
125+
cluster: predecos-kubernetes-cluster
126+
- run:
127+
command: docker build -t thinkdeeptech/deep-microservice-analysis:${CIRCLE_BUILD_NUM} -t thinkdeeptech/deep-microservice-analysis:latest --build-arg PREDECOS_PG_CONNECTION_STRING=$PREDECOS_PG_CONNECTION_STRING --build-arg PREDECOS_MICROSERVICE_COLLECTION_URL=$PREDECOS_MICROSERVICE_COLLECTION_URL --build-arg NODE_ENV=$NODE_ENV .
128+
working_directory: ./packages/deep-microservice-analysis
129+
- run: docker push thinkdeeptech/deep-microservice-analysis:${CIRCLE_BUILD_NUM}
130+
- run: docker push thinkdeeptech/deep-microservice-analysis:latest
131+
- kubernetes/delete-resource:
132+
now: true
133+
resource-names: deep-microservice-analysis-deployment
134+
resource-types: deployments
135+
wait: true
136+
- kubernetes/create-or-update-resource:
137+
get-rollout-status: true
138+
resource-file-path: ./packages/deep-microservice-analysis/k8s/deep-microservice-analysis-deployment.yml
139+
resource-name: deployment/deep-microservice-analysis-deployment
140+
show-kubectl-command: true
141+
142+
build_and_deploy_microservice_gateway:
143+
docker:
144+
- image: 'cimg/base:stable'
145+
146+
working_directory: ~/project
147+
148+
steps:
149+
- checkout
150+
- setup_remote_docker:
151+
version: 20.10.7
152+
- login_docker
153+
- k8s/install
154+
- k8s/initialize:
155+
cluster: predecos-kubernetes-cluster
156+
- run:
157+
command: docker build -t thinkdeeptech/deep-microservice-gateway:${CIRCLE_BUILD_NUM} -t thinkdeeptech/deep-microservice-gateway:latest --build-arg PREDECOS_AUTH_AUDIENCE=$PREDECOS_AUTH_AUDIENCE --build-arg PREDECOS_AUTH_JWKS_URI=$PREDECOS_AUTH_JWKS_URI --build-arg PREDECOS_AUTH_ISSUER=$PREDECOS_AUTH_ISSUER --build-arg PREDECOS_MICROSERVICE_ANALYSIS_URL=$PREDECOS_MICROSERVICE_ANALYSIS_URL --build-arg PREDECOS_MICROSERVICE_COLLECTION_URL=$PREDECOS_MICROSERVICE_COLLECTION_URL --build-arg NODE_ENV=$NODE_ENV .
158+
working_directory: ./packages/deep-microservice-gateway
159+
- run: docker push thinkdeeptech/deep-microservice-gateway:${CIRCLE_BUILD_NUM}
160+
- run: docker push thinkdeeptech/deep-microservice-gateway:latest
161+
- kubernetes/delete-resource:
162+
now: true
163+
resource-names: deep-microservice-gateway-deployment
164+
resource-types: deployments
165+
wait: true
166+
- kubernetes/create-or-update-resource:
167+
get-rollout-status: true
168+
resource-file-path: ./packages/deep-microservice-gateway/k8s/deep-microservice-gateway-deployment.yml
169+
resource-name: deployment/deep-microservice-gateway-deployment
170+
show-kubectl-command: true
171+
172+
build_ui:
173+
docker:
174+
- image: 'cimg/node:14.17.6'
175+
176+
working_directory: ~/project
177+
178+
steps:
179+
- browser-tools/install-browser-tools
180+
- checkout
181+
- install_monorepo
182+
- test_monorepo
183+
- build_ui_command
184+
185+
deploy_ui:
186+
docker:
187+
- image: 'cimg/node:14.17.6'
188+
189+
working_directory: ~/project
190+
191+
steps:
192+
- checkout
193+
- install_monorepo
194+
- build_ui_command
195+
- deploy_ui_command
49196

50-
- run: yarn run build
51197

52198
workflows:
53199

54200
version: 2
55201

56-
deploy:
202+
build_and_deploy_if_master:
57203

58204
jobs:
59205

60-
- build
206+
- build_and_deploy_microservice_collection:
207+
filters:
208+
branches:
209+
only: master
61210

62-
- deploy:
211+
- build_and_deploy_microservice_analysis:
212+
filters:
213+
branches:
214+
only: master
63215

64-
requires:
216+
- build_and_deploy_microservice_gateway:
217+
filters:
218+
branches:
219+
only: master
65220

66-
- build
221+
- build_ui
67222

223+
- deploy_ui:
224+
requires:
225+
- build_ui
68226
filters:
69-
70227
branches:
71-
72-
only: master
228+
only: master

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,22 @@ but it also defines how its interface is used by other microservices. This, in t
5757
service in one codebase. One benefit of that would be full-stack development can be done without making changes that collide
5858
with another teams changes. Federation, as well as schema stitching, provide mechanisms for taking a subgraph and connecting
5959
it to a full application supergraph in a seamless way. Federation uses a single gateway that provides access to the remaining
60-
services. This gateway is the publicly accessible end-point for the system of microservices and routes requests to the necessary
60+
services. This gateway is the publicly accessible end-point for the microservices and routes requests to the necessary
6161
microservice needed to gather the response. This application uses that concept because it's intended to introduce additional
6262
microservices that will perform tasks such as data fetching/collection, data cleaning as well as providing data structures for
6363
use in the front-end. Additional benefits include reducing the number of requests that need to go over the wire to gather data when
6464
compared to RESTful APIs, it's backed by facebook and is used by numerous companies and is therefore battle-tested and it's fun.
6565

66+
#### Kubernetes
67+
[Kubernetes](https://kubernetes.io/) is a container orchestration system with many powerful characteristics. It's used in this
68+
project to take advantage of self-healing, monitoring, replication and load-balancing.
69+
70+
#### Docker
71+
Docker provides containerization and is used for a couple of reasons. It allows developers to reproduce bugs that are seen in different
72+
environments such as production. It encapsulates application dependencies and configuration such that each application will run
73+
without worry about conflicting dependencies in a different application. It allows for easy backup and it takes up a much smaller
74+
footprint than virtual machines. It's also moving toward greater adoption on multiple platforms including windows and linux.
75+
6676
#### Postgres
6777
Postgres was chosen simply because I've heard good things about it and it's heavily used.
6878

@@ -92,3 +102,8 @@ with security-related development I opted to use one that was already available.
92102
```console
93103
yarn run setup
94104
```
105+
- Follow the instructions for setup in each of the microservices and the analysis app.
106+
107+
## Environment Variables
108+
- NODE_ENV : The environment in which the application is running (i.e, development, production)
109+
- DIGITALOCEAN_ACCESS_TOKEN : Access token for digital ocean

packages/deep-auth-service/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
"url": "git+https://github.com/ThinkDeepTech/thinkdeep.git"
1414
},
1515
"scripts": {
16-
"dev": "web-dev-server --config ./web-dev-server.config.mjs --esbuild-target auto",
17-
"dev:watch": "web-dev-server --config ./web-dev-server.config.mjs --watch --esbuild-target auto",
16+
"start": "web-dev-server --config ./web-dev-server.config.mjs --esbuild-target auto",
17+
"start:watch": "web-dev-server --config ./web-dev-server.config.mjs --watch --esbuild-target auto",
1818
"tests": "web-test-runner --config ./web-test-runner.config.mjs",
1919
"tests:watch": "web-test-runner --config ./web-test-runner.config.mjs --watch",
2020
"build": "rimraf build && rollup -c rollup.config.mjs"

packages/deep-button/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
"url": "git+https://github.com/ThinkDeepTech/thinkdeep.git"
1414
},
1515
"scripts": {
16-
"dev": "web-dev-server --config ./web-dev-server.config.mjs --esbuild-target auto",
17-
"dev:watch": "web-dev-server --config ./web-dev-server.config.mjs --watch --esbuild-target auto",
16+
"start": "web-dev-server --config ./web-dev-server.config.mjs --esbuild-target auto",
17+
"start:watch": "web-dev-server --config ./web-dev-server.config.mjs --watch --esbuild-target auto",
1818
"tests": "web-test-runner --config ./web-test-runner.config.mjs",
1919
"tests:watch": "web-test-runner --config ./web-test-runner.config.mjs --watch",
2020
"build": "rimraf build && rollup -c rollup.config.mjs"

packages/deep-card/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
"url": "git+https://github.com/ThinkDeepTech/thinkdeep.git"
1313
},
1414
"scripts": {
15-
"dev": "web-dev-server --config ./web-dev-server.config.mjs --esbuild-target auto",
16-
"dev:watch": "web-dev-server --config ./web-dev-server.config.mjs --watch --esbuild-target auto",
15+
"start": "web-dev-server --config ./web-dev-server.config.mjs --esbuild-target auto",
16+
"start:watch": "web-dev-server --config ./web-dev-server.config.mjs --watch --esbuild-target auto",
1717
"tests": "web-test-runner --config ./web-test-runner.config.mjs",
1818
"tests:watch": "web-test-runner --config ./web-test-runner.config.mjs --watch",
1919
"build": "rimraf build && rollup -c rollup.config.mjs"

packages/deep-footer/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
"url": "git+https://github.com/ThinkDeepTech/thinkdeep.git"
1515
},
1616
"scripts": {
17-
"dev": "web-dev-server --config ./web-dev-server.config.mjs --esbuild-target auto",
18-
"dev:watch": "web-dev-server --config ./web-dev-server.config.mjs --watch --esbuild-target auto",
17+
"start": "web-dev-server --config ./web-dev-server.config.mjs --esbuild-target auto",
18+
"start:watch": "web-dev-server --config ./web-dev-server.config.mjs --watch --esbuild-target auto",
1919
"tests": "web-test-runner --config ./web-test-runner.config.mjs",
2020
"tests:watch": "web-test-runner --config ./web-test-runner.config.mjs --watch",
2121
"build": "rimraf build && rollup -c rollup.config.mjs"

packages/deep-graphql-binding/.circleci/config.yml

Lines changed: 0 additions & 10 deletions
This file was deleted.

packages/deep-graphql-binding/.gitignore

Lines changed: 0 additions & 10 deletions
This file was deleted.

packages/deep-graphql-binding/.huskyrc

Lines changed: 0 additions & 5 deletions
This file was deleted.

packages/deep-graphql-binding/.npmrc

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)