FROM debian:trixie-slim

# Install necessary runtime dependencies for the shared library
RUN apt-get update && apt-get install -y \
    ca-certificates \
    libgcc-s1 \
    libstdc++6 \
    && rm -rf /var/lib/apt/lists/*

# Copy the nextgen metering server binary
COPY nextgen-metering-server /usr/local/bin/nextgen-metering-server

# Copy the delta-rs-golang shared library
COPY libdeltalake_golang.so /usr/local/lib/libdeltalake_golang.so

# Copy entrypoint script
COPY entrypoint.sh /usr/local/bin/entrypoint.sh

# Copy optional extensions (e.g., DuckDB extension)
RUN mkdir -p /ops/extension
COPY ops/ /ops/
RUN rm -f /ops/.gitkeep

# Set library path to include /usr/local/lib
ENV LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

# Make scripts executable
RUN chmod +x /usr/local/bin/nextgen-metering-server && \
    chmod +x /usr/local/bin/entrypoint.sh

ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]