规定数据类型

This commit is contained in:
2026-04-24 01:45:29 +08:00
parent ab860c61d9
commit d1943f564a
18 changed files with 546 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
# Backend Dockerfile - NestJS
FROM node:20-alpine AS builder
WORKDIR /app
# Copy package files
COPY server/package*.json ./server/
COPY shared/package*.json ./shared/
# Install dependencies
RUN cd server && npm ci
# Copy source code
COPY server/src ./server/src
COPY server/tsconfig.json ./server/
COPY server/nest-cli.json ./server/
COPY shared ./shared
# Build
RUN cd server && npm run build
# Production stage
FROM node:20-alpine
WORKDIR /app
# Copy package files and install production dependencies
COPY server/package*.json ./
RUN npm ci --only=production
# Copy built application
COPY --from=builder /app/server/dist ./dist
COPY shared ./shared
# Create data directory
RUN mkdir -p /app/data
EXPOSE 3000
CMD ["node", "dist/main.js"]

View File

@@ -0,0 +1,31 @@
# Frontend Dockerfile - Vue3 + Vite
FROM node:20-alpine AS builder
WORKDIR /app
# Copy package files
COPY client/package*.json ./client/
COPY shared/package*.json ./shared/
# Install dependencies
RUN cd client && npm ci
# Copy source code
COPY client ./client
COPY shared ./shared
# Build
RUN cd client && npm run build
# Production stage - serve with nginx
FROM nginx:alpine
# Copy custom nginx config
COPY docker/nginx/default.conf /etc/nginx/conf.d/default.conf
# Copy built files
COPY --from=builder /app/client/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

View File

@@ -0,0 +1,37 @@
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html;
# Gzip compression
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml+rss application/json application/javascript;
# Serve static files
location / {
try_files $uri $uri/ /index.html;
}
# API proxy to backend
location /api/ {
proxy_pass http://backend:3000/api/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $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_cache_bypass $http_upgrade;
}
# Cache static assets
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
}