Skip to content

Commit

Permalink
Feat/build push (#34)
Browse files Browse the repository at this point in the history
* feat(deployment): build push simple services

* feat(workflow): created workflows for each service

* feat(deployment): build push simple services

* feat(deployment): kube files for all simple services

* Feat/deployment (#28)

* fix(mcq): fixed issue where only 1 MCQ was being generated by gpt

* fix(client): minor qol fixes

* fix(mcq): added additonal fixes

* fix(profile): fixed cards

* fix(subscribe): added blue box

* feat(MCQ): added option to reorder, delete or add options

---------

Co-authored-by: neilscallywag <neil.sharma.2022@scis.smu.edu.sg>
Co-authored-by: Louis <64778758+iamlouisteo@users.noreply.github.com>

* chore(upload-note): added env file

* fix(docker): fixed docker file to add env file for upload note

* chore(deployment): build push complex service images

* feat(kubernetes): finished manifest

* chore(kong): build and push kong image

* chore(kong): added health check path

* fix(user-storage): rebuild image

* fix(subscriptions): rebuild image

* fix(subscriptions): rebuild image

* fix(payment): rebuild image

* fix(contents): rebuild image

* fix(notes & fileprocessor): rebuild image

* fix(deployment): rebuild image

* fix(handletempcontent): rebuild image

* fix(makepayment & verifyuser): rebuild image

* fix(kong): rebuild image

* fix(userstorage & kong): temp fix

* fix(contents): fix redis connection

* fix(process-chunks): fix connection to aws mq

* fix(deploy): fix connection

* fix

* fix(upload-notes): fixed rabbit connection

* fix(upload-notes): fixed rabbit connection

* fix(upload-notes): fixed rabbit connection

* fix(upload-notes): fixed rabbit connection

* fix(upload-notes): fixed rabbit connection

* fix(upload-notes): fixed rabbit connection

* fix(upload-notes): fixed rabbit connection

* fix(upload-notes): fixed rabbit connection

* fix(upload-notes): fixed rabbit connection

* fix(upload-notes): fixed rabbit connection

* fix(upload-notes): fixed rabbit connection

* fix(upload-notes): fixed rabbit connection

* fix(upload-notes): fixed rabbit connection

* fix(upload-notes): fixed rabbit connection

* fix(upload-notes): fixed rabbit connection

* fix(upload-notes): fixed rabbit connection

* fix(contents): fix redis connection

* feat(terraform): resources creation done

* feat(kubernetes): done

* fix(user-storage): singass auth use random email

* fix(user-storage): singass auth use random email

---------

Co-authored-by: neilscallywag <neil.sharma.2022@scis.smu.edu.sg>
Co-authored-by: Louis <64778758+iamlouisteo@users.noreply.github.com>
  • Loading branch information
3 people authored Apr 23, 2024
1 parent ddf25ef commit 17b29f1
Show file tree
Hide file tree
Showing 118 changed files with 1,991 additions and 687 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/contents.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- feat/build-push
paths:
- 'backend/simple/contents/**'

Expand Down Expand Up @@ -32,7 +33,7 @@ jobs:
uses: docker/build-push-action@v2
with:
context: ./backend/simple/contents/
file: ./backend/simple/contents/Dockerfile
file: ./backend/simple/contents/Contents.Dockerfile
push: true
tags: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/${{ secrets.ECR_REPOSITORY }}:contents
platforms: linux/arm64
3 changes: 2 additions & 1 deletion .github/workflows/fileprocessor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- feat/build-push
paths:
- 'backend/simple/fileprocessor/**'

Expand Down Expand Up @@ -32,7 +33,7 @@ jobs:
uses: docker/build-push-action@v2
with:
context: ./backend/simple/fileprocessor/
file: ./backend/simple/fileprocessor/Dockerfile
file: ./backend/simple/fileprocessor/Fileprocessor.Dockerfile
push: true
tags: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/${{ secrets.ECR_REPOSITORY }}:fileprocessor
platforms: linux/arm64
3 changes: 2 additions & 1 deletion .github/workflows/handle-temporary-contents.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- feat/build-push
paths:
- 'backend/complex/handle-temporary-contents/**'

Expand Down Expand Up @@ -32,7 +33,7 @@ jobs:
uses: docker/build-push-action@v2
with:
context: ./backend/complex/handle-temporary-contents/
file: ./backend/complex/handle-temporary-contents/Dockerfile
file: ./backend/complex/handle-temporary-contents/HTC.Dockerfile
push: true
tags: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/${{ secrets.ECR_REPOSITORY }}:handle-temporary-contents
platforms: linux/arm64
3 changes: 2 additions & 1 deletion .github/workflows/kong-gateway.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- feat/build-push
paths:
- 'backend/kong-gateway/**'

Expand Down Expand Up @@ -32,7 +33,7 @@ jobs:
uses: docker/build-push-action@v2
with:
context: ./backend/kong-gateway/
file: ./backend/kong-gateway/Dockerfile
file: ./backend/kong-gateway/Kong.Dockerfile
push: true
tags: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/${{ secrets.ECR_REPOSITORY }}:kong-gateway
platforms: linux/arm64
3 changes: 2 additions & 1 deletion .github/workflows/make-payment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- feat/build-push
paths:
- 'backend/complex/make-payment/**'

Expand Down Expand Up @@ -32,7 +33,7 @@ jobs:
uses: docker/build-push-action@v2
with:
context: ./backend/complex/make-payment/
file: ./backend/complex/make-payment/Dockerfile
file: ./backend/complex/make-payment/MakePayment.Dockerfile
push: true
tags: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/${{ secrets.ECR_REPOSITORY }}:make-payment
platforms: linux/arm64
3 changes: 2 additions & 1 deletion .github/workflows/notes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- feat/build-push
paths:
- 'backend/simple/notes/**'

Expand Down Expand Up @@ -32,7 +33,7 @@ jobs:
uses: docker/build-push-action@v2
with:
context: ./backend/simple/notes/
file: ./backend/simple/notes/Dockerfile
file: ./backend/simple/notes/Notes.Dockerfile
push: true
tags: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/${{ secrets.ECR_REPOSITORY }}:notes
platforms: linux/arm64
3 changes: 2 additions & 1 deletion .github/workflows/payment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- feat/build-push
paths:
- 'backend/simple/payment/**'

Expand Down Expand Up @@ -32,7 +33,7 @@ jobs:
uses: docker/build-push-action@v2
with:
context: ./backend/simple/payment/
file: ./backend/simple/payment/Dockerfile
file: ./backend/simple/payment/Payment.Dockerfile
push: true
tags: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/${{ secrets.ECR_REPOSITORY }}:payment
platforms: linux/arm64
1 change: 1 addition & 0 deletions .github/workflows/process-chunks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- feat/build-push
paths:
- 'backend/complex/process-chunks/**'

Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/save-notes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- feat/build-push
paths:
- 'backend/complex/save-notes/**'

Expand Down Expand Up @@ -32,7 +33,7 @@ jobs:
uses: docker/build-push-action@v2
with:
context: ./backend/complex/save-notes/
file: ./backend/complex/save-notes/Dockerfile
file: ./backend/complex/save-notes/SaveNotes.Dockerfile
push: true
tags: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/${{ secrets.ECR_REPOSITORY }}:save-notes
platforms: linux/arm64
3 changes: 2 additions & 1 deletion .github/workflows/subscriptions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- feat/build-push
paths:
- 'backend/simple/subscriptions/**'

Expand Down Expand Up @@ -32,7 +33,7 @@ jobs:
uses: docker/build-push-action@v2
with:
context: ./backend/simple/subscriptions/
file: ./backend/simple/subscriptions/Dockerfile
file: ./backend/simple/subscriptions/Subscriptions.Dockerfile
push: true
tags: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/${{ secrets.ECR_REPOSITORY }}:subscriptions
platforms: linux/arm64
3 changes: 2 additions & 1 deletion .github/workflows/upload-notes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- feat/build-push
paths:
- 'backend/complex/upload-notes/**'

Expand Down Expand Up @@ -32,7 +33,7 @@ jobs:
uses: docker/build-push-action@v2
with:
context: ./backend/complex/upload-notes/
file: ./backend/complex/upload-notes/Dockerfile
file: ./backend/complex/upload-notes/UploadNotes.Dockerfile
push: true
tags: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/${{ secrets.ECR_REPOSITORY }}:upload-notes
platforms: linux/arm64
3 changes: 2 additions & 1 deletion .github/workflows/user-storage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- feat/build-push
paths:
- 'backend/simple/user-storage/**'

Expand Down Expand Up @@ -32,7 +33,7 @@ jobs:
uses: docker/build-push-action@v2
with:
context: ./backend/simple/user-storage/
file: ./backend/simple/user-storage/Dockerfile
file: ./backend/simple/user-storage/UserStorage.Dockerfile
push: true
tags: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/${{ secrets.ECR_REPOSITORY }}:user-storage
platforms: linux/arm64
3 changes: 2 additions & 1 deletion .github/workflows/verify-user.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- feat/build-push
paths:
- 'backend/complex/verify-user/**'

Expand Down Expand Up @@ -32,7 +33,7 @@ jobs:
uses: docker/build-push-action@v2
with:
context: ./backend/complex/verify-user/
file: ./backend/complex/verify-user/Dockerfile
file: ./backend/complex/verify-user/VerifyUser.Dockerfile
push: true
tags: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/${{ secrets.ECR_REPOSITORY }}:verify-user
platforms: linux/arm64
3 changes: 2 additions & 1 deletion .github/workflows/view-notes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- feat/build-push
paths:
- 'backend/complex/view-notes/**'

Expand Down Expand Up @@ -32,7 +33,7 @@ jobs:
uses: docker/build-push-action@v2
with:
context: ./backend/complex/view-notes/
file: ./backend/complex/view-notes/Dockerfile
file: ./backend/complex/view-notes/ViewNotes.Dockerfile
push: true
tags: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/${{ secrets.ECR_REPOSITORY }}:view-notes
platforms: linux/arm64
28 changes: 28 additions & 0 deletions backend/complex/handle-temporary-contents/HTC.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM developwithzt/esd-buf-healthprobe-base:go-1.0 as proto-base
COPY buf.* .
COPY api/ api/
RUN buf generate

FROM golang:alpine3.19 AS builder
WORKDIR /app

# Install curl to fetch grpc_health_probe
RUN apk --no-cache add curl

COPY go.mod go.sum ./
RUN go mod download
COPY --from=proto-base /app/pb/ pb/
COPY cmd/ cmd/
COPY internal/ internal/
RUN go build -o /app/build/server cmd/main.go

# Download and install the gRPC health probe
RUN GRPC_HEALTH_PROBE_VERSION=v0.4.13 && \
curl -sLo /app/build/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-arm64 && \
chmod +x /app/build/grpc_health_probe

FROM gcr.io/distroless/static-debian12
WORKDIR /app
COPY --from=builder /app/build/grpc_health_probe /bin/grpc_health_probe
COPY --from=builder /app/build/server .
CMD ["./server"]
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/EchoSkorJjj/IS213-Education-Helper/handle-temporary-contents/pb/contents"
)


type ContentClient struct {
Conn *grpc.ClientConn
Stub contents.ContentClient
Expand Down
28 changes: 28 additions & 0 deletions backend/complex/make-payment/MakePayment.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM developwithzt/esd-buf-healthprobe-base:go-1.0 as proto-base
COPY buf.* .
COPY api/ api/
RUN buf generate

FROM golang:alpine3.19 AS builder
WORKDIR /app

# Install curl to fetch grpc_health_probe
RUN apk --no-cache add curl

COPY go.mod go.sum ./
RUN go mod download
COPY --from=proto-base /app/pb/ pb/
COPY cmd/ cmd/
COPY internal/ internal/
RUN go build -o /app/build/server cmd/main.go

# Download and install the gRPC health probe
RUN GRPC_HEALTH_PROBE_VERSION=v0.4.13 && \
curl -sLo /app/build/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-arm64 && \
chmod +x /app/build/grpc_health_probe

FROM gcr.io/distroless/static-debian12
WORKDIR /app
COPY --from=builder /app/build/grpc_health_probe /bin/grpc_health_probe
COPY --from=builder /app/build/server .
CMD ["./server"]
1 change: 1 addition & 0 deletions backend/complex/make-payment/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
makepaymentPb "github.com/EchoSkorJjj/IS213-Education-Helper/make-payment/pb/make_payment"
)


func main() {
err := godotenv.Load()
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion backend/complex/process-chunks/.env
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ CONTENT_SERVICE_ADDRESS=contents-service:50051
RABBITMQ_SERVER=rabbitmq
RABBITMQ_USERNAME=user
RABBITMQ_PASSWORD=password
OPENAI_API_KEYS= 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
ENVIRONMENT=development
OPENAI_API_KEYS=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
# ,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,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,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,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,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,
1 change: 1 addition & 0 deletions backend/complex/process-chunks/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ RUN pyinstaller \
--hidden-import=tiktoken_ext \
--onefile main.py


FROM debian:stable-slim
WORKDIR /app
COPY --from=builder /app/dist/main server
Expand Down
14 changes: 13 additions & 1 deletion backend/complex/process-chunks/src/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import grpc
import pika
import ssl
import os
import re
import json
Expand Down Expand Up @@ -42,8 +43,19 @@ def initialize_api_key_cycle(self):

def initialize_rabbitmq(self):
"""Initializes the RabbitMQ connection and channels."""

ssl_context = None
if os.getenv("ENVIRONMENT") == "production":
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
ssl_context.set_ciphers('ECDHE+AESGCM:!ECDSA')

credentials = pika.PlainCredentials(self.RABBITMQ_USERNAME, self.RABBITMQ_PASSWORD)
connection_parameters = pika.ConnectionParameters(host=self.RABBITMQ_SERVER, credentials=credentials)
connection_parameters = pika.ConnectionParameters(
host=self.RABBITMQ_SERVER,
credentials=credentials,
ssl_options=pika.SSLOptions(context=ssl_context) if ssl_context else None
)

self.connection = pika.BlockingConnection(connection_parameters)
self.channel = self.connection.channel()
self.channel.queue_declare(queue=self.QUEUE_NAME_1, durable=True)
Expand Down
30 changes: 30 additions & 0 deletions backend/complex/save-notes/SaveNotes.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM developwithzt/esd-buf-healthprobe-base:general-1.0 as proto-base
COPY buf.* .
COPY protos/ protos/
RUN buf generate

FROM python:3.11.7 as builder
WORKDIR /app
RUN pip install pyinstaller
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY --from=proto-base /app/pb/ /app/pb/
ENV PYTHONPATH /app/:/app/pb/:$PYTHONPATH
COPY src/ src/
RUN pyinstaller --onefile src/main.py

FROM debian:stable-slim
WORKDIR /app

# Install curl and other necessary utilities
RUN apt-get update && \
apt-get install -y curl && \
rm -rf /var/lib/apt/lists/*

# Download and install the gRPC health probe, used for checking the health of gRPC applications
RUN GRPC_HEALTH_PROBE_VERSION=v0.4.13 && \
curl -sLo /bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-arm64 && \
chmod +x /bin/grpc_health_probe

COPY --from=builder /app/dist/main server
CMD ["./server"]
Loading

0 comments on commit 17b29f1

Please sign in to comment.