feat: serve frontend from api container in prod build

This commit is contained in:
Julian Tölle 2020-05-03 03:46:52 +02:00
parent 49bff95ea5
commit ad98ce4e88
5 changed files with 24 additions and 1 deletions

1
.gitignore vendored
View file

@ -1,5 +1,6 @@
# compiled output # compiled output
/dist /dist
/build
/node_modules /node_modules

View file

@ -45,6 +45,6 @@ LABEL stage="app"
RUN npm ci --only=production RUN npm ci --only=production
COPY --from=build-api /app/dist/ /app/dist/ COPY --from=build-api /app/dist/ /app/dist/
COPY --from=build-frontend /app/frontend/dist /app/static/ COPY --from=build-frontend /app/frontend/build /app/static/
CMD ["dist/main"] CMD ["dist/main"]

15
package-lock.json generated
View file

@ -1328,6 +1328,21 @@
} }
} }
}, },
"@nestjs/serve-static": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/@nestjs/serve-static/-/serve-static-2.1.0.tgz",
"integrity": "sha512-syC7x3vacNYOAqpITqiPd7NS0gAc3IbzexyMOpUu00mVt/8NZc3zXNEV5r4DeatRKUwc11tt1TRlMEsmTLTQIA==",
"requires": {
"path-to-regexp": "0.1.7"
},
"dependencies": {
"path-to-regexp": {
"version": "0.1.7",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
"integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w="
}
}
},
"@nestjs/swagger": { "@nestjs/swagger": {
"version": "4.5.3", "version": "4.5.3",
"resolved": "https://registry.npmjs.org/@nestjs/swagger/-/swagger-4.5.3.tgz", "resolved": "https://registry.npmjs.org/@nestjs/swagger/-/swagger-4.5.3.tgz",

View file

@ -27,6 +27,7 @@
"@nestjs/passport": "^7.0.0", "@nestjs/passport": "^7.0.0",
"@nestjs/platform-express": "^7.0.9", "@nestjs/platform-express": "^7.0.9",
"@nestjs/schedule": "^0.3.1", "@nestjs/schedule": "^0.3.1",
"@nestjs/serve-static": "^2.1.0",
"@nestjs/swagger": "^4.5.3", "@nestjs/swagger": "^4.5.3",
"@nestjs/typeorm": "^7.0.0", "@nestjs/typeorm": "^7.0.0",
"class-transformer": "^0.2.3", "class-transformer": "^0.2.3",

View file

@ -1,6 +1,8 @@
import { Module } from "@nestjs/common"; import { Module } from "@nestjs/common";
import { ConfigModule } from "@nestjs/config"; import { ConfigModule } from "@nestjs/config";
import { ScheduleModule } from "@nestjs/schedule"; import { ScheduleModule } from "@nestjs/schedule";
import { ServeStaticModule } from "@nestjs/serve-static";
import { join } from "path";
import { AuthModule } from "./auth/auth.module"; import { AuthModule } from "./auth/auth.module";
import { DatabaseModule } from "./database/database.module"; import { DatabaseModule } from "./database/database.module";
import { ListensModule } from "./listens/listens.module"; import { ListensModule } from "./listens/listens.module";
@ -14,6 +16,10 @@ import { UsersModule } from "./users/users.module";
ConfigModule.forRoot({ isGlobal: true }), ConfigModule.forRoot({ isGlobal: true }),
ScheduleModule.forRoot(), ScheduleModule.forRoot(),
DatabaseModule, DatabaseModule,
ServeStaticModule.forRoot({
rootPath: join(__dirname, "..", "static"),
exclude: ["/api*"],
}),
AuthModule, AuthModule,
UsersModule, UsersModule,
SourcesModule, SourcesModule,