Skip to content

Commit 22d652e

Browse files
build(docker): add configs to speed up compose up/down/restart
1. In `package.json`, add `--abort-on-container-exit` flag to the npm `start` script. This ensures the `dynamodb-local` container is also killed when the `api` container is stopped, which ensures the db container's port is released and made available for subsequent `up` invocations. Without this, the next `up` will fail bc the port will be unavailable (unless additional action has been taken to free up the port). 2. In `package.json`, change the `start:dist` script to use the `start` script so it doesn't have to repeat the long `--abort-on-container-exit` docker compose flag. 3. In `docker-compose.yaml`, add `stop_grace_period: 2s` to the `api` container's configs. This overrides the default of `10s`, which is unnecessarily long and slows down container killing/restart.
1 parent 7b76974 commit 22d652e

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

docker-compose.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ services:
2222
AWS_SECRET_ACCESS_KEY: local
2323
DYNAMODB_ENDPOINT: "http://dynamodb-local:8000"
2424
tty: true
25+
stop_grace_period: 2s # default is 10s
2526

2627
dynamodb-local:
2728
container_name: dynamodb-local

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
},
2222
"type": "module",
2323
"scripts": {
24-
"start": "docker compose up",
25-
"start:dist": "API_COMMAND='node dist/index.js' docker compose up",
24+
"start": "docker compose up --abort-on-container-exit",
25+
"start:dist": "API_COMMAND='node dist/index.js' && npm start",
2626
"prebuild": "[ -d dist ] && rm -rf dist || true",
2727
"build": "swc src --out-dir dist --strip-leading-paths",
2828
"lint": "eslint src",

0 commit comments

Comments
 (0)