# Define the image argument and provide a default value ARG IMAGE=python:3-slim-bullseye # Use the image as specified FROM ${IMAGE} # Re-declare the ARG after FROM ARG IMAGE # Update and upgrade the existing packages RUN apt-get update && apt-get upgrade -y && apt-get install -y --no-install-recommends \ python3 \ python3-pip \ ninja-build \ libmariadb-dev-compat \ libmariadb-dev \ build-essential \ pkg-config WORKDIR /app COPY . . # Set up a new user named "user" with user ID 1000 RUN useradd -u 1000 user #RUN useradd -ms /bin/bash user #RUN addgroup -g 1001 -S 1000 #RUN adduser -u 1001 -S 1000 -G 1000 # Set environment variable for the host ENV HOST=0.0.0.0 ENV PORT=7860 ENV ORIGINS=* ENV TF_ENABLE_ONEDNN_OPTS=0 # Switch to the "user" user USER user # Set home to the user's home directory RUN python3 -m pip install --upgrade pip # Install requirements.txt RUN pip install --no-cache-dir --upgrade -r requirements.txt ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH/app RUN export MYSQLCLIENT_CFLAGS=`pkg-config mysqlclient --cflags` RUN export MYSQLCLIENT_LDFLAGS=`pkg-config mysqlclient --libs` # Set the working directory to the user's home directory #WORKDIR $HOME/app RUN chmod -R 755 $HOME/app # Copy the current directory contents into the container at $HOME/app setting the owner to the user COPY --chown=user . $HOME/app #CMD ["python3", "-m", "app"] # Start the FastAPI app on port 7860, the default port expected by Spaces CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"] #ENTRYPOINT ["python3", "-m", "llama_cpp.server", "--hf_model_repo_id", "Qwen/Qwen1.5-0.5B-Chat-GGUF", "--model", "*q4_0.gguf", "--host", "0.0.0.0"]