Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Community service to use grpc & graphql #184

Open
wants to merge 39 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
f2fe95d
token.go to extract and validate token
Mar 17, 2023
0958007
config.go for initializing monogdb and postgres
Mar 17, 2023
cf14189
model_gen.go generated from schema.graphql
Mar 17, 2023
120a228
seeder.go to seed default values in user and coupon database
Mar 17, 2023
b680289
Added schema.graphqls
Mar 17, 2023
5609ca7
Removed model_gen.go autogenerated file
Mar 17, 2023
c1522db
schema.resolvers.go file to resolve schema.graphqls query and mutations
Mar 17, 2023
9631c74
Added coupon.go file to handle coupon operations
Mar 17, 2023
52478df
Added post.go file to handle post operations
Mar 17, 2023
bf0f05e
removed errors in graphql go files
Mar 17, 2023
817623b
Added community proto files in grpc
Mar 17, 2023
fa59b16
Added main.go in grpc to handle all incoming graphql requests
Mar 17, 2023
14f08a0
Added models/comments.go to handle comment operations
Mar 17, 2023
e7b684f
Added models/coupon.go to handle comment operations
Mar 17, 2023
4ca0659
Added models/post.go to handle comment operations
Mar 17, 2023
e79c04f
Added models/user.go to handle comment operations
Mar 17, 2023
f83c39d
Removed errors from models/
Mar 17, 2023
903d2fa
Added responses/json.go to return error or json
Mar 17, 2023
cf78d73
Added server.go for graphql server and Dockerfile for both grpc and g…
Mar 18, 2023
ab88276
Removing errors while creating docker images
Mar 18, 2023
82e42d7
Added the autogenerated files in graphql | updated schema.graphqls | …
Mar 19, 2023
ad04959
Updated logic in token.go and removed existing community service
Mar 19, 2023
72a031e
Removed crapi-community from docker-compose
Mar 19, 2023
1cee4e9
Updated community.saga and shop.saga to send graphql requests
Mar 19, 2023
9836c2a
Updated token.go
Mar 19, 2023
847101c
Updated docker compose file to update community service to community-…
Mar 19, 2023
4ff3c8a
Updated seeder.go to handle the key conversion of couponcode
Mar 19, 2023
ed02d0e
Updated coupon.go to handle the key conversion of couponcode
Mar 19, 2023
d53ed73
Moved seeder.go in grpc | Updated couponcode to coupon_code to match …
Mar 20, 2023
9ed772a
FINAL COMMIT | Removed unwanted piece of code
Mar 20, 2023
5a331cf
FINAL COMMIT | Removed unwanted piece of code
Mar 20, 2023
87855fa
FINAL COMMIT | Reverted back UpdatePost code(for adding comment)
Mar 20, 2023
ab9fc04
updated multiple files for validate_coupon
Mar 29, 2023
dd61b75
updated validate_coupon logic
Mar 30, 2023
37a5ef9
Merge branch 'develop' into community-grpc-graphql
piyushroshan Apr 27, 2023
829bc65
Update docker-compose.yml
piyushroshan Apr 27, 2023
d3f8abb
Update Helm and k8s deployment
Aug 23, 2023
f9c636c
Merge 'develop' into current branch
Aug 26, 2023
7b5680c
Updated dockerfile for both grpc&graphql to sync with new changes
Sep 12, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
118 changes: 76 additions & 42 deletions deploy/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,45 +63,6 @@ services:
cpus: '0.8'
memory: 384M

crapi-community:
container_name: crapi-community
image: crapi/crapi-community:${VERSION:-latest}
#ports:
# - "${LISTEN_IP:-127.0.0.1}:8087:8087"
environment:
- IDENTITY_SERVICE=crapi-identity:${IDENTITY_SERVER_PORT:-8080}
- DB_NAME=crapi
- DB_USER=admin
- DB_PASSWORD=crapisecretpassword
- DB_HOST=postgresdb
- DB_PORT=5432
- SERVER_PORT=${COMMUNITY_SERVER_PORT:-8087}
- MONGO_DB_HOST=mongodb
- MONGO_DB_PORT=27017
- MONGO_DB_USER=admin
- MONGO_DB_PASSWORD=crapisecretpassword
- MONGO_DB_NAME=crapi
- TLS_ENABLED=${TLS_ENABLED:-false}
- TLS_CERTIFICATE=certs/server.crt
- TLS_KEY=certs/server.key
depends_on:
postgresdb:
condition: service_healthy
mongodb:
condition: service_healthy
crapi-identity:
condition: service_healthy
healthcheck:
test: /app/health.sh
interval: 15s
timeout: 15s
retries: 15
deploy:
resources:
limits:
cpus: '0.3'
memory: 128M

