# finish.sh Docker Image
FROM ubuntu:22.04

LABEL maintainer="finish contributors"
LABEL description="LLM-powered command-line autocompletion with LM-Studio integration"
LABEL version="0.5.0"

# Prevent interactive prompts during installation
ENV DEBIAN_FRONTEND=noninteractive

# Install dependencies
RUN apt-get update && \
    apt-get install -y \
    bash \
    bash-completion \
    curl \
    wget \
    jq \
    bc \
    vim \
    git \
    && apt-get clean && \
    rm -rf /var/lib/apt/lists/*

# Create application directory
WORKDIR /opt/finish

# Copy application files
COPY src/finish.sh /usr/bin/finish
COPY README.md LICENSE ./

# Make script executable
RUN chmod +x /usr/bin/finish

# Create finish directory
RUN mkdir -p /root/.finish

# Source bash-completion in .bashrc
RUN echo "" >> /root/.bashrc && \
    echo "# Bash completion" >> /root/.bashrc && \
    echo "if [ -f /etc/bash_completion ] && ! shopt -oq posix; then" >> /root/.bashrc && \
    echo "    . /etc/bash_completion" >> /root/.bashrc && \
    echo "fi" >> /root/.bashrc

# Set working directory to home
WORKDIR /root

# Set entrypoint to bash
ENTRYPOINT ["/bin/bash"]

# Default command shows help
CMD ["-c", "echo 'finish.sh Docker Container' && echo '' && finish --help && exec /bin/bash"]