FROM debian:trixie

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get install -y \
    build-essential \
    clang \
    flex \
    bison \
    g++ \
    gawk \
    gettext \
    git \
    libncurses-dev \
    libssl-dev \
    python3 \
    rsync \
    unzip \
    zlib1g-dev \
    file \
    wget \
    patch \
    time \
    sudo \
    locales \
    && apt-get clean && rm -rf /var/lib/apt/lists/*

RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen

ENV LANG=en_US.UTF-8
ENV LC_ALL=en_US.UTF-8

RUN adduser openwrt --disabled-password --gecos "" && \
    echo "openwrt ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers

USER openwrt
WORKDIR /home/openwrt

RUN git clone https://github.com/openwrt/openwrt.git && \
    mkdir -p /home/openwrt/openwrt/package/OpenUniFi

WORKDIR /home/openwrt/openwrt/package/OpenUniFi