feat: switch to Docker Compose + auto-migration
- docker-compose.yml: 移除 MySQL 容器,后端连宿主机 MySQL - main.ts: 启动时自动 runMigrations - 前端 Nginx 反代 /api/ → backend:3000 不变
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { ValidationPipe } from '@nestjs/common';
|
||||
import { AppModule } from './app.module';
|
||||
import { DataSource } from 'typeorm';
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule);
|
||||
app.setGlobalPrefix('api');
|
||||
app.enableCors();
|
||||
app.useGlobalPipes(new ValidationPipe({ transform: true, whitelist: true }));
|
||||
const dataSource = app.get(DataSource);
|
||||
await dataSource.runMigrations();
|
||||
console.log('Migrations OK');
|
||||
await app.listen(process.env.PORT ?? 3000);
|
||||
console.log(`Server running on http://localhost:${process.env.PORT ?? 3000}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user