From 63af261a2a26ce18d1d55242c6cb017408f7cdc8 Mon Sep 17 00:00:00 2001 From: vishalmishraa Date: Wed, 28 Aug 2024 15:33:37 +0530 Subject: [PATCH] add compiler deployment --- docker/worker-compiler/Dockerfile | 5 ++-- k8s/33-compiler/deployment.yml | 39 +++++++++++++++++++++++++++ k8s/33-compiler/secret.yml | 12 +++++++++ k8s/33-compiler/services.yml | 13 +++++++++ k8s/44-worker-compiler/deployment.yml | 9 ++++++- 5 files changed, 75 insertions(+), 3 deletions(-) create mode 100644 k8s/33-compiler/deployment.yml create mode 100644 k8s/33-compiler/secret.yml create mode 100644 k8s/33-compiler/services.yml diff --git a/docker/worker-compiler/Dockerfile b/docker/worker-compiler/Dockerfile index d3e2e93..544f56e 100644 --- a/docker/worker-compiler/Dockerfile +++ b/docker/worker-compiler/Dockerfile @@ -3,6 +3,9 @@ FROM node:20-alpine ARG DATABASE_URL ARG REDIS_URL +# Install g++ compiler +RUN apk add --no-cache g++ + # Set the working directory in the container WORKDIR /usr/src/app @@ -12,8 +15,6 @@ COPY ../../apps/worker-compiler /usr/src/app/apps/worker-compiler COPY ../../package.json /usr/src/app/package.json COPY ../../turbo.json /usr/src/app/turbo.json - - # Install dependencies RUN npm install diff --git a/k8s/33-compiler/deployment.yml b/k8s/33-compiler/deployment.yml new file mode 100644 index 0000000..d33b4d9 --- /dev/null +++ b/k8s/33-compiler/deployment.yml @@ -0,0 +1,39 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: compiler + namespace: default +spec: + replicas: 1 + selector: + matchLabels: + app: compiler + template: + metadata: + labels: + app: compiler + spec: + containers: + - name: main-container + image: vishal022/algoearth-compiler:latest + ports: + - containerPort: 3005 + volumeMounts: + - name: problems + mountPath: /dev/problems + env: + - name: DATABASE_URL + valueFrom: + secretKeyRef: + name: algoearth-compiler-secret + key: DATABASE_URL + - name: REDIS_URL + valueFrom: + secretKeyRef: + name: algoearth-compiler-secret + key: REDIS_URL + volumes: + - name: problems + persistentVolumeClaim: + claimName: problems-pvc +--- \ No newline at end of file diff --git a/k8s/33-compiler/secret.yml b/k8s/33-compiler/secret.yml new file mode 100644 index 0000000..952e59c --- /dev/null +++ b/k8s/33-compiler/secret.yml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Secret +metadata: + name: algoearth-compiler-secret +type: Opaque +data: + DATABASE_URL: + REDIS_URL: + NEXTAUTH_SECRET: + JUDGE0_URI: + CLOUD_FLARE_TURNSTILE_SITE_KEY: + CLOUD_FLARE_TURNSTILE_SECRET_KEY: diff --git a/k8s/33-compiler/services.yml b/k8s/33-compiler/services.yml new file mode 100644 index 0000000..613b102 --- /dev/null +++ b/k8s/33-compiler/services.yml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: algoearth-compiler-service + namespace: default +spec: + selector: + app: compiler + ports: + - protocol: TCP + port: 3005 + targetPort: 3005 + type: ClusterIP \ No newline at end of file diff --git a/k8s/44-worker-compiler/deployment.yml b/k8s/44-worker-compiler/deployment.yml index c6ee604..93a8708 100644 --- a/k8s/44-worker-compiler/deployment.yml +++ b/k8s/44-worker-compiler/deployment.yml @@ -15,6 +15,9 @@ spec: containers: - name: worker-compiler image: vishal022/algoearth-worker-compiler:latest + volumeMounts: + - name: problems + mountPath: /dev/problems env: - name: DATABASE_URL valueFrom: @@ -25,4 +28,8 @@ spec: valueFrom: secretKeyRef: name: algoearth-wc - key: REDIS_URL \ No newline at end of file + key: REDIS_URL + volumes: + - name: problems + persistentVolumeClaim: + claimName: problems-pvc \ No newline at end of file