Skip to content

Commit 6eca6a6

Browse files
committed
🔒 security: create non-root user and adjust file ownership in Dockerfile
1 parent c51ece3 commit 6eca6a6

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

Dockerfile

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,26 @@ FROM oven/bun:1-slim AS production
4444

4545
WORKDIR /app
4646

47+
# Create non-root user for security (Trivy DS002)
48+
RUN groupadd --gid 1001 tinyclaw && \
49+
useradd --uid 1001 --gid tinyclaw --shell /bin/sh tinyclaw
50+
4751
# Copy everything needed at runtime
48-
COPY --from=builder /app/package.json ./
49-
COPY --from=builder /app/bun.lock ./
50-
COPY --from=builder /app/packages ./packages
51-
COPY --from=builder /app/src ./src
52-
COPY --from=builder /app/plugins ./plugins
53-
COPY --from=builder /app/node_modules ./node_modules
52+
COPY --from=builder --chown=tinyclaw:tinyclaw /app/package.json ./
53+
COPY --from=builder --chown=tinyclaw:tinyclaw /app/bun.lock ./
54+
COPY --from=builder --chown=tinyclaw:tinyclaw /app/packages ./packages
55+
COPY --from=builder --chown=tinyclaw:tinyclaw /app/src ./src
56+
COPY --from=builder --chown=tinyclaw:tinyclaw /app/plugins ./plugins
57+
COPY --from=builder --chown=tinyclaw:tinyclaw /app/node_modules ./node_modules
5458

5559
# SQLite data volume (defaults to ~/.tinyclaw inside the container)
5660
ENV TINYCLAW_DATA_DIR=/data
61+
RUN mkdir -p /data && chown tinyclaw:tinyclaw /data
5762
VOLUME /data
5863

64+
# Switch to non-root user
65+
USER tinyclaw
66+
5967
# API + Web UI
6068
EXPOSE 3000
6169

0 commit comments

Comments
 (0)