# Use an official Python runtime as a parent image FROM python:3.10-slim-buster # Set the working directory in the container to /app WORKDIR /app # Copy the current directory contents into the container at /app COPY . /app # Install system dependencies required for building sqlite3 and other operations RUN apt-get update && \ apt-get install -y --no-install-recommends git wget build-essential libsqlite3-dev && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* # Download and compile sqlite3 from source RUN wget https://www.sqlite.org/2021/sqlite-autoconf-3350500.tar.gz && \ tar xvfz sqlite-autoconf-3350500.tar.gz && \ cd sqlite-autoconf-3350500 && \ ./configure --prefix=/usr --disable-static CFLAGS="-DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_COLUMN_METADATA=1 -DSQLITE_ENABLE_UNLOCK_NOTIFY=1 -DSQLITE_SECURE_DELETE=1 -DSQLITE_ENABLE_DBSTAT_VTAB=1 -DSQLITE_ENABLE_FTS3_TOKENIZER=1 -DSQLITE_ENABLE_FTS4=1 -DSQLITE_ENABLE_FTS5=1 -DSQLITE_ENABLE_JSON1=1 -DSQLITE_ENABLE_RTREE=1" && \ make && \ make install && \ cd .. && \ rm sqlite-autoconf-3350500.tar.gz && \ rm -rf sqlite-autoconf-3350500 # Verify sqlite3 version RUN sqlite3 --version # Install Python dependencies RUN pip install poetry gradio # Create a non-root user and change ownership of the /app directory RUN adduser --disabled-password --gecos '' myuser && \ chown -R myuser:myuser /app # Switch to the non-root user USER myuser # Expose the port Gradio runs on EXPOSE 7860 RUN chmod +x /app/start.sh # Run the start script when the container launches CMD ["/app/start.sh"]