Skip to content

Commit

Permalink
Merge branch 'main' into feature/feedback-api-changes
Browse files Browse the repository at this point in the history
# Conflicts:
#	client/go.mod
#	client/go.sum
#	server/api/tumdev/campus_backend.pb.go
#	server/api/tumdev/campus_backend.pb.gw.go
#	server/api/tumdev/campus_backend.proto
#	server/api/tumdev/campus_backend.swagger.json
#	server/api/tumdev/campus_backend_grpc.pb.go
#	server/backend/cron/feedback_email.go
#	server/backend/cron/feedback_email_test.go
#	server/backend/migration/20230826000000.go
#	server/model/feedback.go
  • Loading branch information
CommanderStorm committed Oct 2, 2023
2 parents 18e426a + 70958ab commit c6f6b51
Show file tree
Hide file tree
Showing 37 changed files with 2,269 additions and 1,828 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: '1.21'
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: '1.21'
Expand All @@ -22,10 +22,10 @@ jobs:
needs: [test]
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: ghcr.io/tum-dev/campus-backend/backend-server
tags: |
Expand All @@ -38,15 +38,15 @@ jobs:
prefix=
suffix=
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
- name: Login to registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker images
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
context: server
pull: true
Expand Down
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ repos:
language: system
pass_filenames: false
stages: [commit]
- id: go-mod-tidy-client
name: Check if go.mod and go.sum are up to date for server
files: server/
entry: sh -c "(cd client && go get github.com/TUM-Dev/Campus-Backend/server && go mod tidy)"
language: system
pass_filenames: false
stages: [commit]
#- id: go-mod-tidy-client
# name: Check if go.mod and go.sum are up to date for server
# files: server/
# entry: sh -c "(cd client && go get github.com/TUM-Dev/Campus-Backend/server && go mod tidy)"
# language: system
# pass_filenames: false
# stages: [commit]
4 changes: 2 additions & 2 deletions client/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ module github.com/TUM-Dev/Campus-Backend/client
go 1.21

require (
github.com/TUM-Dev/Campus-Backend/server v0.0.0-20230922221907-9ec2b923010a
github.com/TUM-Dev/Campus-Backend/server v0.0.0-20231002172727-f2caad45ba86
github.com/sirupsen/logrus v1.9.3
google.golang.org/grpc v1.58.1
google.golang.org/grpc v1.58.2
)

