优化
This commit is contained in:
20
docker/admin.yml
Normal file
20
docker/admin.yml
Normal file
@@ -0,0 +1,20 @@
|
||||
version: "3.3"
|
||||
|
||||
services:
|
||||
# 后台应用
|
||||
tailchat-admin:
|
||||
build:
|
||||
context: ../
|
||||
image: tailchat
|
||||
restart: unless-stopped
|
||||
env_file: docker-compose.env
|
||||
depends_on:
|
||||
- mongo
|
||||
- redis
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
- "traefik.http.routers.admin.rule=PathPrefix(`/admin`)"
|
||||
- "traefik.http.services.admin.loadbalancer.server.port=3000"
|
||||
networks:
|
||||
- internal
|
||||
command: pnpm start:admin
|
||||
44
docker/config/nginx.conf
Normal file
44
docker/config/nginx.conf
Normal file
@@ -0,0 +1,44 @@
|
||||
map $http_upgrade $connection_upgrade {
|
||||
default upgrade;
|
||||
'' close;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80 default_server;
|
||||
listen [::]:80 default_server;
|
||||
server_name _;
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl http2 default_server;
|
||||
listen [::]:443 ssl http2 default_server;
|
||||
|
||||
# enable subfolder method reverse proxy confs
|
||||
include /config/nginx/proxy-confs/*.subfolder.conf;
|
||||
|
||||
# all ssl related config moved to ssl.conf
|
||||
include /config/nginx/ssl.conf;
|
||||
|
||||
# server
|
||||
location ~ ^/(socket\.io) {
|
||||
proxy_pass http://127.0.0.1:11000;
|
||||
#
|
||||
proxy_http_version 1.1;
|
||||
proxy_redirect off;
|
||||
proxy_request_buffering off;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $connection_upgrade;
|
||||
proxy_read_timeout 86400;
|
||||
proxy_set_header Referer $http_referer;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_max_temp_file_size 2048m;
|
||||
}
|
||||
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:11000;
|
||||
}
|
||||
}
|
||||
22
docker/livekit.yml
Normal file
22
docker/livekit.yml
Normal file
@@ -0,0 +1,22 @@
|
||||
version: "3.3"
|
||||
|
||||
services:
|
||||
# livekit webhook receiver
|
||||
tailchat-livekit-webhook-receiver:
|
||||
build:
|
||||
context: ../
|
||||
image: tailchat
|
||||
restart: unless-stopped
|
||||
env_file: docker-compose.env
|
||||
environment:
|
||||
LIVEKIT_WEBHOOK_PORT: 3000
|
||||
depends_on:
|
||||
- mongo
|
||||
- redis
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
- "traefik.http.routers.livekit.rule=PathPrefix(`/livekit/webhook`)"
|
||||
- "traefik.http.services.livekit.loadbalancer.server.port=3000"
|
||||
networks:
|
||||
- internal
|
||||
command: node server/dist/plugins/com.msgbyte.livekit/webhook/index.js
|
||||
3
docker/simple/README.md
Normal file
3
docker/simple/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
Only have one tailchat instance version.
|
||||
|
||||
Not include **openapi** and **admin**
|
||||
83
docker/simple/docker-compose.yml
Normal file
83
docker/simple/docker-compose.yml
Normal file
@@ -0,0 +1,83 @@
|
||||
version: "3.3"
|
||||
|
||||
services:
|
||||
tailchat:
|
||||
build:
|
||||
context: ../../
|
||||
image: tailchat
|
||||
restart: unless-stopped
|
||||
env_file: ../../docker-compose.env
|
||||
environment:
|
||||
SERVICEDIR: services,plugins
|
||||
PORT: 3000
|
||||
depends_on:
|
||||
- mongo
|
||||
- redis
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
- "traefik.http.routers.api-gw.rule=PathPrefix(`/`)"
|
||||
- "traefik.http.services.api-gw.loadbalancer.server.port=3000"
|
||||
healthcheck:
|
||||
test: [ "CMD", "wget", "localhost:3000/health", "-q", "-O", "-" ]
|
||||
interval: 30s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
start_period: 15s
|
||||
networks:
|
||||
- internal
|
||||
|
||||
# Database
|
||||
mongo:
|
||||
image: mongo:4
|
||||
restart: on-failure
|
||||
volumes:
|
||||
- data:/data/db
|
||||
networks:
|
||||
- internal
|
||||
|
||||
# Data cache and Transporter
|
||||
redis:
|
||||
image: redis:alpine
|
||||
restart: on-failure
|
||||
networks:
|
||||
- internal
|
||||
|
||||
# Persist Storage
|
||||
minio:
|
||||
image: minio/minio
|
||||
restart: on-failure
|
||||
networks:
|
||||
- internal
|
||||
environment:
|
||||
MINIO_ROOT_USER: tailchat
|
||||
MINIO_ROOT_PASSWORD: com.msgbyte.tailchat
|
||||
volumes:
|
||||
- storage:/data
|
||||
command: minio server /data --console-address ":9001"
|
||||
|
||||
# Router
|
||||
traefik:
|
||||
image: traefik:v2.1
|
||||
restart: unless-stopped
|
||||
command:
|
||||
- "--api.insecure=true" # Don't do that in production!
|
||||
- "--providers.docker=true"
|
||||
- "--providers.docker.exposedbydefault=false"
|
||||
- "--entryPoints.web.address=:80"
|
||||
- "--entryPoints.web.forwardedHeaders.insecure" # Not good
|
||||
ports:
|
||||
- 11000:80
|
||||
- 127.0.0.1:11001:8080
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
networks:
|
||||
- internal
|
||||
- default
|
||||
|
||||
networks:
|
||||
internal:
|
||||
name: tailchat-internal
|
||||
|
||||
volumes:
|
||||
data:
|
||||
storage:
|
||||
112
docker/simple/k8s/README.md
Normal file
112
docker/simple/k8s/README.md
Normal file
@@ -0,0 +1,112 @@
|
||||
Its doc will tell you how to deploy `Tailchat` in kubeneters.
|
||||
|
||||
## One Command
|
||||
|
||||
```bash
|
||||
kubectl apply -f namespace.yml -f pv.yml -f mongo.yml -f minio.yml -f redis.yml -f tailchat.yml
|
||||
```
|
||||
|
||||
### Delete
|
||||
|
||||
if you wanna delete all resource, just delete namespace.
|
||||
|
||||
```bash
|
||||
kubectl delete -f namespace.yml
|
||||
```
|
||||
|
||||
## Setup one by one
|
||||
|
||||
### Create Namespace
|
||||
|
||||
```bash
|
||||
kubectl apply -f namespace.yml
|
||||
```
|
||||
|
||||
### Create Persistent Volume
|
||||
|
||||
```bash
|
||||
kubectl apply -f pv.yml
|
||||
```
|
||||
|
||||
### Create Mongodb
|
||||
|
||||
```bash
|
||||
kubectl apply -f mongo.yml
|
||||
```
|
||||
|
||||
### Create Minio
|
||||
|
||||
```bash
|
||||
kubectl apply -f minio.yml
|
||||
```
|
||||
|
||||
### Create Redis
|
||||
|
||||
```bash
|
||||
kubectl apply -f redis.yml
|
||||
```
|
||||
|
||||
### Create Tailchat
|
||||
|
||||
```bash
|
||||
kubectl apply -f tailchat.yml
|
||||
```
|
||||
|
||||
## Check tailchat-service work
|
||||
|
||||
#### get services ClusterIP
|
||||
```bash
|
||||
kubectl get svc -n tailchat
|
||||
```
|
||||
|
||||
#### create test container in kubernetes
|
||||
|
||||
```bash
|
||||
kubectl run -it --rm test-pod --image=busybox --restart=Never
|
||||
```
|
||||
|
||||
#### request health and checkout `nodeID`, send multi times.
|
||||
```
|
||||
wget -q -O - http://<tailchat-cluster-ip>:11000/health
|
||||
```
|
||||
|
||||
## Router and Load Balance
|
||||
|
||||
For example, we use traefik.
|
||||
|
||||
### Install Traefik provider
|
||||
|
||||
```bash
|
||||
helm repo add traefik https://helm.traefik.io/traefik
|
||||
helm install traefik traefik/traefik -n tailchat
|
||||
```
|
||||
|
||||
### Apply Ingress Config
|
||||
|
||||
```bash
|
||||
kubectl apply -f ingress.yml
|
||||
```
|
||||
|
||||
### Check Status
|
||||
|
||||
```bash
|
||||
kubectl get services -n tailchat
|
||||
```
|
||||
|
||||
If every is ok, its should be like this:
|
||||
|
||||

|
||||
|
||||
### Set DNS record
|
||||
|
||||
```bash
|
||||
sudo vim /etc/hosts
|
||||
```
|
||||
|
||||
append this record:
|
||||
|
||||
```
|
||||
127.0.0.1 tailchat.internal.com
|
||||
```
|
||||
|
||||
Now you can open browser and view `http://tailchat.internal.com` to open tailchat in k8s.
|
||||
BIN
docker/simple/k8s/images/traefik-svc.png
Normal file
BIN
docker/simple/k8s/images/traefik-svc.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 62 KiB |
19
docker/simple/k8s/ingress.yml
Normal file
19
docker/simple/k8s/ingress.yml
Normal file
@@ -0,0 +1,19 @@
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: ingress
|
||||
namespace: tailchat
|
||||
annotations:
|
||||
traefik.ingress.kubernetes.io/routing-type: edge
|
||||
spec:
|
||||
rules:
|
||||
- host: tailchat.internal.com
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: tailchat-service
|
||||
port:
|
||||
number: 11000
|
||||
55
docker/simple/k8s/minio.yml
Normal file
55
docker/simple/k8s/minio.yml
Normal file
@@ -0,0 +1,55 @@
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: minio
|
||||
namespace: tailchat
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: minio
|
||||
serviceName: minio
|
||||
replicas: 1
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: minio
|
||||
spec:
|
||||
containers:
|
||||
- name: minio
|
||||
image: minio/minio
|
||||
imagePullPolicy: IfNotPresent
|
||||
env:
|
||||
- name: MINIO_ROOT_USER
|
||||
value: tailchat
|
||||
- name: MINIO_ROOT_PASSWORD
|
||||
value: com.msgbyte.tailchat
|
||||
command:
|
||||
- minio
|
||||
- server
|
||||
- /data/storage
|
||||
- '--console-address'
|
||||
- ':9001'
|
||||
ports:
|
||||
- containerPort: 9000
|
||||
- containerPort: 9001
|
||||
volumeMounts:
|
||||
- name: minio-persistent-storage
|
||||
mountPath: /data/tailchat/storage
|
||||
volumes:
|
||||
- name: minio-persistent-storage
|
||||
persistentVolumeClaim:
|
||||
claimName: minio-pvc
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: minio-service
|
||||
namespace: tailchat
|
||||
spec:
|
||||
type: ClusterIP
|
||||
selector:
|
||||
app: minio
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 9000
|
||||
targetPort: 9000
|
||||
43
docker/simple/k8s/mongo.yml
Normal file
43
docker/simple/k8s/mongo.yml
Normal file
@@ -0,0 +1,43 @@
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: mongo
|
||||
namespace: tailchat
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: mongo
|
||||
serviceName: mongo
|
||||
replicas: 1
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: mongo
|
||||
spec:
|
||||
containers:
|
||||
- name: mongo
|
||||
image: mongo:4
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- containerPort: 27017
|
||||
volumeMounts:
|
||||
- name: mongo-persistent-storage
|
||||
mountPath: /data/tailchat/db
|
||||
volumes:
|
||||
- name: mongo-persistent-storage
|
||||
persistentVolumeClaim:
|
||||
claimName: mongo-pvc
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: mongo-service
|
||||
namespace: tailchat
|
||||
spec:
|
||||
type: ClusterIP
|
||||
selector:
|
||||
app: mongo
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 27017
|
||||
targetPort: 27017
|
||||
4
docker/simple/k8s/namespace.yml
Normal file
4
docker/simple/k8s/namespace.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: tailchat
|
||||
51
docker/simple/k8s/pv.yml
Normal file
51
docker/simple/k8s/pv.yml
Normal file
@@ -0,0 +1,51 @@
|
||||
apiVersion: v1
|
||||
kind: PersistentVolume
|
||||
metadata:
|
||||
name: mongo-pv
|
||||
spec:
|
||||
storageClassName: tailchat-db
|
||||
capacity:
|
||||
storage: 5Gi
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
hostPath:
|
||||
path: /data/tailchat/db
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: mongo-pvc
|
||||
namespace: tailchat
|
||||
spec:
|
||||
storageClassName: tailchat-db
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 5Gi
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolume
|
||||
metadata:
|
||||
name: minio-pv
|
||||
spec:
|
||||
storageClassName: tailchat-storage
|
||||
capacity:
|
||||
storage: 5Gi
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
hostPath:
|
||||
path: /data/tailchat/storage
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: minio-pvc
|
||||
namespace: tailchat
|
||||
spec:
|
||||
storageClassName: tailchat-storage
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 5Gi
|
||||
36
docker/simple/k8s/redis.yml
Normal file
36
docker/simple/k8s/redis.yml
Normal file
@@ -0,0 +1,36 @@
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: redis
|
||||
namespace: tailchat
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: redis
|
||||
serviceName: redis
|
||||
replicas: 1
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: redis
|
||||
spec:
|
||||
containers:
|
||||
- name: redis
|
||||
image: redis:alpine
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- containerPort: 6379
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: redis-service
|
||||
namespace: tailchat
|
||||
spec:
|
||||
type: ClusterIP
|
||||
selector:
|
||||
app: redis
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 6379
|
||||
targetPort: 6379
|
||||
76
docker/simple/k8s/tailchat.yml
Normal file
76
docker/simple/k8s/tailchat.yml
Normal file
@@ -0,0 +1,76 @@
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: tailchat
|
||||
namespace: tailchat
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: tailchat
|
||||
serviceName: tailchat
|
||||
replicas: 3
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: tailchat
|
||||
spec:
|
||||
containers:
|
||||
- name: tailchat
|
||||
image: moonrailgun/tailchat
|
||||
# imagePullPolicy: Always
|
||||
env:
|
||||
- name: SERVICEDIR
|
||||
value: services,plugins
|
||||
- name: TRANSPORTER
|
||||
value: redis://redis-service:6379
|
||||
- name: REDIS_URL
|
||||
value: redis://redis-service:6379
|
||||
- name: MONGO_URL
|
||||
value: mongodb://mongo-service/tailchat
|
||||
- name: SECRET
|
||||
value: any-secret-keywords
|
||||
- name: MINIO_URL
|
||||
value: minio-service:9000
|
||||
- name: MINIO_USER
|
||||
value: tailchat
|
||||
- name: MINIO_PASS
|
||||
value: com.msgbyte.tailchat
|
||||
ports:
|
||||
- containerPort: 11000
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: 11000
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 30
|
||||
timeoutSeconds: 2
|
||||
failureThreshold: 3
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: 11000
|
||||
initialDelaySeconds: 10
|
||||
periodSeconds: 30
|
||||
timeoutSeconds: 2
|
||||
failureThreshold: 3
|
||||
resources:
|
||||
requests:
|
||||
cpu: 50m
|
||||
memory: 51Mi
|
||||
limits:
|
||||
cpu: 500m
|
||||
memory: 256Mi
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: tailchat-service
|
||||
namespace: tailchat
|
||||
spec:
|
||||
type: ClusterIP
|
||||
selector:
|
||||
app: tailchat
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 11000
|
||||
targetPort: 11000
|
||||
3
docker/swag.env.example
Normal file
3
docker/swag.env.example
Normal file
@@ -0,0 +1,3 @@
|
||||
URL=
|
||||
|
||||
TZ=Asia/Shanghai
|
||||
18
docker/swag.yml
Normal file
18
docker/swag.yml
Normal file
@@ -0,0 +1,18 @@
|
||||
version: "3.3"
|
||||
|
||||
services:
|
||||
swag:
|
||||
image: lscr.io/linuxserver/swag:latest
|
||||
container_name: swag
|
||||
cap_add:
|
||||
- NET_ADMIN
|
||||
env_file:
|
||||
- swag.env
|
||||
environment:
|
||||
- PUID=1000
|
||||
- PGID=1000
|
||||
- VALIDATION=http
|
||||
volumes:
|
||||
- ./config/nginx.conf:/config/nginx/site-confs/default.conf:ro
|
||||
restart: unless-stopped
|
||||
network_mode: "host"
|
||||
Reference in New Issue
Block a user