# Use an official Ubuntu as a base image
FROM ubuntu:latest

# Set environment variables to avoid interactive prompts during package installation
ENV DEBIAN_FRONTEND=noninteractive

# Update the package list and install required packages
RUN apt-get update -y && \
    apt-get install -y \
    gcc \
    make \
    libreadline-dev \
    libncurses5-dev \
    libcurl4-openssl-dev \
    libssl-dev \
    libjson-c-dev \
    libsqlite3-dev \
    python3-dev \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

RUN mkdir /r
# Set the working directory
WORKDIR /r

# Copy the source files into the container
COPY . .

# Build the application
RUN make build

RUN cp r /usr/local/bin/r

WORKDIR /app

# Command to run the application (optional, can be overridden)
CMD ["r", "--verbose"]