Update docker-compose configuration for resource limits and image usage

This commit is contained in:
Jose Eduardo 2025-08-11 13:14:48 -04:00
parent 3bad475df6
commit 4e5350faab

View File

@ -2,23 +2,18 @@ services:
api1: api1:
container_name: api1 container_name: api1
hostname: api1 hostname: api1
build: image: payment2:latest
context: .
dockerfile: Dockerfile
entrypoint: ./docker/entrypoint.sh
networks: networks:
- backend - backend
- payment-processor - payment-processor
volumes:
- .:/app
depends_on: depends_on:
- redis - redis
- database - database
# deploy: deploy:
# resources: resources:
# limits: limits:
# cpus: "0.15" cpus: "0.30"
# memory: "80MB" memory: "80MB"
healthcheck: healthcheck:
test: [ "CMD", "curl", "-f", "http://api1:9999" ] test: [ "CMD", "curl", "-f", "http://api1:9999" ]
interval: 30s interval: 30s
@ -28,23 +23,18 @@ services:
api2: api2:
container_name: api2 container_name: api2
hostname: api2 hostname: api2
build: image: payment2:latest
context: .
dockerfile: Dockerfile
entrypoint: ./docker/entrypoint.sh
depends_on: depends_on:
- redis - redis
- database - database
networks: networks:
- backend - backend
- payment-processor - payment-processor
volumes: deploy:
- .:/app resources:
# deploy: limits:
# resources: cpus: "0.30"
# limits: memory: "80MB"
# cpus: "0.15"
# memory: "80MB"
healthcheck: healthcheck:
test: [ "CMD", "curl", "-f", "http://api2:9999" ] test: [ "CMD", "curl", "-f", "http://api2:9999" ]
interval: 30s interval: 30s
@ -67,8 +57,8 @@ services:
deploy: deploy:
resources: resources:
limits: limits:
cpus: "0.10" cpus: "0.1"
memory: "20MB" memory: "10MB"
redis: redis:
image: redis:7.2-alpine image: redis:7.2-alpine
@ -79,12 +69,12 @@ services:
networks: networks:
- backend - backend
volumes: volumes:
- redis_data:/data - redis_data1:/data
deploy: deploy:
resources: resources:
limits: limits:
cpus: "0.05" cpus: "0.10"
memory: "20MB" memory: "48MB"
database: database:
container_name: database container_name: database
@ -103,15 +93,15 @@ services:
- POSTGRES_USER=postgres - POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres_pwd - POSTGRES_PASSWORD=postgres_pwd
volumes: volumes:
- database_volume:/var/lib/postgresql/data - database_volume1:/var/lib/postgresql/data
- ./docker/db_init/:/docker-entrypoint-initdb.d/ - ./docker/db_init.sql:/docker-entrypoint-initdb.d/
networks: networks:
- backend - backend
deploy: deploy:
resources: resources:
limits: limits:
cpus: "0.5" cpus: "0.70"
memory: "110MB" memory: "117MB"
networks: networks:
backend: backend:
@ -120,5 +110,5 @@ networks:
external: true external: true
volumes: volumes:
database_volume: database_volume1:
redis_data: redis_data1: