Skip to content

Commit

Permalink
feat: dockerize backend
Browse files Browse the repository at this point in the history
  • Loading branch information
KonsumGandalf committed Apr 27, 2024
1 parent 93c585a commit e3866d1
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
37 changes: 37 additions & 0 deletions apps/backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM node:20-alpine as base

ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable

WORKDIR /usr/src/app

RUN corepack prepare pnpm@8.15.1 --activate

FROM base as installer

COPY package.json ./
COPY pnpm-lock.yaml ./

RUN pnpm install --frozen-lockfile --prod

FROM base as builder

ENV NX_DEAMON="false"

COPY --from=installer /usr/src/app/node_modules ./node_modules

COPY . .

RUN pnpm install --frozen-lockfile
RUN pnpm nx build backend

FROM node:20-alpine as production

COPY --from=installer /usr/src/app/node_modules ./node_modules
COPY --from=builder /usr/src/app/dist/apps/backend ./dist/

EXPOSE 3000
EXPOSE 9229

CMD ["node", "./dist/main.js"]
2 changes: 0 additions & 2 deletions apps/backend/src/app/app.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { AppService } from './app.service';

@Controller()
export class AppController {
A = 'awdawdawd';

constructor(private readonly appService: AppService) {}

@Get()
Expand Down

0 comments on commit e3866d1

Please sign in to comment.