crapi-workshop:
container_name: crapi-workshop
image: crapi/crapi-workshop:${VERSION:-latest}
Expand Down Expand Up @@ -132,7 +93,7 @@ services:
condition: service_healthy
crapi-identity:
condition: service_healthy
crapi-community:
crapi-community-graphql:
condition: service_healthy
healthcheck:
test: /app/health.sh
Expand All @@ -152,12 +113,12 @@ services:
- "${LISTEN_IP:-127.0.0.1}:8888:80"
- "${LISTEN_IP:-127.0.0.1}:8443:443"
environment:
- COMMUNITY_SERVICE=crapi-community:${COMMUNITY_SERVER_PORT:-8087}
- COMMUNITY_SERVICE=crapi-community-graphql:${COMMUNITY_GRAPHQL_SERVER_PORT:-8087}
- IDENTITY_SERVICE=crapi-identity:${IDENTITY_SERVER_PORT:-8080}
- WORKSHOP_SERVICE=crapi-workshop:${WORKSHOP_SERVER_PORT:-8000}
- TLS_ENABLED=${TLS_ENABLED:-false}
depends_on:
crapi-community:
crapi-community-graphql:
condition: service_healthy
crapi-identity:
condition: service_healthy
Expand Down Expand Up @@ -218,6 +179,79 @@ services:
cpus: '0.3'
memory: 128M

crapi-community-graphql:
container_name: crapi-community-graphql
image: crapi/crapi-community/graphql-server:${VERSION:-latest}
# ports:
# - "8087:8087"
environment:
- GRPC-SERVICE=crapi-community-grpc:${COMMUNITY_GRPC_SERVER_PORT:-9090}
- IDENTITY_SERVICE=crapi-identity:${IDENTITY_SERVER_PORT:-8080}
- DB_NAME=crapi
- DB_USER=admin
- DB_PASSWORD=crapisecretpassword
- DB_HOST=postgresdb
- DB_PORT=5432
- SERVER_PORT=${COMMUNITY_GRAPHQL_SERVER_PORT:-8087}
- MONGO_DB_HOST=mongodb
- MONGO_DB_PORT=27017
- MONGO_DB_USER=admin
- MONGO_DB_PASSWORD=crapisecretpassword
- MONGO_DB_NAME=crapi
depends_on:
postgresdb:
condition: service_healthy
mongodb:
condition: service_healthy
crapi-identity:
condition: service_healthy
healthcheck:
test: curl 0.0.0.0:${COMMUNITY_GRAPHQL_SERVER_PORT:-8087}/health
interval: 15s
timeout: 15s
retries: 15
deploy:
resources:
limits:
cpus: '0.3'
memory: 128M

crapi-community-grpc:
container_name: crapi-community-grpc
image: crapi/crapi-community/grpc-server:${VERSION:-latest}
# ports:
# - "9090:9090"
environment:
- IDENTITY_SERVICE=crapi-identity:${IDENTITY_SERVER_PORT:-8080}
- DB_NAME=crapi
- DB_USER=admin
- DB_PASSWORD=crapisecretpassword
- DB_HOST=postgresdb
- DB_PORT=5432
- SERVER_PORT=${COMMUNITY_GRPC_SERVER_PORT:-9090}
- MONGO_DB_HOST=mongodb
- MONGO_DB_PORT=27017
- MONGO_DB_USER=admin
- MONGO_DB_PASSWORD=crapisecretpassword
- MONGO_DB_NAME=crapi
depends_on:
postgresdb:
condition: service_healthy
mongodb:
condition: service_healthy
crapi-identity:
condition: service_healthy
healthcheck:
test: curl 0.0.0.0:${COMMUNITY_GRAPHQL_SERVER_PORT:-8087}/health
interval: 15s
timeout: 15s
retries: 15
deploy:
resources:
limits:
cpus: '0.3'
memory: 128M

