forked from Mirrowel/LLM-API-Key-Proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
52 lines (36 loc) · 1.43 KB
/
Dockerfile
File metadata and controls
52 lines (36 loc) · 1.43 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
49
50
51
52
# Build stage
FROM python:3.12-slim AS builder
WORKDIR /app
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
&& rm -rf /var/lib/apt/lists/*
# Set PATH for user-installed packages in builder stage
ENV PATH=/root/.local/bin:$PATH
# Copy requirements first for better caching
COPY requirements.txt .
# Copy the local rotator_library for editable install
COPY src/rotator_library ./src/rotator_library
# Install dependencies
RUN pip install --no-cache-dir --user -r requirements.txt
# Production stage
FROM python:3.12-slim
WORKDIR /app
# Copy installed packages from builder
COPY --from=builder /root/.local /root/.local
# Make sure scripts in .local are usable
ENV PATH=/root/.local/bin:$PATH
# Copy application code
COPY src/ ./src/
# Create directories for logs and oauth credentials
RUN mkdir -p logs oauth_creds
# Configure interactive shell: auto-launch TUI + alias
RUN printf '\n# TUI shortcut\nalias tui="python src/proxy_app/main.py"\n\n# Auto-launch TUI on interactive terminal (skip with SKIP_TUI=1)\nif [ -z "$SKIP_TUI" ] && [[ $- == *i* ]] && [ -t 0 ]; then\n exec python src/proxy_app/main.py\nfi\n' >> /root/.bashrc
# Expose the default port
EXPOSE 8000
# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONPATH=/app/src
# Default command - runs proxy with the correct PYTHONPATH
CMD ["python", "src/proxy_app/main.py", "--port", "8000"]