diff --git a/.env b/.env index 0256ef612f..1070549e88 100644 --- a/.env +++ b/.env @@ -1,10 +1,19 @@ # URLs - change these to your local or cloud deployment IP address/URL if necessary -PUBLIC_URL=http://localhost -WS_PUBLIC_URL=ws://localhost +PUBLIC_URL=http://34.149.216.116 +WS_PUBLIC_URL=ws://34.149.216.116 # Port numbers - change these if you are already using these ports for other (non-PeerPrep) services FRONTEND_PORT=3000 QUESTION_API_PORT=2000 USER_API_PORT=3001 MATCHING_API_PORT=3002 -COLLAB_API_PORT=3003 \ No newline at end of file +COLLAB_API_PORT=3003 + +# Use internal DNS names +# FRONTEND_API_URL=http://35.240.249.202 +# USER_API_URL=http://35.197.128.24 +# QUESTION_API_URL=http://35.247.159.214 +# MATCHING_API_URL=http://35.197.129.244 +# COLLAB_API_URL=http://34.126.181.193 +# KAFKA_URL=http://34.142.245.12 +# ZOOKEEPER_URL=http://35.247.142.189 \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6093f0070f..50da7511db 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,7 +50,7 @@ jobs: - name: Build and push Docker images run: | docker compose build - services=("frontend" "matching-service" "question" "signaling-service" "user") + services=("frontend" "matching-service" "question" "collab-service" "user") for service in "${services[@]}"; do image="asia-southeast1-docker.pkg.dev/tokyo-crossbar-440806-u9/peerprep/$service:latest" docker tag "cs3219-ay2425s1-project-g44-$service" "$image" diff --git a/docker-compose.yml b/docker-compose.yml index 400139ae1f..11277f7f8f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,6 +14,13 @@ services: USER_API_PORT: ${USER_API_PORT} MATCHING_API_PORT: ${MATCHING_API_PORT} COLLAB_API_PORT: ${COLLAB_API_PORT} + FRONTEND_API_URL: ${FRONTEND_API_URL} + USER_API_URL: ${USER_API_URL} + QUESTION_API_URL: ${QUESTION_API_URL} + MATCHING_API_URL: ${MATCHING_API_URL} + COLLAB_API_URL: ${COLLAB_API_URL} + KAFKA_URL: ${KAFKA_URL} + ZOOKEEPER_URL: ${ZOOKEEPER_URL} ports: - "${FRONTEND_PORT}:${FRONTEND_PORT}" develop: diff --git a/frontend/Dockerfile.dev b/frontend/Dockerfile.dev index d926e1ac0d..b8056c10fc 100644 --- a/frontend/Dockerfile.dev +++ b/frontend/Dockerfile.dev @@ -8,28 +8,44 @@ ARG QUESTION_API_PORT ARG USER_API_PORT ARG MATCHING_API_PORT ARG COLLAB_API_PORT +ARG FRONTEND_API_URL +ARG USER_API_URL +ARG QUESTION_API_URL +ARG MATCHING_API_URL +ARG COLLAB_API_URL ENV PUBLIC_URL=${PUBLIC_URL} ENV WS_PUBLIC_URL=${WS_PUBLIC_URL} +ENV FRONTEND_API_URL=${USER_API_URL} +ENV USER_API_URL=${USER_API_URL} +ENV QUESTION_API_URL=${QUESTION_API_URL} +ARG MATCHING_API_URL=${MATCHING_API_URL} +ARG COLLAB_API_URL=${COLLAB_API_URL} ENV FRONTEND_PORT=${FRONTEND_PORT} -ENV NEXT_PUBLIC_FRONTEND_URL=${PUBLIC_URL}:${FRONTEND_PORT} +# ENV NEXT_PUBLIC_FRONTEND_URL=${FRONTEND_API_URL}:${FRONTEND_PORT} +ENV NEXT_PUBLIC_FRONTEND_URL=${PUBLIC_URL} ENV QUESTION_API_PORT=${QUESTION_API_PORT} -ENV NEXT_PUBLIC_QUESTION_API_BASE_URL=${PUBLIC_URL}:${QUESTION_API_PORT}/questions +# ENV NEXT_PUBLIC_QUESTION_API_BASE_URL=${QUESTION_API_URL}:${QUESTION_API_PORT}/questions +ENV NEXT_PUBLIC_QUESTION_API_BASE_URL=${PUBLIC_URL}/questions + ENV USER_API_PORT=${USER_API_PORT} -ENV USER_API_BASE_URL=${PUBLIC_URL}:${USER_API_PORT} +# ENV USER_API_BASE_URL=${PUBLIC_URL}:${USER_API_PORT} +ENV USER_API_BASE_URL=${PUBLIC_URL} ENV NEXT_PUBLIC_USER_API_AUTH_URL=${USER_API_BASE_URL}/auth ENV NEXT_PUBLIC_USER_API_USERS_URL=${USER_API_BASE_URL}/users ENV NEXT_PUBLIC_USER_API_EMAIL_URL=${USER_API_BASE_URL}/email ENV NEXT_PUBLIC_USER_API_HISTORY_URL=${USER_API_BASE_URL}/users/history ENV MATCHING_API_PORT=${MATCHING_API_PORT} -ENV NEXT_PUBLIC_MATCHING_API_URL=${PUBLIC_URL}:${MATCHING_API_PORT}/matching +# ENV NEXT_PUBLIC_MATCHING_API_URL=${MATCHING_API_URL}:${MATCHING_API_PORT}/matching +ENV NEXT_PUBLIC_MATCHING_API_URL=${PUBLIC_URL}/matching ENV COLLAB_API_PORT=${COLLAB_API_PORT} -ENV NEXT_PUBLIC_COLLAB_API_URL=${PUBLIC_URL}:${COLLAB_API_PORT} +# ENV NEXT_PUBLIC_COLLAB_API_URL=${COLLAB_API_URL}:${COLLAB_API_PORT} +ENV NEXT_PUBLIC_COLLAB_API_URL=${PUBLIC_URL} COPY package.json package-lock.json ./ RUN npm ci diff --git a/kubernetes/signaling-service-deployment.yaml b/kubernetes/collab-service-deployment.yaml similarity index 69% rename from kubernetes/signaling-service-deployment.yaml rename to kubernetes/collab-service-deployment.yaml index f85defbb96..703f0c9a69 100644 --- a/kubernetes/signaling-service-deployment.yaml +++ b/kubernetes/collab-service-deployment.yaml @@ -1,20 +1,20 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: signaling-service + name: collab-service spec: replicas: 1 selector: matchLabels: - app: signaling-service + app: collab-service template: metadata: labels: - app: signaling-service + app: collab-service spec: containers: - - image: asia-southeast1-docker.pkg.dev/tokyo-crossbar-440806-u9/peerprep/signaling-service:latest - name: signaling-service + - image: asia-southeast1-docker.pkg.dev/tokyo-crossbar-440806-u9/peerprep/collab-service:latest + name: collab-service ports: - containerPort: 3003 protocol: TCP diff --git a/kubernetes/signaling-service-service.yaml b/kubernetes/collab-service-service.yaml similarity index 65% rename from kubernetes/signaling-service-service.yaml rename to kubernetes/collab-service-service.yaml index 29d1355c97..0f99ef3c0d 100644 --- a/kubernetes/signaling-service-service.yaml +++ b/kubernetes/collab-service-service.yaml @@ -1,11 +1,12 @@ apiVersion: v1 kind: Service metadata: - name: signaling-service + name: collab-service spec: + type: ClusterIP ports: - name: "3003" port: 3003 targetPort: 3003 selector: - app: signaling-service + app: collab-service diff --git a/kubernetes/frontend-ingress.yaml b/kubernetes/frontend-ingress.yaml new file mode 100644 index 0000000000..b8bbf4a7bc --- /dev/null +++ b/kubernetes/frontend-ingress.yaml @@ -0,0 +1,67 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: frontend-ingress + annotations: + kubernetes.io/ingress.global-static-ip-name: "peerprep" +spec: + ingressClassName: "gce" + rules: + - http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: frontend + port: + number: 3000 + - path: /users + pathType: Prefix + backend: + service: + name: user + port: + number: 3001 + - path: /auth + pathType: Prefix + backend: + service: + name: user + port: + number: 3001 + - path: /email + pathType: Prefix + backend: + service: + name: user + port: + number: 3001 + - path: /users/history + pathType: Prefix + backend: + service: + name: user + port: + number: 3001 + - path: /questions + pathType: Prefix + backend: + service: + name: question + port: + number: 2000 + - path: /matching + pathType: Prefix + backend: + service: + name: matching-service + port: + number: 3002 + - path: / + pathType: Prefix + backend: + service: + name: collab-service + port: + number: 3003 \ No newline at end of file diff --git a/kubernetes/frontend-service.yaml b/kubernetes/frontend-service.yaml index 02343dc96f..ab3b9215a9 100644 --- a/kubernetes/frontend-service.yaml +++ b/kubernetes/frontend-service.yaml @@ -3,7 +3,7 @@ kind: Service metadata: name: frontend spec: - type: LoadBalancer + type: ClusterIP ports: - name: "3000" port: 3000 diff --git a/kubernetes/kafka-deployment.yaml b/kubernetes/kafka-container-deployment.yaml similarity index 96% rename from kubernetes/kafka-deployment.yaml rename to kubernetes/kafka-container-deployment.yaml index 5ee83f42bd..4e764a34c8 100644 --- a/kubernetes/kafka-deployment.yaml +++ b/kubernetes/kafka-container-deployment.yaml @@ -35,7 +35,7 @@ spec: failureThreshold: 10 periodSeconds: 10 timeoutSeconds: 5 - name: kafka-containter + name: kafka-container ports: - containerPort: 9092 protocol: TCP diff --git a/kubernetes/kafka-service.yaml b/kubernetes/kafka-container-service.yaml similarity index 90% rename from kubernetes/kafka-service.yaml rename to kubernetes/kafka-container-service.yaml index 2447f024b9..08e5d89d84 100644 --- a/kubernetes/kafka-service.yaml +++ b/kubernetes/kafka-container-service.yaml @@ -3,6 +3,7 @@ kind: Service metadata: name: kafka-container spec: + type: ClusterIP ports: - name: "9092" port: 9092 diff --git a/kubernetes/matching-service-service.yaml b/kubernetes/matching-service-service.yaml index e6f03f3b27..f52708ed27 100644 --- a/kubernetes/matching-service-service.yaml +++ b/kubernetes/matching-service-service.yaml @@ -3,6 +3,7 @@ kind: Service metadata: name: matching-service spec: + type: ClusterIP ports: - name: "3002" port: 3002 diff --git a/kubernetes/question-service.yaml b/kubernetes/question-service.yaml index 22357febdf..95349518dc 100644 --- a/kubernetes/question-service.yaml +++ b/kubernetes/question-service.yaml @@ -3,6 +3,7 @@ kind: Service metadata: name: question spec: + type: ClusterIP ports: - name: "2000" port: 2000 diff --git a/kubernetes/zookeeper-service.yaml b/kubernetes/zookeeper-service.yaml index a456d0841e..0036e715e2 100644 --- a/kubernetes/zookeeper-service.yaml +++ b/kubernetes/zookeeper-service.yaml @@ -3,6 +3,7 @@ kind: Service metadata: name: zookeeper spec: + type: ClusterIP ports: - name: "2181" port: 2181