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