Skip to content

Commit

Permalink
fix nestjs-server dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
nishkohli96 committed Feb 22, 2024
1 parent 785f124 commit 6a9de04
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
7 changes: 2 additions & 5 deletions apps/nestjs-server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,12 @@ COPY --chown=node:node package.json .
RUN mkdir -p apps/nestjs-server

# copying only the required packages
COPY --chown=node:node ./apps/nestjs-server/package.json apps/nestjs-server
COPY --chown=node:node ./apps/nestjs-server/tsconfig.*.json apps/nestjs-server
COPY --chown=node:node ./apps/nestjs-server/package.json apps/nestjs-server
COPY --chown=node:node ./apps/nestjs-server apps/nestjs-server

# install node_modules
RUN yarn

# build nestjs-server
RUN yarn build

# run server in dev env
# run server in prod env
CMD ["yarn", "workspace", "nestjs-server", "start:prod"]
10 changes: 9 additions & 1 deletion apps/nestjs-server/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,22 @@ async function bootstrap() {
* the line below...
*/
// const app = await NestFactory.create(AppModule);

/**
* Unfortunately NestJs prod build with fastify, works on local
* machine, but it does not port map on docker...
*
* Soln link -
* https://stackoverflow.com/questions/66086427/docker-container-with-nodejs-appnestjs-is-not-accessible-from-both-other-conta
*/
const app = await NestFactory.create<NestFastifyApplication>(
AppModule,
new FastifyAdapter({
ignoreTrailingSlash: true,
caseSensitive: false,
}),
);
await app.listen(4000);
await app.listen(4000, '0.0.0.0');
}

bootstrap();

0 comments on commit 6a9de04

Please sign in to comment.