# Start from the official Playwright image (Ubuntu Noble)
# This includes Node.js, Playwright browsers, and dependencies required for agent-browser.
FROM mcr.microsoft.com/playwright:v1.58.0-noble

# Set the working directory
WORKDIR /datapallas

# Install essential utilities + Java/Maven for project compilation
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
    curl \
    wget \
    git \
    ripgrep \
    jq \
    file \
    sed \
    gawk \
    findutils \
    grep \
    ca-certificates \
    build-essential \
    python3 \
    python3-pip \
    python3-dev \
    python3-venv \
    python-is-python3 \
    openjdk-17-jdk \
    && rm -rf /var/lib/apt/lists/*

# Install Maven 3.9.9
RUN wget https://archive.apache.org/dist/maven/maven-3/3.9.9/binaries/apache-maven-3.9.9-bin.tar.gz \
    && tar -xzf apache-maven-3.9.9-bin.tar.gz -C /opt \
    && ln -s /opt/apache-maven-3.9.9 /opt/maven \
    && ln -s /opt/maven/bin/mvn /usr/local/bin/mvn \
    && rm apache-maven-3.9.9-bin.tar.gz

# Set Java and Maven environment variables
ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
ENV MAVEN_HOME=/opt/maven
ENV PATH="${MAVEN_HOME}/bin:${PATH}"

# Install code-server
RUN curl -fsSL https://code-server.dev/install.sh | sh

# Install Node.js global packages
RUN npm install -g \
    @anthropic-ai/claude-code \
    @musistudio/claude-code-router \
    agent-browser \
    && npm cache clean --force

# Install VS Code extensions
# https://open-vsx.org (only extensions available here work)

# Claude Code
RUN code-server --install-extension Anthropic.claude-code

# General
RUN code-server --install-extension dbaeumer.vscode-eslint
RUN code-server --install-extension humao.rest-client
RUN code-server --install-extension emmanuelbeziat.vscode-great-icons

# Java/Maven/Python development
RUN code-server --install-extension vscjava.vscode-java-pack
#RUN code-server --install-extension ms-python.python

RUN code-server --install-extension jebbs.plantuml

# Org Mode
RUN code-server --install-extension realDestroyer.org-vscode

RUN code-server --install-extension RooVeterinaryInc.roo-cline

# Commented out (uncomment if needed)
# RUN code-server --install-extension Gruntfuggly.todo-tree
# RUN code-server --install-extension tootone.org-mode

# Expose port for code-server
EXPOSE 8443

# Start code-server
CMD ["code-server", "--bind-addr", "0.0.0.0:8443", "--auth", "none"]