-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
87 lines (67 loc) · 2.58 KB
/
Dockerfile
File metadata and controls
87 lines (67 loc) · 2.58 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
FROM python:3.12-slim AS builder
# Build stage - install dependencies
WORKDIR /build
# Copy requirements first for better caching
COPY requirements.txt .
# Install dependencies to user site-packages
RUN pip install --no-cache-dir --user -r requirements.txt
# Final stage - minimal runtime image
FROM python:3.12-slim
ENV LANG=C.UTF-8
ENV LC_ALL=C.UTF-8
LABEL org.opencontainers.image.title="OctoGen" \
org.opencontainers.image.description="AI-Powered Music Discovery Engine for Navidrome" \
org.opencontainers.image.authors="OctoGen Contributors" \
org.opencontainers.image.url="https://github.com/Blueion76/Octogen" \
org.opencontainers.image.source="https://github.com/Blueion76/Octogen" \
org.opencontainers.image.documentation="https://github.com/Blueion76/Octogen/blob/main/README.md" \
org.opencontainers.image.licenses="MIT"
# Install only essential runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
curl \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# Copy Python packages from builder stage
COPY --from=builder /root/.local /root/.local
# Add local bin to PATH
ENV PATH=/root/.local/bin:$PATH
# Set working directory
WORKDIR /app
# Copy application code
COPY *.py .
COPY octogen/ octogen/
COPY config/ /config/
# Create data directory with proper permissions
RUN mkdir -p /data && chmod 755 /data
# Environment variables with sensible defaults
ENV OCTOGEN_DATA_DIR=/data \
LOG_LEVEL=INFO \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
AI_BACKEND=gemini \
AI_MODEL=gemini-2.5-flash \
AI_BASE_URL=https://generativelanguage.googleapis.com/v1beta/openai/ \
METRICS_ENABLED=true \
METRICS_PORT=9090 \
WEB_ENABLED=true \
WEB_PORT=5000
# Health check - verifies log file exists and was updated recently
HEALTHCHECK --interval=5m --timeout=30s --start-period=30s --retries=3 \
CMD python3 -c "import json, sys, os; \
from pathlib import Path; \
health = json.loads(Path(os.getenv('OCTOGEN_DATA_DIR', '/data'), 'health.json').read_text()); \
sys.exit(0 if health['status'] in ['healthy', 'running', 'scheduled'] else 1)" \
|| exit 1
# Expose ports
EXPOSE 9090 5000
# Port 9090: Prometheus metrics
# Port 5000: Web UI dashboard
# Expose data and config volumes
VOLUME ["/data", "/config"]
# Run as non-root user for security (optional - uncomment if desired)
# RUN useradd -m -u 1000 octogen && \
# chown -R octogen:octogen /app /data
# USER octogen
# Default command - use modular entry point
CMD ["python", "-u", "-m", "octogen.main"]