FROM mcr.microsoft.com/devcontainers/base:jammy


ENV DEBIAN_FRONTEND=noninteractive

# Base packages
RUN apt-get update && apt-get install -y \
    curl \
    wget \
    git \
    python3 \
    python3-pip \
    jq \
    ca-certificates \
    software-properties-common \
    rclone \
    rsync \
    iputils-ping \
    dnsutils \
    iproute2 \
    traceroute \
    mtr \
    netcat-openbsd \
    nmap \
    apache2-utils \
    mariadb-client \
    age \
    && rm -rf /var/lib/apt/lists/*



# --- Install pip modules ---
RUN pip3 install --upgrade pip \
    && pip3 install \
    ansible \
    pyyaml


# --- Install kubectl ---
RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" \
    && install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl \
    && rm kubectl

# --- Install Helm ---
RUN curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash

# --- Install yq ---
RUN wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 \
    -O /usr/bin/yq && chmod +x /usr/bin/yq

# --- Install Node.js (LTS) ---
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
    && apt-get install -y nodejs \
    && npm install -g npm@latest

# --- Install act (GitHub Actions local runner) ---
RUN mkdir /tmp/act \
    && curl -s https://api.github.com/repos/nektos/act/releases/latest \
    | grep "browser_download_url.*act_Linux_x86_64.tar.gz" \
    | cut -d '"' -f 4 \
    | wget -O /tmp/act/act.tar.gz -i - \
    && tar -xzf /tmp/act/act.tar.gz -C /tmp/act \
    && install -m 0755 /tmp/act/act /usr/local/bin/act \
    && rm -r /tmp/act 

# ---zsh plugins ---
RUN git clone https://github.com/zdharma-continuum/fast-syntax-highlighting.git /home/vscode/.oh-my-zsh/custom/plugins/fast-syntax-highlighting
RUN git clone https://github.com/zsh-users/zsh-autosuggestions /home/vscode/.oh-my-zsh/custom/plugins/zsh-autosuggestions

# -- install chroma for zsh
RUN mkdir /tmp/chroma \
    && curl -s https://api.github.com/repos/alecthomas/chroma/releases/latest \
    | grep "browser_download_url.*linux-amd64.*tar.gz" \
    | cut -d '"' -f 4 \
    | wget -O /tmp/chroma/chroma.tar.gz -i - \
    && tar -xzf /tmp/chroma/chroma.tar.gz -C /tmp/chroma \
    && install -m 0755 /tmp/chroma/chroma /usr/local/bin/chroma \ 
    && rm -r /tmp/chroma 

# --- set zsh shell as default ---
RUN chsh -s /usr/bin/zsh vscode

# --- copy assets ---
COPY ./assets/.zshrc /home/vscode


#----- buildctl
ENV BUILDKIT_VERSION=v0.29.0

RUN curl -L -o /tmp/buildkit.tar.gz \
      "https://github.com/moby/buildkit/releases/download/${BUILDKIT_VERSION}/buildkit-${BUILDKIT_VERSION}.linux-amd64.tar.gz" \
    && tar -xzf /tmp/buildkit.tar.gz -C /usr/local/bin --strip-components=1 bin/ \
    && rm /tmp/buildkit.tar.gz


RUN curl -s https://fluxcd.io/install.sh | bash


#----- SOPS
ENV SOPS_VERSION=3.13.1

RUN wget "https://github.com/getsops/sops/releases/download/v${SOPS_VERSION}/sops-v${SOPS_VERSION}.linux.amd64" -O /tmp/sops

RUN cp /tmp/sops /usr/local/bin/sops
RUN chmod +x /usr/local/bin/sops



