Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix-Docker is consuming too much resource (PR for Devlop Branch) #2828

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
f1895b7
some changs
PurnenduMIshra129th Jan 2, 2025
182b201
updated docker.prod
PurnenduMIshra129th Jan 3, 2025
084eeda
updated Dockerfile.prod and dev
PurnenduMIshra129th Jan 4, 2025
1807342
created single compose file for prod and removed development dockerco…
PurnenduMIshra129th Jan 5, 2025
64e52b2
Merge branch 'main-develop' into bugfix/dockerEfficiency-develop
PurnenduMIshra129th Jan 5, 2025
ed3d884
merged branch with upstream
PurnenduMIshra129th Jan 5, 2025
37e57be
again added the docke-compose.dev.yaml , docker-compose.prod.yaml,Doc…
PurnenduMIshra129th Jan 12, 2025
4cbba55
changed package.json, changed start command with minio,commented the …
PurnenduMIshra129th Jan 12, 2025
de65d05
changed according to suggestion
PurnenduMIshra129th Jan 13, 2025
a307751
changed the jq installation to debian syntax
PurnenduMIshra129th Jan 13, 2025
3211756
changed command of minio start
PurnenduMIshra129th Jan 14, 2025
23963fb
updated script of minio and removed unnecessary imports in 2nd stage …
PurnenduMIshra129th Jan 14, 2025
a8dce3d
suggestion from ai
PurnenduMIshra129th Jan 19, 2025
c57a82c
Update docker-compose.dev.yaml line 19
PurnenduMIshra129th Jan 21, 2025
0f494f8
Update docker-compose.dev.yaml line 35
PurnenduMIshra129th Jan 21, 2025
26f26d4
Update docker-compose.dev.yaml line55
PurnenduMIshra129th Jan 21, 2025
2d3661c
Update docker-compose.prod.yaml line 16
PurnenduMIshra129th Jan 21, 2025
6773b68
Update docker-compose.prod.yaml
PurnenduMIshra129th Jan 21, 2025
4bfe7fb
Update docker-compose.prod.yaml
PurnenduMIshra129th Jan 21, 2025
f1fd16d
Update docker-compose.prod.yaml
PurnenduMIshra129th Jan 21, 2025
28c8374
updated by suggestion
PurnenduMIshra129th Jan 21, 2025
fcc9429
updated dockerFiles
PurnenduMIshra129th Jan 21, 2025
b64413c
added npm install in prod
PurnenduMIshra129th Jan 22, 2025
05eef35
Merge branch 'develop' of https://github.com/PalisadoesFoundation/tal…
PurnenduMIshra129th Jan 26, 2025
c21adcc
modify test expectation for getVolunteerRank.spec.ts componennt
PurnenduMIshra129th Jan 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions Dockerfile.dev
PurnenduMIshra129th marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
# Stage 1: Install Dependencies
FROM node:20.10.0 AS builder
# Stage 1: Build stage
FROM node:20.10.0

WORKDIR /usr/src/app

COPY package.json ./
# Copy only necessary files for dependency installation
COPY package*.json ./

# Install dependencies
RUN npm install

# Copy the rest of the source files (exclude .dockerignore content)
COPY . .

# Expose the application port
EXPOSE 4000

CMD ["npm", "run", "dev"]
# Start the application
CMD ["npm", "run", "dev"]
PurnenduMIshra129th marked this conversation as resolved.
Show resolved Hide resolved
22 changes: 14 additions & 8 deletions Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
# Stage 1: Install Dependencies and Build
FROM node:lts AS builder
# Stage 1: Build stage
FROM node:20.10.0 AS builder

WORKDIR /usr/src/app

COPY package*.json ./
# Copy only necessary files for dependency installation
COPY package*.json ./

RUN npm install -g npm@latest && npm install && rm -rf ./package-lock.json
RUN npm install

PurnenduMIshra129th marked this conversation as resolved.
Show resolved Hide resolved
COPY . .

# Build the application
RUN npm run build

# Stage 2: Final image
# Stage 2: Final stage
FROM node:alpine

PurnenduMIshra129th marked this conversation as resolved.
Show resolved Hide resolved
WORKDIR /usr/src/app

COPY --from=builder /usr/src/app/package.json ./
COPY --from=builder /usr/src/app/node_modules ./node_modules
# Copy only the build output, node_modules, and necessary files from the builder
COPY --from=builder /usr/src/app/build ./build
COPY --from=builder /usr/src/app/package.json ./package.json
COPY --from=builder /usr/src/app/node_modules ./node_modules


PurnenduMIshra129th marked this conversation as resolved.
Show resolved Hide resolved
# Expose the application port
EXPOSE 4000

CMD ["npm", "start"]
# Start the application
CMD ["npm", "run", "start"]
35 changes: 29 additions & 6 deletions docker-compose.dev.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
version: "3.8"
services:
mongo:
# No light weight image is available for mongo
image: mongo:latest
container_name: mongo
restart: unless-stopped
Expand All @@ -12,8 +14,10 @@ services:
resources:
limits:
memory: 1G
cpus: '1.0'
ports:
- "127.0.0.1:27017:27017"

volumes:
- mongo_data:/data/db
- ./scripts/docker/init-mongo.sh:/init-mongo.sh
Expand All @@ -22,15 +26,21 @@ services:
entrypoint: ["/bin/bash", "/init-mongo.sh"]

