Spaces:
Paused
Paused
| FROM ubuntu:22.04 | |
| ENV DEBIAN_FRONTEND=noninteractive | |
| ENV HOME=/home/user | |
| ENV PATH="/home/user/.local/bin:/home/user/.npm-global/bin:/usr/local/bin:$PATH" | |
| ENV NPM_CONFIG_PREFIX=/home/user/.npm-global | |
| ENV TERM=xterm-256color | |
| ENV LANG=en_US.UTF-8 | |
| # System packages + nginx + gotty alternative (shellinabox removed, use gotty) | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| curl wget git ca-certificates build-essential \ | |
| python3 python3-pip python3-venv \ | |
| nginx \ | |
| ripgrep fd-find sqlite3 unzip zip \ | |
| cmake libjson-c-dev libwebsockets-dev \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Build ttyd from source (reliable, no binary download issues) | |
| RUN cd /tmp && \ | |
| git clone --depth 1 --branch 1.7.4 https://github.com/tsl0922/ttyd.git && \ | |
| cd ttyd && mkdir build && cd build && \ | |
| cmake .. && make -j$(nproc) && \ | |
| cp ttyd /usr/local/bin/ttyd && \ | |
| chmod +x /usr/local/bin/ttyd && \ | |
| cd / && rm -rf /tmp/ttyd && \ | |
| ttyd --version | |
| # Node.js 20 | |
| RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \ | |
| apt-get install -y nodejs && \ | |
| rm -rf /var/lib/apt/lists/* | |
| # Create user | |
| RUN useradd -m -s /bin/bash user | |
| # nginx permissions for non-root | |
| RUN mkdir -p /var/log/nginx /var/lib/nginx/body /var/lib/nginx/proxy /var/lib/nginx/fastcgi /var/lib/nginx/uwsgi /var/lib/nginx/scgi /run && \ | |
| chown -R user:user /var/log/nginx /var/lib/nginx /run /etc/nginx | |
| USER user | |
| WORKDIR /home/user | |
| RUN mkdir -p /home/user/.npm-global | |
| # Install Claude Code CLI | |
| RUN npm install -g @anthropic-ai/claude-code@latest 2>&1 | tail -5 | |
| # Python deps | |
| COPY requirements.txt /home/user/requirements.txt | |
| RUN pip3 install --no-cache-dir -r /home/user/requirements.txt | |
| # Claude Code pre-config | |
| RUN mkdir -p /home/user/.claude && \ | |
| echo '{"permissions":{"allow":["Bash(*)","Read(*)","Write(*)","Edit(*)","Computer(*)","WebFetch(*)","mcp__*"],"deny":[]},"hasCompletedOnboarding":true,"hasAcknowledgedDisclaimer":true}' > /home/user/.claude/settings.json | |
| RUN mkdir -p /home/user/workspace | |
| # Copy app files | |
| COPY --chown=user:user app.py proxy.py start.sh nginx.conf /home/user/ | |
| COPY --chown=user:user README.md /home/user/README.md | |
| USER root | |
| RUN chmod +x /home/user/start.sh | |
| USER user | |
| EXPOSE 7860 | |
| CMD ["/home/user/start.sh"] | |