mailhog:
user: root
container_name: mailhog
Expand Down
4 changes: 2 additions & 2 deletions deploy/helm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.1
version: 0.1.2

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
appVersion: develop
appVersion: latest
25 changes: 25 additions & 0 deletions deploy/helm/templates/community-graphql/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Values.community_graphql.config.name }}
labels:
release: {{ .Release.Name }}
{{- with .Values.community_graphql.config.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
data:
IDENTITY_SERVICE: {{ .Values.identity.service.name }}:{{ .Values.identity.port }}
DB_HOST: {{ .Values.postgresdb.service.name }}
DB_DRIVER: {{ .Values.community_graphql.config.postgresDbDriver }}
DB_USER: {{ .Values.postgresdb.config.postgresUser }}
DB_PASSWORD: {{ .Values.postgresdb.config.postgresPassword }}
DB_NAME: {{ .Values.postgresdb.config.postgresDbName }}
DB_PORT: {{ .Values.postgresdb.port | quote }}
MONGO_DB_HOST: {{ .Values.mongodb.service.name }}
MONGO_DB_DRIVER: {{ .Values.community_graphql.config.mongoDbDriver }}
MONGO_DB_PORT: {{ .Values.mongodb.port | quote }}
MONGO_DB_USER: {{ .Values.mongodb.config.mongoUser }}
MONGO_DB_PASSWORD: {{ .Values.mongodb.config.mongoPassword }}
MONGO_DB_NAME: {{ .Values.mongodb.config.mongoDbName }}
SERVER_PORT: {{ .Values.community_graphql.port | quote }}
GRPC-SERVICE: {{ .Values.community_grpc.service.name }}:{{ .Values.community_grpc.port}}
55 changes: 55 additions & 0 deletions deploy/helm/templates/community-graphql/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Values.community_graphql.name }}
labels:
release: {{ .Release.Name }}
{{- with .Values.community_graphql.deploymentLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}

spec:
replicas: {{ .Values.community_graphql.replicaCount }}
selector:
matchLabels:
{{- toYaml .Values.community_graphql.deploymentSelectorMatchLabels | nindent 6 }}
template:
metadata:
labels:
release: {{ .Release.Name }}
{{- with .Values.community_graphql.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
initContainers:
- name: wait-for-postgres
image: {{ .Values.waitForK8sResources.image }}
imagePullPolicy: {{ .Values.waitForK8sResources.imagePullPolicy }}
args:
- "service"
- {{ .Values.postgresdb.service.name | quote }}
- name: wait-for-mongo
image: {{ .Values.waitForK8sResources.image }}
imagePullPolicy: {{ .Values.waitForK8sResources.imagePullPolicy }}
args:
- "service"
- {{ .Values.mongodb.service.name | quote }}
- name: wait-for-java
image: {{ .Values.waitForK8sResources.image }}
imagePullPolicy: {{ .Values.waitForK8sResources.imagePullPolicy }}
args:
- "service"
- {{ .Values.identity.service.name | quote }}
containers:
- name: {{ .Values.community_graphql.name }}
image: {{ .Values.community_graphql.image }}:{{ .Chart.AppVersion }}
imagePullPolicy: {{ .Values.imagePullPolicy }}
ports:
- containerPort: {{ .Values.community_graphql.port }}
envFrom:
- configMapRef:
name: {{ .Values.community_graphql.config.name }}
{{- if .Values.community_graphql.resources }}
resources:
{{- toYaml .Values.community_graphql.resources | nindent 12 }}
{{- end }}
15 changes: 15 additions & 0 deletions deploy/helm/templates/community-graphql/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ .Values.community_graphql.service.name }}
labels:
release: {{ .Release.Name }}
{{- with .Values.community_graphql.service.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
ports:
- port: {{ .Values.community_graphql.port }}
name: go
selector:
{{- toYaml .Values.community_graphql.serviceSelectorLabels | nindent 4 }}
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Values.community.config.name }}
name: {{ .Values.community_grpc.config.name }}
labels:
release: {{ .Release.Name }}
{{- with .Values.community.config.labels }}
{{- with .Values.community_grpc.config.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
data:
IDENTITY_SERVICE: {{ .Values.identity.service.name }}:{{ .Values.identity.port }}
DB_HOST: {{ .Values.postgresdb.service.name }}
DB_DRIVER: {{ .Values.community.config.postgresDbDriver }}
DB_DRIVER: {{ .Values.community_grpc.config.postgresDbDriver }}
DB_USER: {{ .Values.postgresdb.config.postgresUser }}
DB_PASSWORD: {{ .Values.postgresdb.config.postgresPassword }}
DB_NAME: {{ .Values.postgresdb.config.postgresDbName }}
DB_PORT: {{ .Values.postgresdb.port | quote }}
MONGO_DB_HOST: {{ .Values.mongodb.service.name }}
MONGO_DB_DRIVER: {{ .Values.community.config.mongoDbDriver }}
MONGO_DB_DRIVER: {{ .Values.community_grpc.config.mongoDbDriver }}
MONGO_DB_PORT: {{ .Values.mongodb.port | quote }}
MONGO_DB_USER: {{ .Values.mongodb.config.mongoUser }}
MONGO_DB_PASSWORD: {{ .Values.mongodb.config.mongoPassword }}
MONGO_DB_NAME: {{ .Values.mongodb.config.mongoDbName }}
SERVER_PORT: {{ .Values.community.port | quote }}
SERVER_PORT: {{ .Values.community_grpc.port | quote }}
TLS_ENABLED: {{ .Values.tlsEnabled | quote }}
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Values.community.name }}
name: {{ .Values.community_grpc.name }}
labels:
release: {{ .Release.Name }}
{{- with .Values.community.deploymentLabels }}
{{- with .Values.community_grpc.deploymentLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}

spec:
replicas: {{ .Values.community.replicaCount }}
replicas: {{ .Values.community_grpc.replicaCount }}
selector:
matchLabels:
{{- toYaml .Values.community.deploymentSelectorMatchLabels | nindent 6 }}
{{- toYaml .Values.community_grpc.deploymentSelectorMatchLabels | nindent 6 }}
template:
metadata:
labels:
release: {{ .Release.Name }}
{{- with .Values.community.podLabels }}
{{- with .Values.community_grpc.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
Expand All @@ -41,15 +41,15 @@ spec:
- "service"
- {{ .Values.identity.service.name | quote }}
containers:
- name: {{ .Values.community.name }}
image: {{ .Values.community.image }}:{{ .Chart.AppVersion }}
- name: {{ .Values.community_grpc.name }}
image: {{ .Values.community_grpc.image }}:{{ .Chart.AppVersion }}
imagePullPolicy: {{ .Values.imagePullPolicy }}
ports:
- containerPort: {{ .Values.community.port }}
- containerPort: {{ .Values.community_grpc.port }}
envFrom:
- configMapRef:
name: {{ .Values.community.config.name }}
{{- if .Values.community.resources }}
name: {{ .Values.community_grpc.config.name }}
{{- if .Values.community_grpc.resources }}
resources:
{{- toYaml .Values.community.resources | nindent 12 }}
{{- toYaml .Values.community_grpc.resources | nindent 12 }}
{{- end }}
15 changes: 15 additions & 0 deletions deploy/helm/templates/community-grpc/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ .Values.community_grpc.service.name }}
labels:
release: {{ .Release.Name }}
{{- with .Values.community_grpc.service.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
ports:
- port: {{ .Values.community_grpc.port }}
name: go
selector:
{{- toYaml .Values.community_grpc.serviceSelectorLabels | nindent 4 }}
15 changes: 0 additions & 15 deletions deploy/helm/templates/community/service.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion deploy/helm/templates/web/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
release: {{ .Release.Name }}
{{- toYaml .Values.web.config.labels | nindent 4 }}
data:
COMMUNITY_SERVICE: {{ .Values.community.service.name }}:{{ .Values.community.port }}
COMMUNITY_SERVICE: {{ .Values.community_graphql.service.name }}:{{ .Values.community_graphql.port }}
IDENTITY_SERVICE: {{ .Values.identity.service.name }}:{{ .Values.identity.port }}
WORKSHOP_SERVICE: {{ .Values.workshop.service.name }}:{{ .Values.workshop.port }}
TLS_ENABLED: {{ .Values.tlsEnabled | quote }}
2 changes: 1 addition & 1 deletion deploy/helm/templates/workshop/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ spec:
imagePullPolicy: {{ .Values.waitForK8sResources.imagePullPolicy }}
args:
- "service"
- {{ .Values.community.service.name | quote }}
- {{ .Values.community_graphql.service.name | quote }}
containers:
- name: {{ .Values.workshop.name }}
image: {{ .Values.workshop.image }}:{{ .Chart.AppVersion }}
Expand Down
Loading