This commit is contained in:
2026-09-10 18:54:53 +03:30
parent a308d6e039
commit e2303bcd70
8 changed files with 216 additions and 165 deletions
+2 -1
View File
@@ -13,7 +13,8 @@ COPY runtime ./runtime
COPY docker-entrypoint.sh /app/docker-entrypoint.sh
RUN chmod +x /app/docker-entrypoint.sh \
&& test -f /app/runtime/server.cjs \
&& test -f /app/runtime/libquery_engine-debian-openssl-3.0.x.so.node
&& test -f /app/runtime/libquery_engine-debian-openssl-3.0.x.so.node \
&& test -f /app/runtime/swagger-ui/swagger-ui.css
EXPOSE 9292
ENTRYPOINT ["./docker-entrypoint.sh"]
+2 -1
View File
@@ -13,7 +13,8 @@ COPY runtime ./runtime
COPY docker-entrypoint.sh /app/docker-entrypoint.sh
RUN chmod +x /app/docker-entrypoint.sh \
&& test -f /app/runtime/server.cjs \
&& test -f /app/runtime/libquery_engine-debian-openssl-3.0.x.so.node
&& test -f /app/runtime/libquery_engine-debian-openssl-3.0.x.so.node \
&& test -f /app/runtime/swagger-ui/swagger-ui.css
EXPOSE 9292
ENTRYPOINT ["./docker-entrypoint.sh"]
+177 -162
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+15
View File
@@ -68,6 +68,21 @@ execSync(
)
copyFileSync(engineSrc, path.join(runtimeDir, engineName))
const swaggerSrc = path.join(root, 'node_modules', 'swagger-ui-dist')
const swaggerDest = path.join(runtimeDir, 'swagger-ui')
mkdirSync(swaggerDest, { recursive: true })
for (const file of [
'swagger-ui.css',
'swagger-ui-bundle.js',
'swagger-ui-standalone-preset.js',
]) {
const src = path.join(swaggerSrc, file)
if (!existsSync(src)) {
throw new Error(`swagger-ui فایل ${file} پیدا نشد`)
}
copyFileSync(src, path.join(swaggerDest, file))
}
const schemaSrc = path.join(root, 'node_modules', '.prisma', 'client', 'schema.prisma')
if (existsSync(schemaSrc)) {
copyFileSync(schemaSrc, path.join(runtimeDir, 'schema.prisma'))
+13 -1
View File
@@ -1,3 +1,5 @@
import { existsSync } from 'node:fs';
import path from 'node:path';
import { NestFactory } from '@nestjs/core';
import { ValidationPipe } from '@nestjs/common';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
@@ -6,6 +8,14 @@ import { AppModule } from './app.module';
import { applyPendingMigrations } from './apply-migrations';
import { runBundledSeed } from './run-seed';
function swaggerUiAssetsPath() {
const bundled = path.join(process.cwd(), 'runtime', 'swagger-ui');
if (existsSync(path.join(bundled, 'swagger-ui.css'))) {
return bundled;
}
return path.join(process.cwd(), 'node_modules', 'swagger-ui-dist');
}
async function bootstrap() {
if (process.env.NODE_ENV === 'production') {
await applyPendingMigrations();
@@ -44,7 +54,9 @@ async function bootstrap() {
.addBearerAuth()
.build();
const document = SwaggerModule.createDocument(app, swaggerConfig);
SwaggerModule.setup(`${globalPrefix}/docs`, app, document);
SwaggerModule.setup(`${globalPrefix}/docs`, app, document, {
customSwaggerUiPath: swaggerUiAssetsPath(),
});
const port = Number(process.env.PORT) || 3000;
await app.listen(port);