Compare commits

...
7 Commits
Author SHA1 Message Date
yiling 0e4bdec0e3 Release v0.1.1 2026-06-23 10:32:41 +08:00
yiling 0eb03b16a4 chore(docker): add AWS_ENDPOINT_URL_S3 to local docker-compose 2026-06-23 10:27:18 +08:00
Yiling-J b216773044 Merge pull request #151 from shumaiOne/docker/entrypoint-privilege-dropping
feat(docker): add root entrypoint with privilege dropping for data volumes
2026-06-23 10:09:57 +08:00
yiling 92801ba14a fix(core): make version stack sort index lookup deterministic
When creating a version stack, the sortIndex was previously extracted
by taking files[0] from the database query result. Because findMany
without orderBy is non-deterministic, this resulted in flakiness
where the sortIndex would sometimes be null (from file2) instead of
'abc' (from file1), causing tests to fail.

We now look up the first file specifically based on the ordered
fileIds array parameter.
2026-06-23 10:02:01 +08:00
yiling 661e836f06 fix(docker): support non-root/restricted container environments in entrypoint
Checks if the container is running as root (UID 0) before executing
chown and gosu. If running directly as a non-root user (e.g. in hardened
environments like Kubernetes runAsNonRoot or via docker run --user),
it directly execs the command, preventing EACCES and permission errors.
2026-06-23 09:56:31 +08:00
yiling fb5c7ecabe chore(docker): ignore dist and data directories in .dockerignore
This adds the `dist` and `data` folders to `.dockerignore` to prevent
them from being transferred as part of the Docker build context.
This reduces the build context size by over 1.5GB+, making the build
much faster.
2026-06-23 09:53:00 +08:00
yiling a390643458 feat(docker): add root entrypoint with privilege dropping for data volumes
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.
2026-06-23 09:46:56 +08:00
20 changed files with 44 additions and 16 deletions
+2
View File
@@ -1,4 +1,6 @@
node_modules
dist
data
Dockerfile*
docker-compose*
.dockerignore
+8
View File
@@ -47,6 +47,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
socat \
ca-certificates \
bubblewrap \
gosu \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
@@ -69,5 +70,12 @@ COPY --chown=bun:bun --from=builder /app/prisma.config.ts.prod ./prisma.config.t
# Expose port (Bun Hono defaults to 3000)
EXPOSE 3000
# Switch back to root at the end so the container runs the entrypoint as root
USER root
COPY scripts/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
ENTRYPOINT ["docker-entrypoint.sh"]
# Default command: run migrations and start API server
CMD ["sh", "-c", "bun prisma migrate deploy && bun index.js"]
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@shumai/agent-app",
"version": "0.1.0",
"version": "0.1.1",
"private": true,
"type": "module",
"bin": {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@shumai/cli",
"version": "0.1.0",
"version": "0.1.1",
"private": true,
"type": "module",
"bin": {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@shumai/transcode-app",
"version": "0.1.0",
"version": "0.1.1",
"private": true,
"type": "module",
"bin": {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@shumai/web-app",
"version": "0.1.0",
"version": "0.1.1",
"private": true,
"type": "module",
"dependencies": {
+1
View File
@@ -29,6 +29,7 @@ services:
# S3 Configuration
STORAGE_BACKEND: local
AWS_ENDPOINT_URL_S3: http://localhost
# Better Auth
BETTER_AUTH_SECRET: qSxs9DxzHDZBbeeTNPEwBuspYwipBqz5Gk5XdBjNhWw=
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "shumai",
"version": "0.1.0",
"version": "0.1.1",
"private": true,
"type": "module",
"repository": {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@shumai/agent",
"version": "0.1.0",
"version": "0.1.1",
"private": true,
"type": "module",
"main": "./src/index.ts",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@shumai/api",
"version": "0.1.0",
"version": "0.1.1",
"private": true,
"type": "module",
"main": "./src/index.ts",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@shumai/core",
"version": "0.1.0",
"version": "0.1.1",
"private": true,
"type": "module",
"main": "./src/index.ts",
@@ -58,7 +58,7 @@ export class VersionStackService {
throw new Error('parent not found')
}
const firstFile = files[0]
const firstFile = files.find((f) => f.id === fileIds[0])
const sortIndex = firstFile?.sortIndex || null
const stack = await tx.asset.create({
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@shumai/db",
"version": "0.1.0",
"version": "0.1.1",
"private": true,
"type": "module",
"main": "./src/index.ts",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@shumai/dtos",
"version": "0.1.0",
"version": "0.1.1",
"private": true,
"type": "module",
"main": "./src/index.ts",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@shumai/tableprinter",
"version": "0.1.0",
"version": "0.1.1",
"private": true,
"type": "module",
"main": "./src/index.ts",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@shumai/transcode",
"version": "0.1.0",
"version": "0.1.1",
"private": true,
"type": "module",
"main": "./src/index.ts",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@shumai/webui",
"version": "0.1.0",
"version": "0.1.1",
"private": true,
"type": "module",
"main": "./index.html",
+1 -1
View File
@@ -1 +1 @@
export const APP_VERSION = '0.1.0'
export const APP_VERSION = '0.1.1'
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@shumai/workflow-core",
"version": "0.1.0",
"version": "0.1.1",
"private": true,
"type": "module",
"main": "./src/index.ts",
+17
View File
@@ -0,0 +1,17 @@
#!/bin/sh
set -e
if [ "$(id -u)" = "0" ]; then
# 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 "$@"
else
# Run the CMD directly if already running as non-root
exec "$@"
fi