Files
script.service.ultimate/Dockerfile
T

100 lines
2.9 KiB
Docker
Raw Normal View History

2025-12-10 14:04:39 +01:00
# Ultimate Backend Streaming Service - Kodi addon in standalone Docker mode
2025-12-10 13:56:11 +01:00
FROM python:3.11-slim
2025-12-10 16:04:27 +01:00
# Build arguments
2025-12-10 14:04:39 +01:00
ARG USER_ID=1000
ARG GROUP_ID=1000
ARG APP_USER=ultimate
ARG APP_HOME=/app
# Environment variables
2025-12-10 13:56:11 +01:00
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
TZ=UTC \
ULTIMATE_PORT=7777 \
ULTIMATE_COUNTRY=DE \
2025-12-10 14:04:39 +01:00
ULTIMATE_DEBUG=false \
2025-12-10 16:39:17 +01:00
PYTHONPATH=${APP_HOME}/lib:${PYTHONPATH}
2025-12-10 13:56:11 +01:00
# Install system dependencies
2025-12-10 14:04:39 +01:00
RUN apt-get update && apt-get install -y --no-install-recommends \
2025-12-10 13:56:11 +01:00
gcc \
g++ \
libxml2-dev \
libxslt-dev \
libffi-dev \
libssl-dev \
libxmlsec1-dev \
pkg-config \
curl \
2025-12-10 14:04:39 +01:00
ca-certificates \
&& apt-get clean \
2025-12-10 16:04:27 +01:00
&& rm -rf /var/lib/apt/lists/*
2025-12-10 13:56:11 +01:00
# Set working directory
2025-12-10 14:04:39 +01:00
WORKDIR ${APP_HOME}
2025-12-10 13:56:11 +01:00
2025-12-10 16:04:27 +01:00
# Copy requirements.txt first for better caching
COPY requirements.txt .
2025-12-10 13:56:11 +01:00
2025-12-10 14:04:39 +01:00
# Install Python dependencies
2025-12-10 16:04:27 +01:00
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# Create user
RUN groupadd -g ${GROUP_ID} ${APP_USER} && \
useradd -u ${USER_ID} -g ${APP_USER} -m -s /bin/bash ${APP_USER}
2025-12-10 13:56:11 +01:00
2025-12-10 14:04:39 +01:00
# Copy application code
2025-12-10 16:04:27 +01:00
COPY --chown=${USER_ID}:${GROUP_ID} . .
2025-12-10 13:56:11 +01:00
2025-12-10 16:27:58 +01:00
# Debug: Show Python path and test import
RUN echo "Testing imports..." && \
python3 -c "import sys; print('Python path:', sys.path)" && \
2025-12-10 16:39:17 +01:00
python3 -c "\
import sys;\n\
sys.path.insert(0, '/app/lib');\n\
try:\n\
import streaming_providers;\n\
print('✓ streaming_providers import successful');\n\
except ImportError as e:\n\
print('✗ streaming_providers import failed:', e);\n\
import os;\n\
print('lib exists:', os.path.exists('/app/lib'));\n\
print('lib/streaming_providers exists:', os.path.exists('/app/lib/streaming_providers'));\n\
print('lib/streaming_providers/__init__.py exists:', os.path.exists('/app/lib/streaming_providers/__init__.py'));\n\
print('Files in lib:', os.listdir('/app/lib') if os.path.exists('/app/lib') else 'lib not found');"
2025-12-10 16:27:58 +01:00
2025-12-10 16:04:27 +01:00
# Create directories
2025-12-10 14:04:39 +01:00
RUN mkdir -p /config /logs /cache && \
chown -R ${USER_ID}:${GROUP_ID} /config /logs /cache
# Switch to non-root user
USER ${USER_ID}
2025-12-10 16:04:27 +01:00
# Create default config
2025-12-10 14:04:39 +01:00
RUN if [ ! -f /config/config.json ]; then \
echo '{"default_country": "DE", "server_port": 7777, "debug_mode": false}' > /config/config.json; \
fi
2025-12-10 13:56:11 +01:00
2025-12-10 16:04:27 +01:00
# Expose port
2025-12-10 13:56:11 +01:00
EXPOSE ${ULTIMATE_PORT}
# Health check
2025-12-10 14:04:39 +01:00
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
2025-12-10 13:56:11 +01:00
CMD curl -f http://localhost:${ULTIMATE_PORT}/api/providers || exit 1
2025-12-10 16:04:27 +01:00
# Labels
2025-12-10 14:04:39 +01:00
LABEL maintainer="nirvana-7777" \
2025-12-10 16:04:27 +01:00
description="Ultimate Backend Streaming Service"
2025-12-10 14:04:39 +01:00
2025-12-10 16:39:17 +01:00
# Create a simple wrapper script to set up Python path
RUN echo '#!/bin/bash\n\
export PYTHONPATH="/app/lib:${PYTHONPATH}"\n\
cd /app\n\
python service.py "$@"' > /app/entrypoint.sh && \
chmod +x /app/entrypoint.sh
# Use the wrapper script as entrypoint
ENTRYPOINT ["/app/entrypoint.sh"]
2025-12-10 13:56:11 +01:00
CMD ["--standalone", "--config-dir", "/config"]