mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-04 15:14:10 +00:00
Merge pull request #151 from shumaiOne/docker/entrypoint-privilege-dropping
feat(docker): add root entrypoint with privilege dropping for data volumes
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
node_modules
|
node_modules
|
||||||
|
dist
|
||||||
|
data
|
||||||
Dockerfile*
|
Dockerfile*
|
||||||
docker-compose*
|
docker-compose*
|
||||||
.dockerignore
|
.dockerignore
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|||||||
socat \
|
socat \
|
||||||
ca-certificates \
|
ca-certificates \
|
||||||
bubblewrap \
|
bubblewrap \
|
||||||
|
gosu \
|
||||||
&& apt-get clean \
|
&& apt-get clean \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& 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 port (Bun Hono defaults to 3000)
|
||||||
EXPOSE 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
|
# Default command: run migrations and start API server
|
||||||
CMD ["sh", "-c", "bun prisma migrate deploy && bun index.js"]
|
CMD ["sh", "-c", "bun prisma migrate deploy && bun index.js"]
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ export class VersionStackService {
|
|||||||
throw new Error('parent not found')
|
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 sortIndex = firstFile?.sortIndex || null
|
||||||
|
|
||||||
const stack = await tx.asset.create({
|
const stack = await tx.asset.create({
|
||||||
|
|||||||
@@ -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
|
||||||
Reference in New Issue
Block a user