tursodatabase / libsql

libSQL is a fork of SQLite that is both Open Source, and Open Contributions.
https://turso.tech/libsql
MIT License
9.54k stars 252 forks source link

use gosu instead of native docker USER in the entrypoint #1590

Closed sivukhin closed 2 months ago

sivukhin commented 2 months ago

Context

We are using USER command to run sqld process from sqld user but this is quite non-flexible. For example, if we will try to mount local user directory to the container it will fail with an error:

$> docker run --name some-sqld -it \
    -v $(pwd):/var/lib/sqld \
    -e SQLD_NODE=primary \
    ghcr.io/tursodatabase/libsql-server:latest /bin/sqld
...
Error: Permission denied (os error 13)

This PR changes the way we spawn sqld process: now we run docker-wrapper.sh with root permission which internally change permission of the data dir recursively and then spawn docker-entrypoint.sh from the sqld user with the gosu utility