Skip to content

Commit

Permalink
added multistage build and changed compose file
Browse files Browse the repository at this point in the history
  • Loading branch information
abhiraj-ku committed Sep 9, 2024
1 parent c328595 commit 53e9e6e
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 21 deletions.
16 changes: 13 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
FROM node:18
# Stage 1: Build stage
FROM node:18-alpine AS build

WORKDIR /app

COPY package*.json ./

RUN npm install
RUN npm ci

COPY . .


# Stage 2: Production stage

FROM node:18-alpine

WORKDIR /app

copy --from= build /app .

EXPOSE 4040

CMD [ "npm","start" ]
CMD["npm","start"]
46 changes: 28 additions & 18 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,39 @@ services:
build:
context: .
dockerfile: Dockerfile
container_name: splitBhai-app
volumes:
- .:/app
ports:
- "4040:4040"

env_file:
- "./env"
environment:
- DB_URI=mongodb://mongo:27017/splitbhai
- REDIS_URL=redis://redis:6379
depends_on:
- mongo
- redis
environment:
- MONGO_URI=mongodb://mongo:27017/splitBhaiDB
- REDIS_URL=redis://redis:6379
restart: unless-stopped

mongo:
image: mongo:latest
name: mongo_db
ports:
- "27017:27017"
volumes:
- mongo_data:/data/db
mongo:
image: mongo:6
container_name: splitBhai-mognoDB
ports:
- "27017:27017"
volumes:
- mongo-data:/data/db
restart: unless-stopped

redis:
image: redis:lates
container_name: redis_db
ports:
- "6379:6379"
redis:
image: redis:7
container_name: splitBhai-cacheDB
ports:
- "6379:6379"
volumes:
- redis-data:/data
restart: unless-stopped

volumes: mongo-data
redis-data
volumes:
mongo-data:
redis-data:

0 comments on commit 53e9e6e

Please sign in to comment.