# Enduro/X (open-source Tuxedo/ATMI) + ECPG/PostgreSQL client — runnable builder image
FROM debian:12

ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update -qq && apt-get install -y -qq \
      build-essential cmake flex bison git \
      libxml2-dev libssl-dev uuid-dev libgpgme-dev \
      libecpg-dev libpq-dev postgresql-server-dev-all \
      postgresql-client \
      procps net-tools vim-tiny ca-certificates curl \
    && rm -rf /var/lib/apt/lists/*

# --- build Enduro/X core from source (tag 7.0.12) ---
WORKDIR /opt
RUN git clone --depth 1 --branch 7.0.12 https://github.com/endurox-dev/endurox /opt/endurox-src
WORKDIR /opt/endurox-src
# atmitest 서브디렉터리는 생성헤더(t40.h 등) 의존으로 코어 빌드를 깨뜨려 제외 (DISABLETEST가 실제 제외 안 함)
RUN sed -i -E '/add_subdirectory *\(atmitest/d' CMakeLists.txt
RUN cmake -DDEFINE_DISABLEDOC=ON -DDEFINE_DISABLETEST=ON -DENABLE_POSTGRES=ON -DCMAKE_INSTALL_PREFIX=/usr/local . \
    && make -j"$(nproc)" \
    && make install \
    && ldconfig
# runtime env defaults
ENV NDRX_HOME=/usr/local PATH=/usr/local/bin:$PATH LD_LIBRARY_PATH=/usr/local/lib
WORKDIR /app
CMD ["bash"]