redis-stack-server:
image: redis/redis-stack-server:latest
image: redis:8.0-M02-alpine
ports:
- 6379:6379
PurnenduMIshra129th marked this conversation as resolved.
Show resolved Hide resolved
deploy:
resources:
limits:
memory: 512M
cpus: '0.5'
volumes:
- redis-data:/data/redis
networks:
- talawa-network

minio:
# No light weight image is available
image: minio/minio
ports:
- "9000:9000"
Expand All @@ -39,6 +49,11 @@ services:
- MINIO_ROOT_USER=${MINIO_ROOT_USER}
- MINIO_ROOT_PASSWORD=${MINIO_ROOT_PASSWORD}
command: server /data --console-address ":9001"
deploy:
resources:
limits:
memory: 512M
cpus: '0.5'
volumes:
- minio-data:/data
networks:
Expand All @@ -52,7 +67,6 @@ services:
ports:
- "4000:4000"
volumes:
- .:/usr/src/app
- /usr/src/app/node_modules
PurnenduMIshra129th marked this conversation as resolved.
Show resolved Hide resolved
depends_on:
mongo:
Expand All @@ -65,10 +79,16 @@ services:
- MONGO_DB_URL=mongodb://mongo:27017/talawa-api?replicaSet=rs0&directConnection=true
- REDIS_HOST=redis-stack-server
- REDIS_PORT=6379
deploy:
resources:
limits:
memory: 1G
cpus: '1.0'
networks:
- talawa-network

caddy:
image: caddy/caddy:2.2.1-alpine
image: caddy/caddy:2.9.1-alpine
container_name: caddy-service
restart: unless-stopped
ports:
Expand All @@ -79,8 +99,12 @@ services:
- $PWD/site:/srv
- caddy_data:/data
- caddy_config:/config
deploy:
resources:
limits:
memory: 256M
cpus: '0.25'


volumes:
redis-data:
minio-data:
Expand All @@ -89,5 +113,4 @@ volumes:
caddy_config:

networks:
talawa-network:
driver: bridge
talawa-network:
PurnenduMIshra129th marked this conversation as resolved.
Show resolved Hide resolved
88 changes: 73 additions & 15 deletions docker-compose.prod.yaml
Original file line number Diff line number Diff line change
@@ -1,57 +1,115 @@
version: "3.8"
PurnenduMIshra129th marked this conversation as resolved.
Show resolved Hide resolved
services:
mongodb:
mongo:
PurnenduMIshra129th marked this conversation as resolved.
Show resolved Hide resolved
# No light weight image is available for mongo
image: mongo:latest
container_name: mongo
restart: unless-stopped
healthcheck:
test: mongosh --eval "try { rs.status().ok } catch (e) { 0 }"
interval: 30s
timeout: 5s
retries: 30
deploy:
resources:
limits:
memory: 2G
cpus: '2.0'
ports:
- 27017:27017
- "127.0.0.1:27017:27017"
PurnenduMIshra129th marked this conversation as resolved.
Show resolved Hide resolved
volumes:
- mongodb-data:/data/db
- mongo_data:/data/db
- ./init-mongo.sh:/init-mongo.sh
networks:
- talawa-network
entrypoint: ["/bin/bash", "/init-mongo.sh"]

redis-stack-server:
image: redis/redis-stack-server:latest
image: redis:8.0-M02-alpine
ports:
- 6379:6379
deploy:
resources:
limits:
memory: 512M
cpus: '0.5'
volumes:
- redis-data:/data/redis
networks:
- talawa-network

minio:
# No light weight image is available
image: minio/minio
ports:
- "9000:9000"
- "9001:9001"
environment:
environment:
- MINIO_ROOT_USER=${MINIO_ROOT_USER}
- MINIO_ROOT_PASSWORD=${MINIO_ROOT_PASSWORD}
command: server /data --console-address ":9001"
deploy:
resources:
limits:
memory: 512M
cpus: '0.5'
volumes:
- minio-data:/data
networks:
- talawa-network
talawa-api-prod-container:

talawa-api-prod:
build:
context: .
dockerfile: Dockerfile.prod
container_name: talawa-api-prod
ports:
- 4000:4000
- "4000:4000"
volumes:
- /usr/src/app/node_modules
depends_on:
- mongodb
- redis-stack-server
- minio
mongo:
condition: service_healthy
redis-stack-server:
condition: service_started
minio:
condition: service_started
PurnenduMIshra129th marked this conversation as resolved.
Show resolved Hide resolved
environment:
- MONGO_DB_URL=mongodb://mongodb:27017
- MONGO_DB_URL=mongodb://mongo:27017/talawa-api?replicaSet=rs0&directConnection=true
- REDIS_HOST=redis-stack-server
- REDIS_PORT=6379
- MINIO_ENDPOINT=${MINIO_ENDPOINT}
deploy:
resources:
limits:
memory: 2G
cpus: '2.0'
networks:
- talawa-network

caddy:
image: caddy/caddy:2.9.1-alpine
container_name: caddy-service
restart: unless-stopped
ports:
- "80:80"
- "443:443"
PurnenduMIshra129th marked this conversation as resolved.
Show resolved Hide resolved
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
- $PWD/site:/srv
- caddy_data:/data
- caddy_config:/config
deploy:
resources:
limits:
memory: 256M
cpus: '0.25'

volumes:
mongodb-data:
redis-data:
minio-data:
mongo_data:
caddy_data:
caddy_config:

networks:
talawa-network:
driver: bridge
talawa-network:
PurnenduMIshra129th marked this conversation as resolved.
Show resolved Hide resolved
Loading
Loading