require (
Expand Down
8 changes: 4 additions & 4 deletions client/go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github.com/TUM-Dev/Campus-Backend/server v0.0.0-20230922221907-9ec2b923010a h1:t7ahAwtri1UztDL6t0kce0OOkblQVHdMIWrhHkuEelQ=
github.com/TUM-Dev/Campus-Backend/server v0.0.0-20230922221907-9ec2b923010a/go.mod h1:FIIdW5aglREN0ULXZXDQtvuBdbTMa/fCrKSTS8FYP7k=
github.com/TUM-Dev/Campus-Backend/server v0.0.0-20231002172727-f2caad45ba86 h1:85AgSUlXj6g6JCuAQEv2ya7rD1mTvC4FNsQA3jsNiLI=
github.com/TUM-Dev/Campus-Backend/server v0.0.0-20231002172727-f2caad45ba86/go.mod h1:wrzx8AE9r2dpCuXTcm36XIUQLBAnOH21Hsnt0mpxPbQ=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down Expand Up @@ -35,8 +35,8 @@ google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb h1:
google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb/go.mod h1:KjSP20unUpOx5kyQUFa7k4OJg0qeJ7DEZflGDu2p6Bk=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230913181813-007df8e322eb h1:Isk1sSH7bovx8Rti2wZK0UZF6oraBDK74uoyLEEVFN0=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230913181813-007df8e322eb/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M=
google.golang.org/grpc v1.58.1 h1:OL+Vz23DTtrrldqHK49FUOPHyY75rvFqJfXC84NYW58=
google.golang.org/grpc v1.58.1/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0=
google.golang.org/grpc v1.58.2 h1:SXUpjxeVF3FKrTYQI4f4KvbGD5u2xccdYdurwowix5I=
google.golang.org/grpc v1.58.2/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
Expand Down
4 changes: 2 additions & 2 deletions client/local/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func generateCanteenRating(c pb.CampusClient, ctx context.Context, canteen strin
TagId: 2,
}

_, err := c.NewCanteenRating(ctx, &pb.NewCanteenRatingRequest{
_, err := c.CreateCanteenRating(ctx, &pb.CreateCanteenRatingRequest{
Points: rating,
CanteenId: canteen,
Comment: "Alles super, 2 Sterne",
Expand Down Expand Up @@ -219,7 +219,7 @@ func generateDishRating(c pb.CampusClient, ctx context.Context, canteen string,
TagId: 3,
}

_, err := c.NewDishRating(ctx, &pb.NewDishRatingRequest{
_, err := c.CreateDishRating(ctx, &pb.CreateDishRatingRequest{
Points: rating,
CanteenId: canteen,
Dish: dish,
Expand Down
59 changes: 59 additions & 0 deletions deployment/charts/backend/files/envoy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
admin:
address:
socket_address:
address: 0.0.0.0
port_value: 9901
static_resources:
listeners:
- name: listener_0
address:
socket_address:
address: 0.0.0.0
port_value: 8081
filter_chains:
- filters:
- name: envoy.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
codec_type: auto
stat_prefix: ingress_http
route_config:
name: local_route
virtual_hosts:
- name: local_service
domains: ["*"]
routes:
- match: { prefix: "/" }
route: { cluster: campus_service }
cors:
allow_origin_string_match:
- prefix: "*"
allow_methods: GET, PUT, DELETE, POST, OPTIONS
allow_headers: keep-alive,user-agent,cache-control,content-type,content-transfer-encoding,custom-header-1,x-accept-content-transfer-encoding,x-accept-response-streaming,x-user-agent,x-grpc-web,grpc-timeout
max_age: "1728000"
expose_headers: custom-header-1,grpc-status,grpc-message
http_filters:
- name: envoy.grpc_web
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.grpc_web.v3.GrpcWeb
- name: envoy.filters.http.cors
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.cors.v3.Cors
- name: envoy.filters.http.router
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
clusters:
- name: campus_service
connect_timeout: 0.25s
type: LOGICAL_DNS
http2_protocol_options: {}
lb_policy: ROUND_ROBIN
load_assignment:
cluster_name: campus_service
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: localhost
port_value: 50051
53 changes: 51 additions & 2 deletions deployment/charts/backend/templates/deployments/backend-v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,44 @@ spec:
- name: backend-api-keys
secret:
secretName: backend-api-keys
- name: backend-grpc-web-config
configMap:
name: backend-grpc-web-config
containers:
- name: grpc-web-proxy
image: envoyproxy/envoy:v1.27-latest
imagePullPolicy: IfNotPresent
args:
- --config-path
- /etc/envoy/envoy.yaml
- --service-cluster
- backend-v2
- --service-node
- backend-v2
- --log-level
- info
ports:
- containerPort: 8081
name: http
- containerPort: 9901
name: admin
volumeMounts:
- mountPath: /etc/envoy/envoy.yaml
subPath: envoy.yaml
name: backend-grpc-web-config
readOnly: true
livenessProbe:
httpGet:
path: /ready
port: admin
failureThreshold: 5
periodSeconds: 1
startupProbe:
httpGet:
path: /ready
port: admin
failureThreshold: 60
periodSeconds: 1
- name: tca-backend
image: ghcr.io/tum-dev/campus-backend/backend-server:{{ $.Values.tag }}
imagePullPolicy: Always
Expand Down Expand Up @@ -91,13 +128,13 @@ spec:
httpGet:
path: /health
port: http
failureThreshold: 1
failureThreshold: 5
periodSeconds: 1
startupProbe:
httpGet:
path: /health
port: http
failureThreshold: 20
failureThreshold: 60
periodSeconds: 1
---
apiVersion: v1
Expand All @@ -115,3 +152,15 @@ data:
apns_auth_key.p8: {{ $.Values.backend.apns.auth_key }}
APNS_KEY_ID: {{ $.Values.backend.apns.key_id | b64enc }}
APNS_TEAM_ID: {{ $.Values.backend.apns.team_id | b64enc }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: backend-grpc-web-config
namespace: {{ $.Values.namespace }}
labels:
app.kubernetes.io/part-of: tum-campus-app
app.kubernetes.io/name: backend-v2
data:
envoy.yaml: |-
{{ .Files.Get "files/envoy.yaml" | indent 4 }}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ spec:
name: letsencrypt-production
kind: ClusterIssuer
dnsNames:
{{- range $host := concat $.Values.urls.v1 $.Values.urls.v2 }}
{{- range $host := concat $.Values.urls.v1 $.Values.urls.v2 $.Values.urls.v2WebGrpc }}
- {{ $host }}
{{ end }}
7 changes: 6 additions & 1 deletion deployment/charts/backend/templates/networking/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ spec:
services:
- name: backend-v2-svc
port: 50051
- kind: Rule
match: Host(`{{ join "`) || Host(`" $.Values.urls.v2WebGrpc }}`)
services:
- name: backend-v2-svc
port: 8081
- kind: Rule
match: (Host(`{{ join "`) || Host(`" $.Values.urls.v2 }}`)) && Headers(`Content-Type`, `application/grpc`)
services:
Expand All @@ -40,7 +45,7 @@ spec:
- web
routes:
- kind: Rule
match: Host(`{{ join "`) || Host(`" (concat $.Values.urls.v1 $.Values.urls.v2) }}`)
match: Host(`{{ join "`) || Host(`" (concat $.Values.urls.v1 $.Values.urls.v2 $.Values.urls.v2WebGrpc) }}`)
services:
- name: noop@internal
kind: TraefikService
Expand Down
3 changes: 3 additions & 0 deletions deployment/charts/backend/templates/networking/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ spec:
- name: http
port: 50051
targetPort: 50051
- name: grpc-web
port: 8081
targetPort: 8081
---
apiVersion: v1
kind: Service
Expand Down
3 changes: 2 additions & 1 deletion deployment/charts/backend/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ urls:
- tumcabe.in.tum.de
v2:
- api-test-v2.tum.app
- api-grpc.tum.app
- api.tum.app
v2WebGrpc:
- api-grpc.tum.app

# see https://github.com/bitnami/charts/tree/main/bitnami/mariadb for more options, the se are just the most important ones
mariadb:
Expand Down
31 changes: 29 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
services:
backend:
container_name: campus-backend
image: ghcr.io/tum-dev/campus-backend/backend-server:latest
restart: always
build:
Expand Down Expand Up @@ -32,7 +31,6 @@ services:
condition: service_healthy

db:
container_name: campus-db
image: bitnami/mariadb:latest
ports:
- ${DB_PORT:-3306}:3306
Expand All @@ -47,6 +45,35 @@ services:
interval: 15s
timeout: 5s
retries: 6
# The following code can be used to test the envoy proxy locally
# The reason why this is commented out is that this working requires the following change:
#
# ./deployment/charts/backend/files/envoy.yaml
# socket_address:
# - address: localhost
# + address: backend
# port_value: 50051
#
#grpc-web:
# image: envoyproxy/envoy:v1.27-latest
# restart: always
# command:
# - /docker-entrypoint.sh
# - --config-path
# - /etc/envoy/envoy.yaml
# - --service-cluster
# - backend-v2
# - --service-node
# - backend-v2
# - --log-level
# - info
# ports:
# - 8081:8081
# - 9901:9901
# volumes:
# - ./deployment/charts/backend/files/envoy.yaml:/etc/envoy/envoy.yaml
# depends_on:
# - backend

volumes:
campus-db-data:
Expand Down
Loading

0 comments on commit c6f6b51

Please sign in to comment.