Files
open-terminal/Dockerfile
T
Timothy Jaeryang Baek 0aeda7392c refactor: native Python I/O for multi-user reads
Replace subprocess-based reads (cat, find, stat, test) with native
Python file I/O. Uses chmod 750 + group membership so the server
process can read user directories directly. Writes still use sudo -u
for correct ownership.

- Dockerfile: add CAP_SETGID to Python binary via setcap
- user_isolation: chmod 750, usermod -aG, os.setgroups() refresh
- utils/fs.py: all reads now use aiofiles/os (no subprocess branching)
2026-03-09 18:05:55 -05:00

73 lines
2.0 KiB
Docker

FROM python:3.12
RUN apt-get update && apt-get install -y --no-install-recommends \
# Core utilities
coreutils findutils grep sed gawk diffutils patch \
less file tree bc man-db \
# Networking
curl wget net-tools iputils-ping dnsutils netcat-openbsd socat telnet \
openssh-client rsync \
# Editors
vim nano \
# Version control
git \
# Build tools
build-essential cmake make \
# Scripting & languages
perl ruby-full lua5.4 \
# Data processing
jq xmlstarlet sqlite3 \
# Media & documents
ffmpeg pandoc imagemagick texlive-latex-base \
# Compression
zip unzip tar gzip bzip2 xz-utils zstd p7zip-full \
# System
procps htop lsof strace sysstat \
sudo tmux screen \
ca-certificates gnupg apt-transport-https \
&& rm -rf /var/lib/apt/lists/*
# Node.js (LTS)
RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
&& apt-get install -y --no-install-recommends nodejs \
&& rm -rf /var/lib/apt/lists/*
# Docker CLI + Compose + Buildx (mount socket at runtime for access)
RUN curl -fsSL https://get.docker.com | sh
WORKDIR /app
RUN pip install --no-cache-dir \
numpy pandas scipy scikit-learn \
matplotlib seaborn plotly \
jupyter ipython \
requests beautifulsoup4 lxml \
sqlalchemy psycopg2-binary \
pyyaml toml jsonlines \
tqdm rich \
openpyxl weasyprint \
python-docx python-pptx pypdf csvkit
COPY . .
RUN pip install --no-cache-dir .
RUN useradd -m -s /bin/bash user && echo 'user ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
# Grant CAP_SETGID to Python so the server can refresh supplementary groups
# at runtime when provisioning new users in multi-user mode.
RUN apt-get update && apt-get install -y --no-install-recommends libcap2-bin \
&& rm -rf /var/lib/apt/lists/* \
&& setcap cap_setgid+ep $(readlink -f $(which python3))
USER user
ENV SHELL=/bin/bash
ENV PATH="/home/user/.local/bin:${PATH}"
WORKDIR /home/user
EXPOSE 8000
COPY entrypoint.sh /app/entrypoint.sh
ENTRYPOINT ["/app/entrypoint.sh"]
CMD ["run"]