FROM python:3.11.10-bullseye


ARG USER=vscode
ARG DEBIAN_FRONTEND=noninteractive

# 1) Toolchain + utilities for building libpostal
RUN apt-get update && apt-get install -y --no-install-recommends \
    sudo jq vim curl git ca-certificates \
    build-essential pkg-config automake autoconf libtool \
 && rm -rf /var/lib/apt/lists/*

# # 2) Build and install libpostal from source
RUN git clone --depth 1 https://github.com/openvenues/libpostal /tmp/libpostal \
 && cd /tmp/libpostal \
 && ./bootstrap.sh \
 && ./configure --datadir=/usr/local/share/libpostal \
 && make -j"$(nproc)" \
 && make install \
 && ldconfig \
 && rm -rf /tmp/libpostal

# 3) Create the user and grant sudo privileges
RUN useradd -m -s /bin/bash ${USER} \
 && echo "${USER} ALL=(ALL) NOPASSWD: ALL" >/etc/sudoers.d/${USER} \
 && chmod 0440 /etc/sudoers.d/${USER}

# # 4) Python deps - if you want to run assest list
ENV PIP_NO_CACHE_DIR=1 PIP_DISABLE_PIP_VERSION_CHECK=1
ADD .devcontainer/asset_list/requirements.txt requirements2.txt
ADD asset_list/requirements.txt requirements1.txt
RUN cat requirements1.txt requirements2.txt >> requirements.txt

RUN pip install -r requirements.txt

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


# 5) Workdir
WORKDIR /workspaces/model

# 6) Make Python find your package
# Add project root to PYTHONPATH for all processes
ENV PYTHONPATH=/workspaces/model:${PYTHONPATH}
