feat: switch to Docker Compose + auto-migration

- docker-compose.yml: 移除 MySQL 容器,后端连宿主机 MySQL
- main.ts: 启动时自动 runMigrations
- 前端 Nginx 反代 /api/ → backend:3000 不变
This commit is contained in:
2026-07-20 12:24:51 +08:00
parent 2d7c30eb30
commit 4c2192d85e
2 changed files with 11 additions and 32 deletions

View File

@@ -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}`);
}