FROM --platform=linux/amd64 ubuntu:24.04

RUN apt-get update && apt-get install -y \
    tmux \
    curl \
    git \
    build-essential \
    nodejs \
    npm \
    bash \
    && rm -rf /var/lib/apt/lists/*

# Install gotty (web terminal access)
RUN curl -sL https://github.com/sorenisanerd/gotty/releases/download/v1.5.0/gotty_linux_amd64.tar.gz | \
    tar xz -C /usr/local/bin && chmod +x /usr/local/bin/gotty

# Install Claude CLI
RUN npm install -g claude-code-cli 2>&1 || echo "Note: Claude CLI will be available after NPM package is published"

WORKDIR /root

# Create persistent storage dir
RUN mkdir -p /root/.claude /root/.config /root/.cache

# Entrypoint: start tmux session and gotty
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

EXPOSE 8080

ENTRYPOINT ["/entrypoint.sh"]
