FROM ubuntu:22.04

# Avoid tzdata interactive prompt during package installation
ENV DEBIAN_FRONTEND=noninteractive

# Install System Requirements
RUN apt-get update && \
    apt-get install -y \
    python3 \
    python3-pip \
    gcc \
    make \
    && rm -rf /var/lib/apt/lists/*

# Set up working directory
WORKDIR /vlsi-soc-artifact

# Copy necessary files and directories into the container
COPY FreeRTOS/ FreeRTOS/

COPY gen/config gen/config
COPY gen/templates gen/templates
COPY gen/generate.py gen/generate.py
COPY gen/requirements.txt gen/requirements.txt

COPY include/ include/

COPY src/ src/

COPY Makefile .

# Install dependencies
RUN pip3 install --no-cache-dir -r gen/requirements.txt

# Generate the C code
RUN python3 gen/generate.py -c gen/config/configuration.json -o .

# Build the executable
RUN make -j

# Run the demo by default
CMD ["./build/demo"]
