FROM mcr.microsoft.com/dotnet/sdk:11.0

# Tools for git work and for the firewall script
RUN apt-get update && apt-get install -y --no-install-recommends \
    git sudo curl jq iptables ipset iproute2 dnsutils aggregate \
    && rm -rf /var/lib/apt/lists/*

# Claude Code refuses to skip permissions as root, so it runs as this user.
# The base image's ubuntu user holds UID 1000, which the Dev Containers CLI
# needs free to give claude the same UID as the owner of your repo on the host.
RUN userdel --remove ubuntu \
    && useradd --create-home --shell /bin/bash claude \
    && mkdir -p /workspace /home/claude/.claude \
    && chown -R claude:claude /workspace /home/claude/.claude

# The firewall runs as root at container start, and that is all claude can sudo
COPY init-firewall.sh /usr/local/bin/init-firewall.sh
RUN chmod +x /usr/local/bin/init-firewall.sh \
    && echo "claude ALL=(root) NOPASSWD: /usr/local/bin/init-firewall.sh" > /etc/sudoers.d/claude-firewall \
    && chmod 0440 /etc/sudoers.d/claude-firewall

USER claude
RUN curl -fsSL https://claude.ai/install.sh | bash
ENV PATH="/home/claude/.local/bin:${PATH}"
WORKDIR /workspace
