Compare commits
26 Commits
b2bff53beb
...
59529519e3
| Author | SHA1 | Date | |
|---|---|---|---|
| 59529519e3 | |||
| 2ca6a1ec42 | |||
| 1e3b9faa8b | |||
| f3e31106d0 | |||
| 700a446e77 | |||
| 204bcff75c | |||
| 35b76b70c9 | |||
| 05480cac6b | |||
| 5c103c4880 | |||
| 8a174fbed1 | |||
| 70b48d1892 | |||
| 9d4607c7cd | |||
| 695577d53a | |||
| 4ca1fb5ac9 | |||
| e4d7bc1a3a | |||
| 71915f415f | |||
| efc87cdbaf | |||
| eb21556797 | |||
| b9a03cb167 | |||
| 4745e2b060 | |||
| d7ea4e52cc | |||
| e233f0d8bc | |||
| 41944f0828 | |||
| da16cf0f04 | |||
| c8a78aff5d | |||
| 97f5d8bad1 |
78
.gitea/workflows/deploy.yml
Normal file
78
.gitea/workflows/deploy.yml
Normal file
@@ -0,0 +1,78 @@
|
||||
name: Deploy to K3s
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
container:
|
||||
image: localhost:5000/tiny-ci-runner:latest
|
||||
|
||||
env:
|
||||
IMAGE_TAG: ${{ github.sha }}
|
||||
KUBECONFIG: /tmp/.kube/config
|
||||
|
||||
steps:
|
||||
- name: Write kubeconfig
|
||||
run: |
|
||||
mkdir -p /tmp/.kube
|
||||
cat << 'EOF' > /tmp/.kube/config
|
||||
${{ secrets.KUBECONFIG_DATA }}
|
||||
EOF
|
||||
chmod 600 /tmp/.kube/config
|
||||
|
||||
- name: Verify Kubernetes access
|
||||
run: |
|
||||
kubectl cluster-info
|
||||
kubectl get nodes
|
||||
|
||||
- name: Checkout code
|
||||
run: |
|
||||
git clone --depth=1 --branch master \
|
||||
https://git.tonesc.cn/tone/tonePage.git \
|
||||
/workspace/tone/tonePage
|
||||
cd /workspace/tone/tonePage
|
||||
git log -1 --oneline
|
||||
|
||||
- name: Build and push backend image
|
||||
run: |
|
||||
cd /workspace/tone/tonePage/apps/backend
|
||||
docker build -t localhost:5000/backend:${IMAGE_TAG} .
|
||||
docker push localhost:5000/backend:${IMAGE_TAG}
|
||||
|
||||
- name: Build and push frontend image
|
||||
run: |
|
||||
cd /workspace/tone/tonePage/apps/frontend
|
||||
docker build \
|
||||
--build-arg API_BASE="http://backend-service:3001" \
|
||||
-t localhost:5000/frontend:${IMAGE_TAG} .
|
||||
docker push localhost:5000/frontend:${IMAGE_TAG}
|
||||
|
||||
- name: Deploy to K3s
|
||||
run: |
|
||||
cd /workspace/tone/tonePage/apps/deploy
|
||||
|
||||
# 基础资源
|
||||
kubectl apply -f postgres-deployment.yaml
|
||||
kubectl apply -f backend-deployment.yaml
|
||||
kubectl apply -f frontend-deployment.yaml
|
||||
|
||||
# 更新镜像(触发滚动更新)
|
||||
kubectl set image deployment/backend \
|
||||
backend=localhost:5000/backend:${IMAGE_TAG}
|
||||
|
||||
kubectl set image deployment/frontend \
|
||||
frontend=localhost:5000/frontend:${IMAGE_TAG}
|
||||
|
||||
# 等待滚动完成
|
||||
kubectl rollout status deployment/backend --timeout=120s
|
||||
kubectl rollout status deployment/frontend --timeout=120s
|
||||
|
||||
- name: Post-deploy sanity check
|
||||
run: |
|
||||
kubectl get pods
|
||||
kubectl get svc
|
||||
77
apps/deploy/backend-deployment.yaml
Normal file
77
apps/deploy/backend-deployment.yaml
Normal file
@@ -0,0 +1,77 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: backend
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: backend
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: backend
|
||||
spec:
|
||||
containers:
|
||||
- name: backend
|
||||
image: localhost:5000/backend:latest
|
||||
ports:
|
||||
- containerPort: 3001
|
||||
env:
|
||||
- name: DATABASE_HOST
|
||||
value: "postgres-service"
|
||||
- name: DATABASE_PORT
|
||||
value: "5432"
|
||||
- name: DATABASE_NAME
|
||||
value: "tone_page"
|
||||
- name: DATABASE_USERNAME
|
||||
value: "tone_page"
|
||||
- name: DATABASE_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: backend-secret
|
||||
key: DATABASE_PASSWORD
|
||||
- name: ALIYUN_ACCESS_KEY_ID
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: backend-secret
|
||||
key: ALIYUN_ACCESS_KEY_ID
|
||||
- name: ALIYUN_ACCESS_KEY_SECRET
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: backend-secret
|
||||
key: ALIYUN_ACCESS_KEY_SECRET
|
||||
- name: ALIYUN_OSS_STS_ROLE_ARN
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: backend-secret
|
||||
key: ALIYUN_OSS_STS_ROLE_ARN
|
||||
- name: WEBAUTHN_RP_ID
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: backend-secret
|
||||
key: WEBAUTHN_RP_ID
|
||||
- name: WEBAUTHN_ORIGIN
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: backend-secret
|
||||
key: WEBAUTHN_ORIGIN
|
||||
- name: WEBAUTHN_RP_NAME
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: backend-secret
|
||||
key: WEBAUTHN_RP_NAME
|
||||
- name: NODE_ENV
|
||||
value: "production"
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: backend-service
|
||||
spec:
|
||||
selector:
|
||||
app: backend
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 3001
|
||||
targetPort: 3001
|
||||
13
apps/deploy/backend-secret.yaml
Normal file
13
apps/deploy/backend-secret.yaml
Normal file
@@ -0,0 +1,13 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: backend-secret
|
||||
type: Opaque
|
||||
# stringData:
|
||||
# DATABASE_PASSWORD:
|
||||
# ALIYUN_ACCESS_KEY_ID:
|
||||
# ALIYUN_ACCESS_KEY_SECRET:
|
||||
# ALIYUN_OSS_STS_ROLE_ARN:
|
||||
# WEBAUTHN_RP_ID:
|
||||
# WEBAUTHN_ORIGIN:
|
||||
# WEBAUTHN_RP_NAME:
|
||||
32
apps/deploy/frontend-deployment.yaml
Normal file
32
apps/deploy/frontend-deployment.yaml
Normal file
@@ -0,0 +1,32 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: frontend
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: frontend
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: frontend
|
||||
spec:
|
||||
containers:
|
||||
- name: frontend
|
||||
image: localhost:5000/frontend:latest
|
||||
ports:
|
||||
- containerPort: 3000
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: frontend-service
|
||||
spec:
|
||||
type: NodePort
|
||||
ports:
|
||||
- port: 3000
|
||||
targetPort: 3000
|
||||
nodePort: 30000
|
||||
selector:
|
||||
app: frontend
|
||||
42
apps/deploy/postgres-deployment.yaml
Normal file
42
apps/deploy/postgres-deployment.yaml
Normal file
@@ -0,0 +1,42 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: postgres
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: postgres
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: postgres
|
||||
spec:
|
||||
containers:
|
||||
- name: postgres
|
||||
image: postgres:17-alpine
|
||||
ports:
|
||||
- containerPort: 5432
|
||||
envFrom:
|
||||
- secretRef:
|
||||
name: postgres-secret
|
||||
volumeMounts:
|
||||
- name: postgres-storage
|
||||
mountPath: /var/lib/postgresql/data
|
||||
volumes:
|
||||
- name: postgres-storage
|
||||
hostPath:
|
||||
path: /var/lib/postgres-data
|
||||
type: DirectoryOrCreate
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: postgres-service
|
||||
spec:
|
||||
selector:
|
||||
app: postgres
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 5432
|
||||
targetPort: 5432
|
||||
12
apps/deploy/postgres-nodeport.yaml
Normal file
12
apps/deploy/postgres-nodeport.yaml
Normal file
@@ -0,0 +1,12 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: postgres-nodeport
|
||||
spec:
|
||||
type: NodePort
|
||||
ports:
|
||||
- port: 5432
|
||||
targetPort: 5432
|
||||
nodePort: 30001
|
||||
selector:
|
||||
app: postgres
|
||||
9
apps/deploy/postgres-secret.yaml
Normal file
9
apps/deploy/postgres-secret.yaml
Normal file
@@ -0,0 +1,9 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: postgres-secret
|
||||
type: Opaque
|
||||
# stringData:
|
||||
# POSTGRES_USER:
|
||||
# POSTGRES_PASSWORD:
|
||||
# POSTGRES_DB:
|
||||
@@ -21,6 +21,7 @@ COPY --from=builder /app/.next ./.next
|
||||
COPY --from=builder /app/public ./public
|
||||
COPY --from=builder /app/next.config.ts ./
|
||||
|
||||
ARG API_BASE
|
||||
ENV API_BASE=$API_BASE
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import favicon from '../favicon.ico';
|
||||
import Image from 'next/image';
|
||||
|
||||
export default function Home() {
|
||||
return (
|
||||
<div className="w-full flex-1 flex flex-col items-center justify-center">
|
||||
<Image
|
||||
src={favicon.src}
|
||||
src="/avatar.png"
|
||||
alt="TONE's avatar"
|
||||
width={180}
|
||||
height={180}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.6 MiB |
@@ -27,6 +27,7 @@ export default async function RootLayout({
|
||||
|
||||
return (
|
||||
<html lang="en" suppressHydrationWarning>
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<body
|
||||
className={`${geistSans.variable} ${geistMono.variable} antialiased min-h-screen flex flex-col`}
|
||||
suppressHydrationWarning
|
||||
|
||||
BIN
apps/frontend/public/avatar.png
Normal file
BIN
apps/frontend/public/avatar.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 418 KiB |
BIN
apps/frontend/public/favicon.ico
Normal file
BIN
apps/frontend/public/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 126 KiB |
Reference in New Issue
Block a user