Spaces:
Sleeping
Sleeping
File size: 915 Bytes
d2ba52b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
FROM ollama/ollama:0.9.2
# Install Python and dependencies with security updates
RUN apt-get update && apt-get install -y \
python3 \
python3-pip \
curl \
&& apt-get upgrade -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Create non-root user for security
RUN groupadd -r appuser && useradd -r -g appuser appuser
# Set working directory
WORKDIR /app
# Copy requirements and install Python packages
COPY requirements.txt .
RUN pip3 install --no-cache-dir -r requirements.txt
# Copy your FastAPI app
COPY fast.py .
COPY start.sh .
RUN chmod +x start.sh
# Change ownership to non-root user
RUN chown -R appuser:appuser /app
# Set environment variables
ENV OLLAMA_HOST=0.0.0.0:11434
ENV OLLAMA_ORIGINS=*
# Expose ports
EXPOSE 7860
EXPOSE 11434
# Switch to non-root user
USER appuser
# Start both Ollama and FastAPI
ENTRYPOINT []
CMD ["bash", "/app/start.sh"] |