Skip to content
This repository has been archived by the owner on Jun 1, 2024. It is now read-only.

Commit

Permalink
dockerize the application
Browse files Browse the repository at this point in the history
  • Loading branch information
MEZ901 committed Mar 24, 2024
1 parent 133a13d commit 8aee2a3
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
18 changes: 18 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
services:
iam:
build:
context: .
dockerfile: docker/Dockerfile
target: development
restart: always
ports:
- '3000:3000'
volumes:
- ./src:/app/src
- ./.env:/app/.env
environment:
NODE_ENV: development

networks:
app-network:
driver: bridge
1 change: 1 addition & 0 deletions docker/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
33 changes: 33 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Development Stage
FROM node:20-alpine AS development

WORKDIR /app

COPY package.json pnpm-lock.yaml ./

RUN npm install -g pnpm && \
npm install -g @nestjs/cli && \
pnpm install

COPY .env nest-cli.json tsconfig.build.json tsconfig.json ./
COPY migrations ./migrations
COPY src ./src

CMD ["npm", "run", "start:dev"]

# Production Stage
FROM node:20-alpine AS production

WORKDIR /app

COPY package.json pnpm-lock.yaml ./

RUN npm install -g pnpm && \
npm install -g @nestjs/cli && \
pnpm install --production

COPY --from=development /app/dist ./dist

EXPOSE 3000

CMD ["node", "./dist/main.js"]

0 comments on commit 8aee2a3

Please sign in to comment.