Phase G2-1~G2-6: Code Execution Worker - Docker sandbox deployment, backend API (code_exec_admin.py), frontend CodeExecTab, security hardening (read-only FS, non-root, capability dropping, RLIMIT_AS)
This commit is contained in:
1 parent
909c013e2d
commit
9b3e15ace6
9 files changed
+1709
-447
No files matched your search
@@ -0,0 +1,42 @@
|
||||
FROM python:3.11-slim
|
||||
|
||||
LABEL maintainer="qihuaiflow"
|
||||
LABEL description="Code Execution Sandbox - isolated code runner for Python and JavaScript"
|
||||
|
||||
# Switch to Aliyun mirrors for faster downloads in China
|
||||
RUN sed -i 's|http://deb.debian.org/debian|http://mirrors.aliyun.com/debian|g' /etc/apt/sources.list.d/debian.sources \
|
||||
&& sed -i 's|http://deb.debian.org/debian-security|http://mirrors.aliyun.com/debian-security|g' /etc/apt/sources.list.d/debian.sources
|
||||
|
||||
# Install Node.js from Debian repos + essential tools
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
nodejs \
|
||||
npm \
|
||||
curl \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& ln -sf /usr/bin/nodejs /usr/bin/node 2>/dev/null || true
|
||||
|
||||
# Install Python packages with Aliyun mirror
|
||||
RUN pip install --no-cache-dir -i https://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com \
|
||||
fastapi==0.104.1 \
|
||||
uvicorn==0.24.0 \
|
||||
pydantic==2.5.2
|
||||
|
||||
# Create non-root user for security
|
||||
RUN useradd -m -s /bin/bash executor \
|
||||
&& mkdir -p /workspace /app \
|
||||
&& chown -R executor:executor /workspace /app
|
||||
|
||||
# Copy executor server
|
||||
COPY executor_server.py /app/executor_server.py
|
||||
RUN chown executor:executor /app/executor_server.py
|
||||
|
||||
WORKDIR /app
|
||||
USER executor
|
||||
EXPOSE 8000
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
|
||||
CMD curl -f http://localhost:8000/health || exit 1
|
||||
|
||||
CMD ["uvicorn", "executor_server:app", "--host", "0.0.0.0", "--port", "8000", "--no-access-log"]
|
||||
Reference in new issue
Block a user