Skip to content

Conversation

stbenjam
Copy link

@stbenjam stbenjam commented Oct 8, 2025

Fixes #103

Use exec in docker-entrypoint.sh to replace the shell process with
the Python process, making it PID 1. This ensures SIGTERM and SIGINT
signals are properly received and handled during shutdown, preventing
the container from hanging indefinitely when stopped.

Without exec, the shell script remains as PID 1 and doesn't forward
signals to the child Python process, causing it to wait forever for
stdin to close in stdio mode.

Reproducer:

$DOCKER run -p 8000:8000 -e DATABASE_URI -access-mode=restricted --transport=sse

Without these changes, ^C does not work and the process is hung
forever. After these changes ^C properly exits.

Also fixes to build the postgres container, the app user doesn't seem to exist in the base image.

Use exec in docker-entrypoint.sh to replace the shell process with
the Python process, making it PID 1. This ensures SIGTERM and SIGINT
signals are properly received and handled during shutdown, preventing
the container from hanging indefinitely when stopped.

Without exec, the shell script remains as PID 1 and doesn't forward
signals to the child Python process, causing it to wait forever for
stdin to close in stdio mode.

Reproducer:

```
$DOCKER run -p 8000:8000 -e DATABASE_URI -access-mode=restricted --transport=sse
```

Without these changes, `^C` does not work and the process is hung
forever.  After these changes `^C` properly exits.

Assisted-by: Cursor AI
I'm not able to build the Dockerfile as the `app` user doesn't exist in
the base image.  This creates it.

It also makes sure the app runs as non-root.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Docker spins up a large number of containers

1 participant