mirror of
https://github.com/nirvana-7777/script.service.ultimate.git
synced 2026-10-28 01:32:39 +01:00
Dockerize addon
This commit is contained in:
+18
-63
@@ -1,7 +1,7 @@
|
||||
# Ultimate Backend Streaming Service - Kodi addon in standalone Docker mode
|
||||
FROM python:3.11-slim
|
||||
|
||||
# Build arguments for user/group configuration
|
||||
# Build arguments
|
||||
ARG USER_ID=1000
|
||||
ARG GROUP_ID=1000
|
||||
ARG APP_USER=ultimate
|
||||
@@ -14,9 +14,7 @@ ENV PYTHONUNBUFFERED=1 \
|
||||
ULTIMATE_PORT=7777 \
|
||||
ULTIMATE_COUNTRY=DE \
|
||||
ULTIMATE_DEBUG=false \
|
||||
PYTHONPATH=${APP_HOME}/lib:$PYTHONPATH \
|
||||
HOME=/home/${APP_USER} \
|
||||
PATH=/home/${APP_USER}/.local/bin:$PATH
|
||||
PYTHONPATH=${APP_HOME}/lib:$PYTHONPATH
|
||||
|
||||
# Install system dependencies
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
@@ -31,91 +29,48 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
curl \
|
||||
ca-certificates \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||
|
||||
# Create application user and group with configurable UID/GID
|
||||
RUN groupadd -g ${GROUP_ID} ${APP_USER} && \
|
||||
useradd -u ${USER_ID} -g ${APP_USER} -m -s /bin/bash ${APP_USER}
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Set working directory
|
||||
WORKDIR ${APP_HOME}
|
||||
|
||||
# Copy requirements first for better caching
|
||||
COPY requirements.txt /tmp/requirements.txt
|
||||
# Copy requirements.txt first for better caching
|
||||
COPY requirements.txt .
|
||||
|
||||
# Install Python dependencies
|
||||
# If requirements.txt exists, use it. Otherwise install defaults.
|
||||
RUN if [ -f /tmp/requirements.txt ]; then \
|
||||
echo "Installing from requirements.txt..." && \
|
||||
pip install --no-cache-dir --upgrade pip && \
|
||||
pip install --no-cache-dir -r /tmp/requirements.txt; \
|
||||
else \
|
||||
echo "No requirements.txt found, installing default packages..." && \
|
||||
pip install --no-cache-dir --upgrade pip && \
|
||||
pip install --no-cache-dir \
|
||||
bottle>=0.12.25 \
|
||||
requests>=2.31.0 \
|
||||
lxml>=4.9.3 \
|
||||
defusedxml>=0.7.1 \
|
||||
m3u8>=4.0.0 \
|
||||
iso8601>=1.1.0 \
|
||||
pycountry>=23.12.11 \
|
||||
python-dateutil>=2.8.2 \
|
||||
urllib3>=2.0.7 \
|
||||
chardet>=5.2.0 \
|
||||
pycryptodome>=3.19.0 \
|
||||
cryptography>=41.0.0; \
|
||||
fi
|
||||
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}
|
||||
|
||||
# Copy application code
|
||||
COPY --chown=${USER_ID}:${GROUP_ID} . ${APP_HOME}/
|
||||
COPY --chown=${USER_ID}:${GROUP_ID} . .
|
||||
|
||||
# Create necessary directories
|
||||
# Create directories
|
||||
RUN mkdir -p /config /logs /cache && \
|
||||
chown -R ${USER_ID}:${GROUP_ID} /config /logs /cache
|
||||
|
||||
# Create a requirements.txt if it doesn't exist (for documentation)
|
||||
RUN if [ ! -f requirements.txt ]; then \
|
||||
echo "# Ultimate Backend Service Requirements" > requirements.txt && \
|
||||
echo "# Auto-generated for documentation" >> requirements.txt && \
|
||||
echo "" >> requirements.txt && \
|
||||
echo "bottle>=0.12.25" >> requirements.txt && \
|
||||
echo "requests>=2.31.0" >> requirements.txt && \
|
||||
echo "lxml>=4.9.3" >> requirements.txt && \
|
||||
echo "defusedxml>=0.7.1" >> requirements.txt && \
|
||||
echo "m3u8>=4.0.0" >> requirements.txt && \
|
||||
echo "iso8601>=1.1.0" >> requirements.txt && \
|
||||
echo "pycountry>=23.12.11" >> requirements.txt && \
|
||||
echo "python-dateutil>=2.8.2" >> requirements.txt && \
|
||||
echo "urllib3>=2.0.7" >> requirements.txt && \
|
||||
echo "chardet>=5.2.0" >> requirements.txt && \
|
||||
echo "pycryptodome>=3.19.0" >> requirements.txt && \
|
||||
echo "cryptography>=41.0.0" >> requirements.txt; \
|
||||
fi
|
||||
|
||||
# Switch to non-root user
|
||||
USER ${USER_ID}
|
||||
|
||||
# Create default config if not provided
|
||||
# Create default config
|
||||
RUN if [ ! -f /config/config.json ]; then \
|
||||
echo '{"default_country": "DE", "server_port": 7777, "debug_mode": false}' > /config/config.json; \
|
||||
fi
|
||||
|
||||
# Expose the service port
|
||||
# Expose port
|
||||
EXPOSE ${ULTIMATE_PORT}
|
||||
|
||||
# Health check
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
|
||||
CMD curl -f http://localhost:${ULTIMATE_PORT}/api/providers || exit 1
|
||||
|
||||
# Labels for better image metadata
|
||||
# Labels
|
||||
LABEL maintainer="nirvana-7777" \
|
||||
description="Ultimate Backend Streaming Service" \
|
||||
version="1.0.0" \
|
||||
org.opencontainers.image.source="https://github.com/nirvana-7777/script.service.ultimate"
|
||||
description="Ultimate Backend Streaming Service"
|
||||
|
||||
# Run in standalone mode (since Kodi isn't available in Docker)
|
||||
# Entrypoint
|
||||
ENTRYPOINT ["python", "/app/service.py"]
|
||||
|
||||
# Default command with configurable options
|
||||
CMD ["--standalone", "--config-dir", "/config"]
|
||||
Reference in New Issue
Block a user