feat: 当前开发代码

This commit is contained in:
2026-04-11 17:54:35 +08:00
parent b12a84e388
commit f0cc37681c
16 changed files with 176 additions and 1 deletions

31
backend/Dockerfile Normal file
View File

@@ -0,0 +1,31 @@
# 后端 Dockerfile (开发环境)
FROM node:18-alpine
WORKDIR /app
# 复制 package.json 和 package-lock.json
COPY package*.json ./
# 安装所有依赖 (包括开发依赖)
RUN npm ci
# 复制源代码
COPY . .
# 创建非root用户
RUN addgroup -g 1001 -S nodejs && \
adduser -S nodejs -u 1001 && \
chown -R nodejs:nodejs /app
# 切换用户
USER nodejs
# 暴露端口
EXPOSE 3001
# 健康检查
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
CMD node -e "const http = require('http'); http.get('http://localhost:3001/api/health', (res) => { if (res.statusCode !== 200) throw new Error('Health check failed') }).on('error', (err) => { console.error(err); process.exit(1); })"
# 启动开发服务器
CMD ["npm", "run", "dev"]

101
docker-compose.yml Normal file
View File

@@ -0,0 +1,101 @@
version: '3.8'
services:
# MySQL 数据库服务
db:
image: mysql:8.0
container_name: performance-mysql
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: rootpassword
MYSQL_DATABASE: employee_performance
MYSQL_USER: app_user
MYSQL_PASSWORD: app_password
ports:
- "3306:3306"
volumes:
- mysql_data:/var/lib/mysql
- ./backend/src/db/init.sql:/docker-entrypoint-initdb.d/init.sql
networks:
- app-network
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-prootpassword"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
command:
- --default-authentication-plugin=mysql_native_password
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_unicode_ci
# 后端 API 服务
backend:
build:
context: ./backend
dockerfile: Dockerfile
container_name: performance-backend
restart: unless-stopped
depends_on:
db:
condition: service_healthy
environment:
DB_HOST: db
DB_PORT: 3306
DB_USER: app_user
DB_PASSWORD: app_password
DB_NAME: employee_performance
JWT_SECRET: your_jwt_secret_here_change_in_production
FASTGPT_API_KEY: ${FASTGPT_API_KEY:-your_fastgpt_api_key_here}
FASTGPT_API_URL: https://api.fastgpt.in/api/v1/chat/completions
FASTGPT_MODEL: gpt-4
PORT: 3001
NODE_ENV: development
ports:
- "3001:3001"
volumes:
- ./backend:/app
- /app/node_modules
networks:
- app-network
healthcheck:
test: ["CMD", "node", "-e", "const http = require('http'); http.get('http://localhost:3001/api/health', (res) => { if (res.statusCode !== 200) throw new Error('Health check failed') }).on('error', (err) => { console.error(err); process.exit(1); })"]
interval: 30s
timeout: 5s
retries: 3
start_period: 20s
# 前端开发服务
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
container_name: performance-frontend
restart: unless-stopped
depends_on:
- backend
environment:
VITE_API_URL: http://backend:3001
ports:
- "3000:3000"
volumes:
- ./frontend:/app
- /app/node_modules
networks:
- app-network
healthcheck:
test: ["CMD", "node", "-e", "const http = require('http'); http.get('http://localhost:3000', (res) => { if (res.statusCode !== 200) throw new Error('Health check failed') }).on('error', (err) => { console.error(err); process.exit(1); })"]
interval: 30s
timeout: 5s
retries: 3
start_period: 30s
# 定义网络
networks:
app-network:
driver: bridge
# 定义数据卷
volumes:
mysql_data:
driver: local

31
frontend/Dockerfile Normal file
View File

@@ -0,0 +1,31 @@
# 前端 Dockerfile (开发环境)
FROM node:18-alpine
WORKDIR /app
# 复制 package.json 和 package-lock.json
COPY package*.json ./
# 安装依赖
RUN npm ci
# 复制源代码
COPY . .
# 创建非root用户
RUN addgroup -g 1001 -S nodejs && \
adduser -S nodejs -u 1001 && \
chown -R nodejs:nodejs /app
# 切换用户
USER nodejs
# 暴露端口
EXPOSE 3000
# 健康检查
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
CMD node -e "const http = require('http'); http.get('http://localhost:3000', (res) => { if (res.statusCode !== 200) throw new Error('Health check failed') }).on('error', (err) => { console.error(err); process.exit(1); })"
# 启动开发服务器
CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0"]

View File

@@ -7,7 +7,7 @@ export default defineConfig({
port: 3000, port: 3000,
proxy: { proxy: {
'/api': { '/api': {
target: 'http://localhost:3001', target: process.env.VITE_API_URL || 'http://localhost:3001',
changeOrigin: true, changeOrigin: true,
}, },
}, },

1
tmpclaude-0c08-cwd Normal file
View File

@@ -0,0 +1 @@
/c/Users/99095/Desktop/优一科技/performance-evaluation-system

1
tmpclaude-18d3-cwd Normal file
View File

@@ -0,0 +1 @@
/c/Users/99095/Desktop/优一科技/performance-evaluation-system

1
tmpclaude-2f0c-cwd Normal file
View File

@@ -0,0 +1 @@
/c/Users/99095/Desktop/优一科技/performance-evaluation-system

1
tmpclaude-47c5-cwd Normal file
View File

@@ -0,0 +1 @@
/c/Users/99095/Desktop/优一科技/performance-evaluation-system

1
tmpclaude-7ecb-cwd Normal file
View File

@@ -0,0 +1 @@
/c/Users/99095/Desktop/优一科技/performance-evaluation-system

1
tmpclaude-85df-cwd Normal file
View File

@@ -0,0 +1 @@
/c/Users/99095/Desktop/优一科技/performance-evaluation-system

1
tmpclaude-9de9-cwd Normal file
View File

@@ -0,0 +1 @@
/c/Users/99095/Desktop/优一科技/performance-evaluation-system

1
tmpclaude-aa04-cwd Normal file
View File

@@ -0,0 +1 @@
/c/Users/99095/Desktop/优一科技/performance-evaluation-system

1
tmpclaude-b88e-cwd Normal file
View File

@@ -0,0 +1 @@
/c/Users/99095/Desktop/优一科技/performance-evaluation-system

1
tmpclaude-d88b-cwd Normal file
View File

@@ -0,0 +1 @@
/c/Users/99095/Desktop/优一科技/performance-evaluation-system

1
tmpclaude-e3e6-cwd Normal file
View File

@@ -0,0 +1 @@
/c/Users/99095/Desktop/优一科技/performance-evaluation-system

1
tmpclaude-f08b-cwd Normal file
View File

@@ -0,0 +1 @@
/c/Users/99095/Desktop/优一科技/performance-evaluation-system