Add entrypoint script and update docker-compose for service configuration

This commit is contained in:
Jose Eduardo 2025-08-03 21:19:59 -04:00
parent 62f32b830a
commit c50f9c5c4e
3 changed files with 24 additions and 16 deletions

View File

@ -5,6 +5,7 @@ services:
build: build:
context: . context: .
dockerfile: Dockerfile dockerfile: Dockerfile
entrypoint: ./docker/entrypoint.sh
networks: networks:
- backend - backend
- payment-processor - payment-processor
@ -13,13 +14,13 @@ services:
depends_on: depends_on:
- redis - redis
- database - database
deploy: # deploy:
resources: # resources:
limits: # limits:
cpus: "0.15" # cpus: "0.15"
memory: "80MB" # memory: "80MB"
healthcheck: healthcheck:
test: [ "CMD", "curl", "-f", "http://localhost:9999" ] test: [ "CMD", "curl", "-f", "http://api1:9999" ]
interval: 30s interval: 30s
timeout: 10s timeout: 10s
retries: 3 retries: 3
@ -30,6 +31,7 @@ services:
build: build:
context: . context: .
dockerfile: Dockerfile dockerfile: Dockerfile
entrypoint: ./docker/entrypoint.sh
depends_on: depends_on:
- redis - redis
- database - database
@ -38,13 +40,13 @@ services:
- payment-processor - payment-processor
volumes: volumes:
- .:/app - .:/app
deploy: # deploy:
resources: # resources:
limits: # limits:
cpus: "0.15" # cpus: "0.15"
memory: "80MB" # memory: "80MB"
healthcheck: healthcheck:
test: [ "CMD", "curl", "-f", "http://localhost:9999" ] test: [ "CMD", "curl", "-f", "http://api2:9999" ]
interval: 30s interval: 30s
timeout: 10s timeout: 10s
retries: 3 retries: 3
@ -54,7 +56,7 @@ services:
container_name: nginx container_name: nginx
hostname: nginx hostname: nginx
ports: ports:
- "9999:80" - "9999:9999"
volumes: volumes:
- ./nginx.conf:/etc/nginx/nginx.conf - ./nginx.conf:/etc/nginx/nginx.conf
networks: networks:
@ -76,6 +78,8 @@ services:
- "6379:6379" - "6379:6379"
networks: networks:
- backend - backend
volumes:
- redis_data:/data
deploy: deploy:
resources: resources:
limits: limits:
@ -89,7 +93,7 @@ services:
ports: ports:
- "5432:5432" - "5432:5432"
healthcheck: healthcheck:
test: [ "CMD-SHELL", "pg_isready -U rinha -d rinha" ] test: [ "CMD-SHELL", "pg_isready -U postgres -d payment" ]
interval: 5s interval: 5s
timeout: 5s timeout: 5s
retries: 5 retries: 5
@ -116,3 +120,4 @@ networks:
volumes: volumes:
database_volume: database_volume:
redis_data:

3
docker/entrypoint.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
yarn start:dev

View File

@ -6,4 +6,4 @@ COPY . .
RUN yarn install -y \ RUN yarn install -y \
&& yarn build && yarn build
ENTRYPOINT [ "yarn", "start:dev" ] EXPOSE 9999