llm / Dockerfile
KunalThakare279's picture
Update Dockerfile
af81c82 verified
raw
history blame
1.04 kB
FROM docker.io/library/python:3.10-slim@sha256:80619a5316afae7045a3c13371b0ee670f39bac46ea1ed35081d2bf91d6c3dbd
# Create a group and user
RUN addgroup --system appgroup && adduser --system --ingroup appgroup appuser
# Set the working directory
WORKDIR /app
# Copy the application files
COPY . .
RUN mkdir -p /app/huggingface && chmod 777 /app/huggingface
# Set the environment variable to point to the app directory
ENV HF_HOME=/app/huggingface
USER root
# Install Python dependencies
RUN pip install huggingface_hub
ARG read
RUN huggingface-cli login --token $read
RUN python -c "from transformers import pipeline; pipeline('text-generation', model='mistralai/Mistral-7B-v0.1', tokenizer='mistralai/Mistral-7B-v0.1')"
RUN pip install --no-cache-dir -r requirements.txt
# Set ownership of the application directory
RUN chown -R appuser:appgroup /app
# Switch to the non-root user
USER appuser
# Expose the port
EXPOSE 8000
# Run the application
ENTRYPOINT ["gunicorn", "app:app"]
CMD ["-b", "0.0.0.0:7860", "--workers=1"]