# Use Ubuntu 24.04 as base (matching development environment)
FROM ubuntu:24.04

# Avoid interactive prompts during package installation
ENV DEBIAN_FRONTEND=noninteractive

# Install dependencies
# - build-essential: Compiler (gcc/g++)
# - meson/ninja-build: Build system
# - git: For fetching subprojects
# - pkg-config, cmake: For dependency resolution
# - libssl-dev: Often needed for cmake fetches/networking
RUN apt-get update && apt-get install -y \
    build-essential \
    meson \
    ninja-build \
    git \
    pkg-config \
    cmake \
    ca-certificates \
    libunwind-dev \
    && rm -rf /var/lib/apt/lists/*

# Set working directory
WORKDIR /app

# Copy project files
COPY . .

# Setup build directory and compile
# We allow git to fetch subprojects (glog, gtest, asio, etc.)
RUN meson setup build && \
    meson compile -C build

# Run the cli by default
# We assume the config.yaml is in the root /app or we copy it. 
# The build output is in build/src/cloud_point_rpc_cli
CMD ["./build/src/cloud_point_rpc_cli", "config.yaml"]
