Add Dockerfile and .dockerignore.
This commit is contained in:
+35
@@ -0,0 +1,35 @@
|
||||
FROM python:3.12-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install system dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
build-essential \
|
||||
git \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Copy requirements first for better caching
|
||||
COPY requirements.txt .
|
||||
|
||||
# Install Python dependencies
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
# Cache the model
|
||||
RUN python -c "from gliner import GLiNER; GLiNER.from_pretrained('knowledgator/gliner-multitask-large-v0.5', save_path='/app/model')"
|
||||
|
||||
# Copy all project files
|
||||
COPY . .
|
||||
|
||||
# Environment variables with defaults
|
||||
ENV PORT=8000
|
||||
ENV MODEL_NAME=knowledgator/gliner-multitask-large-v0.5
|
||||
ENV MAX_TEXT_LENGTH=10000
|
||||
|
||||
# Expose port
|
||||
EXPOSE ${PORT}
|
||||
|
||||
# Health check
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=120s --retries=3 \
|
||||
CMD python -c "import requests; requests.get('http://localhost:${PORT}/health')"
|
||||
|
||||
# Run the application
|
||||
CMD uvicorn gliner_inference_server.main:app --host 0.0.0.0 --port ${PORT}
|
||||
Reference in New Issue
Block a user