Consolidate Docker deployment into a single PaperJet container
This commit is contained in:
parent
db9e2ca51b
commit
65abb5154e
13 changed files with 290 additions and 151 deletions
36
docker-entrypoint.sh
Normal file
36
docker-entrypoint.sh
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -Eeuo pipefail
|
||||
|
||||
uvicorn --app-dir /app app.main:app \
|
||||
--host 127.0.0.1 \
|
||||
--port 8000 \
|
||||
--workers 1 &
|
||||
backend_pid=$!
|
||||
|
||||
nginx -g "daemon off;" &
|
||||
nginx_pid=$!
|
||||
|
||||
stop_children() {
|
||||
kill -TERM "$backend_pid" "$nginx_pid" 2>/dev/null || true
|
||||
wait "$backend_pid" 2>/dev/null || true
|
||||
wait "$nginx_pid" 2>/dev/null || true
|
||||
}
|
||||
|
||||
shutdown() {
|
||||
trap - TERM INT
|
||||
stop_children
|
||||
exit 143
|
||||
}
|
||||
|
||||
trap shutdown TERM INT
|
||||
|
||||
# If either service exits, stop the other one and let Docker restart/report the
|
||||
# container rather than leaving a partially working instance running.
|
||||
set +e
|
||||
wait -n "$backend_pid" "$nginx_pid"
|
||||
exit_code=$?
|
||||
set -e
|
||||
|
||||
stop_children
|
||||
exit "$exit_code"
|
||||
Loading…
Add table
Add a link
Reference in a new issue