Skip to content

Commit

Permalink
Create Dockerfile; fix incorrect dev dependencies; serve client from …
Browse files Browse the repository at this point in the history
…server app
  • Loading branch information
paulbert committed Jun 27, 2024
1 parent b298f86 commit db2ee09
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 94 deletions.
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:22-alpine as builder
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . ./
RUN npx nx reset
RUN npm run build

FROM node:22-alpine as runner

COPY --from=builder /usr/src/app/dist/apps /app
WORKDIR /app/server
RUN npm install
3 changes: 2 additions & 1 deletion apps/server/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"tsConfig": "apps/server/tsconfig.app.json",
"assets": ["apps/server/src/assets"],
"isolatedConfig": true,
"webpackConfig": "apps/server/webpack.config.js"
"webpackConfig": "apps/server/webpack.config.js",
"generatePackageJson": true
},
"configurations": {
"development": {},
Expand Down
6 changes: 6 additions & 0 deletions apps/server/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Module } from '@nestjs/common';
import { GraphQLModule } from '@nestjs/graphql';
import { ApolloDriver, ApolloDriverConfig } from '@nestjs/apollo';
import { ServeStaticModule } from '@nestjs/serve-static';
import { join } from 'path';

import { VideosResolver } from './videos/videos.resolver';
Expand All @@ -11,6 +12,10 @@ import { SeasonsService } from './seasons/seasons.service';
import { VideosService } from './videos/videos.service';
import { SeasonsResolver } from './seasons/seasons.resolver';

const staticSite = ServeStaticModule.forRoot({
rootPath: join(__dirname, '..', 'client'),
});

@Module({
imports: [
GraphQLModule.forRoot<ApolloDriverConfig>({
Expand All @@ -19,6 +24,7 @@ import { SeasonsResolver } from './seasons/seasons.resolver';
sortSchema: true,
buildSchemaOptions: { numberScalarMode: 'integer' },
}),
...(process.env.NODE_ENV === 'production' ? [staticSite] : []),
],
providers: [
PrismaService,
Expand Down
Loading

0 comments on commit db2ee09

Please sign in to comment.