fix: use nginx for app

This commit is contained in:
2026-10-10 21:52:16 +04:00
parent b21e7eaaee
commit 031d3707c2
4 changed files with 83 additions and 36 deletions
@@ -18,12 +18,15 @@ spec:
app.kubernetes.io/component: miniapp
spec:
containers:
- name: miniapp
image: "{{ .Values.miniapp.image.registry }}/{{ .Values.miniapp.image.repository }}:{{ .Values.miniapp.image.tag | default .Chart.Version }}"
imagePullPolicy: {{ .Values.miniapp.image.pullPolicy }}
- name: nginx
image: "{{ .Values.miniapp.nginx.image.registry }}/{{ .Values.miniapp.nginx.image.repository }}:{{ .Values.miniapp.nginx.image.tag }}"
imagePullPolicy: {{ .Values.miniapp.nginx.image.pullPolicy }}
ports:
- name: http
containerPort: 80
volumeMounts:
- name: webroot
mountPath: /usr/share/nginx/html
resources:
{{- toYaml .Values.miniapp.resources | nindent 12 }}
readinessProbe:
@@ -38,3 +41,8 @@ spec:
port: 80
initialDelaySeconds: 5
periodSeconds: 20
volumes:
- name: webroot
image:
reference: "{{ .Values.miniapp.image.registry }}/{{ .Values.miniapp.image.repository }}:{{ .Values.miniapp.image.tag | default .Chart.Version }}"
pullPolicy: {{ .Values.miniapp.image.pullPolicy }}
+30 -28
View File
@@ -1,37 +1,39 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
name: {{ include "memevault.fullname" . }}
labels:
{{- include "memevault.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
entryPoints:
{{- toYaml .Values.ingress.entryPoints | nindent 4 }}
routes:
# API-запросы идут напрямую в api-сервис.
- match: Host(`{{ .Values.ingress.host }}`) && PathPrefix(`/api`)
kind: Rule
services:
- name: {{ include "memevault.fullname" . }}-api
port: 8080
# Всё остальное — miniapp (Svelte SPA + nginx).
- match: Host(`{{ .Values.ingress.host }}`)
kind: Rule
services:
- name: {{ include "memevault.fullname" . }}-miniapp
port: 80
{{- if .Values.ingress.tls.enabled }}
tls:
- hosts:
- {{ .Values.ingress.host }}
{{- if .Values.ingress.tls.certResolver }}
# ACME-резолвер (Let's Encrypt и т.п.) — Traefik сам получает сертификат.
certResolver: {{ .Values.ingress.tls.certResolver }}
{{- else if .Values.ingress.tls.store }}
# TLSStore из произвольного неймспейса (требует allowCrossNamespace=true).
store:
name: {{ .Values.ingress.tls.store.name }}
{{- if .Values.ingress.tls.store.namespace }}
namespace: {{ .Values.ingress.tls.store.namespace }}
{{- end }}
{{- else if .Values.ingress.tls.secretName }}
# Секрет в том же неймспейсе.
secretName: {{ .Values.ingress.tls.secretName }}
{{- end }}
rules:
- host: {{ .Values.ingress.host }}
http:
paths:
# API-запросы идут напрямую в api-сервис, минуя miniapp nginx.
- path: /api
pathType: Prefix
backend:
service:
name: {{ include "memevault.fullname" . }}-api
port:
name: http
# Всё остальное — miniapp (Svelte SPA + nginx).
- path: /
pathType: Prefix
backend:
service:
name: {{ include "memevault.fullname" . }}-miniapp
port:
name: http
{{- end }}
+24 -4
View File
@@ -5,13 +5,21 @@ image:
tag: "" # по умолчанию — версия чарта (.Chart.Version)
pullPolicy: IfNotPresent
# Образ miniapp (nginx + статика)
# Образ miniapp
miniapp:
# Образ со статикой (assets-only, FROM scratch) — монтируется как Image Volume (k8s ≥ 1.31)
image:
registry: code.kruzya.dev
repository: crazyhackgut/telegrammemevault/frontend
repository: crazyhackgut/telegrammemevault/frontend-static
tag: "" # по умолчанию — версия чарта (.Chart.Version)
pullPolicy: IfNotPresent
# Стандартный nginx для раздачи статики
nginx:
image:
registry: docker.io
repository: library/nginx
tag: "1.27-alpine"
pullPolicy: IfNotPresent
replicaCount: 1
resources:
requests:
@@ -43,9 +51,21 @@ bot:
ingress:
host: example.com
annotations: {}
entryPoints:
- websecure
tls:
enabled: false
enabled: true
# Ровно один из вариантов (остальные оставить пустыми):
#
# 1. ACME-резолвер — Traefik сам получает сертификат:
certResolver: ""
#
# 2. TLSStore из другого неймспейса (требует allowCrossNamespace=true в Traefik):
store:
name: ""
namespace: ""
#
# 3. Секрет в том же неймспейсе (cert-manager и т.п.):
secretName: ""
s3:
+17
View File
@@ -0,0 +1,17 @@
# syntax=docker/dockerfile:1.7
# Образ содержит только собранные статические файлы в корне (/).
# Используется как Image Volume в Kubernetes (≥ 1.31):
# volumes[].image монтирует содержимое образа напрямую в nginx-контейнер.
FROM node:22-alpine AS build
WORKDIR /app
COPY package*.json ./
RUN --mount=type=cache,target=/root/.npm \
npm ci
COPY . .
RUN npm run build
FROM scratch
COPY --from=build /app/dist /