-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
48 lines (36 loc) · 1.44 KB
/
Dockerfile
File metadata and controls
48 lines (36 loc) · 1.44 KB
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
44
45
46
47
48
# Align container Python version with project requirement
FROM python:3.13-slim-bookworm
# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV PORT=7860
# Install minimal system dependencies
RUN apt-get update && apt-get install -y \
curl \
ffmpeg \
&& rm -rf /var/lib/apt/lists/*
# Create app directory
WORKDIR /app
# Copy dependency files first for better caching
COPY requirements.txt requirements-docker.txt pyproject.toml ./
# Upgrade pip first
RUN pip install --upgrade pip
# Preinstall heavy dependencies to avoid resolver issues
RUN pip install --no-cache-dir --no-deps torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
# Install application requirements (includes inferedge-moss and friends)
RUN pip install --no-cache-dir -r requirements-docker.txt -r requirements.txt
# Pre-download required NLTK data into a shared location
RUN mkdir -p /usr/share/nltk_data \
&& python -c "import nltk; nltk.download('punkt', download_dir='/usr/share/nltk_data'); nltk.download('punkt_tab', download_dir='/usr/share/nltk_data')"
# Copy application files
COPY . .
# Create a non-root user for security with writable home
RUN groupadd -r appuser && useradd -r -g appuser -m appuser
RUN chown -R appuser:appuser /app /usr/share/nltk_data
ENV HOME=/home/appuser
ENV NLTK_DATA=/usr/share/nltk_data
USER appuser
# Expose the port
EXPOSE 7860
# Start the application
CMD ["python", "bot-gemini.py"]