fix: use nginx for app
This commit is contained in:
@@ -18,12 +18,15 @@ spec:
|
|||||||
app.kubernetes.io/component: miniapp
|
app.kubernetes.io/component: miniapp
|
||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: miniapp
|
- name: nginx
|
||||||
image: "{{ .Values.miniapp.image.registry }}/{{ .Values.miniapp.image.repository }}:{{ .Values.miniapp.image.tag | default .Chart.Version }}"
|
image: "{{ .Values.miniapp.nginx.image.registry }}/{{ .Values.miniapp.nginx.image.repository }}:{{ .Values.miniapp.nginx.image.tag }}"
|
||||||
imagePullPolicy: {{ .Values.miniapp.image.pullPolicy }}
|
imagePullPolicy: {{ .Values.miniapp.nginx.image.pullPolicy }}
|
||||||
ports:
|
ports:
|
||||||
- name: http
|
- name: http
|
||||||
containerPort: 80
|
containerPort: 80
|
||||||
|
volumeMounts:
|
||||||
|
- name: webroot
|
||||||
|
mountPath: /usr/share/nginx/html
|
||||||
resources:
|
resources:
|
||||||
{{- toYaml .Values.miniapp.resources | nindent 12 }}
|
{{- toYaml .Values.miniapp.resources | nindent 12 }}
|
||||||
readinessProbe:
|
readinessProbe:
|
||||||
@@ -38,3 +41,8 @@ spec:
|
|||||||
port: 80
|
port: 80
|
||||||
initialDelaySeconds: 5
|
initialDelaySeconds: 5
|
||||||
periodSeconds: 20
|
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 }}
|
||||||
|
|||||||
@@ -1,37 +1,39 @@
|
|||||||
apiVersion: networking.k8s.io/v1
|
apiVersion: traefik.io/v1alpha1
|
||||||
kind: Ingress
|
kind: IngressRoute
|
||||||
metadata:
|
metadata:
|
||||||
name: {{ include "memevault.fullname" . }}
|
name: {{ include "memevault.fullname" . }}
|
||||||
labels:
|
labels:
|
||||||
{{- include "memevault.labels" . | nindent 4 }}
|
{{- include "memevault.labels" . | nindent 4 }}
|
||||||
{{- with .Values.ingress.annotations }}
|
|
||||||
annotations:
|
|
||||||
{{- toYaml . | nindent 4 }}
|
|
||||||
{{- end }}
|
|
||||||
spec:
|
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 }}
|
{{- if .Values.ingress.tls.enabled }}
|
||||||
tls:
|
tls:
|
||||||
- hosts:
|
{{- if .Values.ingress.tls.certResolver }}
|
||||||
- {{ .Values.ingress.host }}
|
# ACME-резолвер (Let's Encrypt и т.п.) — Traefik сам получает сертификат.
|
||||||
secretName: {{ .Values.ingress.tls.secretName }}
|
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 }}
|
||||||
{{- end }}
|
{{- 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
|
|
||||||
|
|||||||
@@ -5,13 +5,21 @@ image:
|
|||||||
tag: "" # по умолчанию — версия чарта (.Chart.Version)
|
tag: "" # по умолчанию — версия чарта (.Chart.Version)
|
||||||
pullPolicy: IfNotPresent
|
pullPolicy: IfNotPresent
|
||||||
|
|
||||||
# Образ miniapp (nginx + статика)
|
# Образ miniapp
|
||||||
miniapp:
|
miniapp:
|
||||||
|
# Образ со статикой (assets-only, FROM scratch) — монтируется как Image Volume (k8s ≥ 1.31)
|
||||||
image:
|
image:
|
||||||
registry: code.kruzya.dev
|
registry: code.kruzya.dev
|
||||||
repository: crazyhackgut/telegrammemevault/frontend
|
repository: crazyhackgut/telegrammemevault/frontend-static
|
||||||
tag: "" # по умолчанию — версия чарта (.Chart.Version)
|
tag: "" # по умолчанию — версия чарта (.Chart.Version)
|
||||||
pullPolicy: IfNotPresent
|
pullPolicy: IfNotPresent
|
||||||
|
# Стандартный nginx для раздачи статики
|
||||||
|
nginx:
|
||||||
|
image:
|
||||||
|
registry: docker.io
|
||||||
|
repository: library/nginx
|
||||||
|
tag: "1.27-alpine"
|
||||||
|
pullPolicy: IfNotPresent
|
||||||
replicaCount: 1
|
replicaCount: 1
|
||||||
resources:
|
resources:
|
||||||
requests:
|
requests:
|
||||||
@@ -43,9 +51,21 @@ bot:
|
|||||||
|
|
||||||
ingress:
|
ingress:
|
||||||
host: example.com
|
host: example.com
|
||||||
annotations: {}
|
entryPoints:
|
||||||
|
- websecure
|
||||||
tls:
|
tls:
|
||||||
enabled: false
|
enabled: true
|
||||||
|
# Ровно один из вариантов (остальные оставить пустыми):
|
||||||
|
#
|
||||||
|
# 1. ACME-резолвер — Traefik сам получает сертификат:
|
||||||
|
certResolver: ""
|
||||||
|
#
|
||||||
|
# 2. TLSStore из другого неймспейса (требует allowCrossNamespace=true в Traefik):
|
||||||
|
store:
|
||||||
|
name: ""
|
||||||
|
namespace: ""
|
||||||
|
#
|
||||||
|
# 3. Секрет в том же неймспейсе (cert-manager и т.п.):
|
||||||
secretName: ""
|
secretName: ""
|
||||||
|
|
||||||
s3:
|
s3:
|
||||||
|
|||||||
@@ -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 /
|
||||||
Reference in New Issue
Block a user