mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-22 04:29:41 +00:00
This updates the Dockerfile and adds a scripts/docker-entrypoint.sh script. Under native Linux (like Debian), when docker-compose mounts a host folder as a volume (e.g. `./data:/app/data`), and the folder doesn't exist, the docker daemon creates the folder as root-owned (`root:root`). Because the container runs as a non-root user `bun`, it gets permission denied (`EACCES`) when trying to write to the data directory. To resolve this in a beginner-friendly way without manual host-side permissions updates: 1. The runner stage now installs `gosu`. 2. At the end of the Dockerfile, the user switches back to `root` so the container launches as root. 3. On launch, the entrypoint script executes. Since it runs as root, it automatically changes ownership of `/app/data` to `bun:bun`. 4. The entrypoint script then uses `gosu` to drop privileges and launch the actual server processes as the non-root `bun` user.
14 lines
310 B
Bash
14 lines
310 B
Bash
#!/bin/sh
|
|
set -e
|
|
|
|
# Check if /app/data exists and is not owned by the bun user (UID 1000)
|
|
if [ -d "/app/data" ]; then
|
|
if [ "$(stat -c '%u' /app/data)" != "1000" ]; then
|
|
echo "Correcting permissions on /app/data..."
|
|
chown -R bun:bun /app/data
|
|
fi
|
|
fi
|
|
|
|
# Run the CMD as the bun user
|
|
exec gosu bun "$@"
|