fix bug
This commit is contained in:
+2
-1
@@ -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
@@ -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
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
@@ -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
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user