From bf4619b78acd7ddea14c26560aa95753b6da01d6 Mon Sep 17 00:00:00 2001 From: andrei Date: Sat, 7 Jun 2025 21:43:30 +0500 Subject: [PATCH] =?UTF-8?q?feat:=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D0=BF=D0=BE=D0=B4=D0=B4=D0=B5=D1=80=D0=B6?= =?UTF-8?q?=D0=BA=D0=B0=20K8s=20=D0=B8=20Docker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- API/.dockerignore | 4 +++ API/app/main.py | 2 +- .../teamfolio-api/templates/deployment.yaml | 5 ++++ WEB/.dockerignore | 7 ++++++ WEB/.gitignore | 2 ++ WEB/Dockerfile | 25 +++++++++++++++++++ WEB/k8s/helm/teamfolio-web/Chart.yaml | 5 ++++ .../teamfolio-web/templates/deployment.yaml | 22 ++++++++++++++++ .../helm/teamfolio-web/templates/ingress.yaml | 23 +++++++++++++++++ .../helm/teamfolio-web/templates/service.yaml | 11 ++++++++ WEB/k8s/helm/teamfolio-web/values.yaml | 23 +++++++++++++++++ WEB/src/core/config.js | 2 +- 12 files changed, 129 insertions(+), 2 deletions(-) create mode 100644 API/.dockerignore create mode 100644 WEB/.dockerignore create mode 100644 WEB/Dockerfile create mode 100644 WEB/k8s/helm/teamfolio-web/Chart.yaml create mode 100644 WEB/k8s/helm/teamfolio-web/templates/deployment.yaml create mode 100644 WEB/k8s/helm/teamfolio-web/templates/ingress.yaml create mode 100644 WEB/k8s/helm/teamfolio-web/templates/service.yaml create mode 100644 WEB/k8s/helm/teamfolio-web/values.yaml diff --git a/API/.dockerignore b/API/.dockerignore new file mode 100644 index 0000000..329ed4e --- /dev/null +++ b/API/.dockerignore @@ -0,0 +1,4 @@ +.venv +k8s +.idea +.env \ No newline at end of file diff --git a/API/app/main.py b/API/app/main.py index 2207555..55181ac 100644 --- a/API/app/main.py +++ b/API/app/main.py @@ -22,7 +22,7 @@ def start_app(): api_app.add_middleware( CORSMiddleware, - allow_origins=["http://localhost:5173"], + allow_origins=["https://api.numerum.team", "https://numerum.team", "http://localhost:5173"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"], diff --git a/API/k8s/helm/teamfolio-api/templates/deployment.yaml b/API/k8s/helm/teamfolio-api/templates/deployment.yaml index 9778621..381a9b1 100644 --- a/API/k8s/helm/teamfolio-api/templates/deployment.yaml +++ b/API/k8s/helm/teamfolio-api/templates/deployment.yaml @@ -24,6 +24,11 @@ spec: secretKeyRef: name: teamfolio-api-secret key: SECRET_KEY + - name: DATABASE_URL + valueFrom: + secretKeyRef: + name: teamfolio-api-secret + key: DATABASE_URL volumeMounts: - name: uploads-volume mountPath: {{ .Values.persistence.uploads.containerPath }} diff --git a/WEB/.dockerignore b/WEB/.dockerignore new file mode 100644 index 0000000..593eedb --- /dev/null +++ b/WEB/.dockerignore @@ -0,0 +1,7 @@ +node_modules +npm-debug.log +build +.dockerignore +.git +k8s +.env \ No newline at end of file diff --git a/WEB/.gitignore b/WEB/.gitignore index 7211af5..f088a92 100644 --- a/WEB/.gitignore +++ b/WEB/.gitignore @@ -23,3 +23,5 @@ dist-ssr *.sln *.sw? */.vscode/* + +.env diff --git a/WEB/Dockerfile b/WEB/Dockerfile new file mode 100644 index 0000000..da3a794 --- /dev/null +++ b/WEB/Dockerfile @@ -0,0 +1,25 @@ +FROM node:20-alpine AS builder + +WORKDIR /app + +COPY package.json package-lock.json ./ + +RUN npm install + +COPY . . + +ARG VITE_BASE_URL +ENV VITE_BASE_URL=https://api.numerum.team +RUN npm run build + +FROM node:20-alpine + +WORKDIR /app + +RUN npm install -g serve + +COPY --from=builder /app/dist /app + +EXPOSE 3000 + +CMD ["serve", "-s", ".", "-l", "3000"] \ No newline at end of file diff --git a/WEB/k8s/helm/teamfolio-web/Chart.yaml b/WEB/k8s/helm/teamfolio-web/Chart.yaml new file mode 100644 index 0000000..81bc2f7 --- /dev/null +++ b/WEB/k8s/helm/teamfolio-web/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v2 +name: teamfolio-web-app +description: teamfolio WEB project +version: 0.1.0 +appVersion: "1.0" \ No newline at end of file diff --git a/WEB/k8s/helm/teamfolio-web/templates/deployment.yaml b/WEB/k8s/helm/teamfolio-web/templates/deployment.yaml new file mode 100644 index 0000000..3f5bd9c --- /dev/null +++ b/WEB/k8s/helm/teamfolio-web/templates/deployment.yaml @@ -0,0 +1,22 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Chart.Name }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ .Chart.Name }} + template: + metadata: + labels: + app: {{ .Chart.Name }} + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - containerPort: {{ .Values.service.port }} + resources: + {{- toYaml .Values.resources | nindent 12 }} \ No newline at end of file diff --git a/WEB/k8s/helm/teamfolio-web/templates/ingress.yaml b/WEB/k8s/helm/teamfolio-web/templates/ingress.yaml new file mode 100644 index 0000000..da2c7ec --- /dev/null +++ b/WEB/k8s/helm/teamfolio-web/templates/ingress.yaml @@ -0,0 +1,23 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: visus-api-ingress + annotations: + cert-manager.io/cluster-issuer: lets-encrypt +spec: + tls: + - hosts: + - {{ .Values.ingress.domain }} + secretName: {{ .Values.ingress.secretTLSName }} + ingressClassName: public + rules: + - host: {{ .Values.ingress.domain }} + http: + paths: + - path: {{ .Values.ingress.path }} + pathType: {{ .Values.ingress.pathType }} + backend: + service: + name: {{ .Chart.Name }}-service + port: + number: {{ .Values.service.port }} diff --git a/WEB/k8s/helm/teamfolio-web/templates/service.yaml b/WEB/k8s/helm/teamfolio-web/templates/service.yaml new file mode 100644 index 0000000..67b1eb9 --- /dev/null +++ b/WEB/k8s/helm/teamfolio-web/templates/service.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Chart.Name }}-service +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: {{ .Values.service.port }} + selector: + app: {{ .Chart.Name }} \ No newline at end of file diff --git a/WEB/k8s/helm/teamfolio-web/values.yaml b/WEB/k8s/helm/teamfolio-web/values.yaml new file mode 100644 index 0000000..89944d8 --- /dev/null +++ b/WEB/k8s/helm/teamfolio-web/values.yaml @@ -0,0 +1,23 @@ +replicaCount: 1 + +image: + repository: archi341/teamfolio-web + tag: latest + pullPolicy: Always + +service: + type: ClusterIP + port: 3000 + +resources: + limits: + memory: 512Mi + cpu: 500m + +ingress: + secretTLSName: teamfolio-web-tls-secret + + domain: numerum.team + + path: / + pathType: Prefix diff --git a/WEB/src/core/config.js b/WEB/src/core/config.js index fb32220..965cb9f 100644 --- a/WEB/src/core/config.js +++ b/WEB/src/core/config.js @@ -1,5 +1,5 @@ const CONFIG = { - BASE_URL: "http://127.0.0.1:8000", + BASE_URL: import.meta.env.VITE_BASE_URL || "http://127.0.0.1:8000", }; export default CONFIG;