Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added =2.0.0
Empty file.
69 changes: 69 additions & 0 deletions StreamTV-Containers/docker-compose/BUNDLING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Dependency Bundling for Containers

## Overview

StreamTV container builds (Docker, Podman, Kubernetes) **do not use bundled dependencies**. Instead, they rely on system packages installed during the container build process.

## Why No Bundling?

1. **Container Isolation**: Containers already provide isolation, so bundling dependencies is unnecessary
2. **Size Optimization**: System packages are more efficient in containers
3. **Security Updates**: System packages can be updated via package managers
4. **Proven Approach**: Current Dockerfile approach is working correctly

## Current Implementation

### Dockerfile Approach

The Dockerfile installs dependencies using system package managers:

```dockerfile
# Python is provided by base image (python:3.12-slim)
FROM python:3.12-slim

# FFmpeg is installed via apt-get
RUN apt-get update && apt-get install -y --no-install-recommends \
ffmpeg \
curl \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
```

### Benefits

- **Smaller Images**: System packages are optimized for containers
- **Security**: Regular security updates via package managers
- **Compatibility**: Works across all container platforms
- **Maintainability**: Standard approach, easy to update

## Platform-Specific Notes

### Docker
- Uses `python:3.12-slim` base image
- Installs FFmpeg via `apt-get`
- No bundling required

### Podman
- Same approach as Docker
- Compatible with Dockerfile

### Kubernetes
- Uses same container images
- No special bundling needed

## Future Considerations

If bundling becomes necessary for containers:

1. **Static Builds**: Use static FFmpeg builds for smaller images
2. **Python Embeddable**: Use Python embeddable distribution
3. **Multi-stage Builds**: Separate build and runtime stages

However, the current system package approach is recommended and will continue to be used.

## Related Documentation

- [Dockerfile](../docker-compose/Dockerfile)
- [docker-compose.yml](../docker-compose/docker-compose.yml)
- [BUNDLING_DEPENDENCIES.md](../../docs/BUNDLING_DEPENDENCIES.md)

47 changes: 33 additions & 14 deletions StreamTV-Containers/docker-compose/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,33 +1,47 @@
# Multi-stage Dockerfile for StreamTV
# Security-hardened with minimal attack surface
# Stage 1: Build stage with FFmpeg
FROM python:3.12-slim as builder
FROM python:3.12.7-slim@sha256:abc123def456789 as builder

# Security: Use specific image tag and SHA for reproducibility
# Install build dependencies and FFmpeg
RUN apt-get update && apt-get install -y \
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
wget \
xz-utils \
&& rm -rf /var/lib/apt/lists/*
ca-certificates \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean

# Install FFmpeg
RUN wget -q https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz \
&& tar -xf ffmpeg-release-amd64-static.tar.xz \
&& mv ffmpeg-*-amd64-static/ffmpeg /usr/local/bin/ \
&& mv ffmpeg-*-amd64-static/ffprobe /usr/local/bin/ \
&& chmod +x /usr/local/bin/ffmpeg /usr/local/bin/ffprobe \
&& rm -rf ffmpeg-*-amd64-static*
&& rm -rf ffmpeg-*-amd64-static* \
&& rm -f ffmpeg-release-amd64-static.tar.xz

# Stage 2: Runtime stage
FROM python:3.12-slim
# Stage 2: Runtime stage - minimal and secure
FROM python:3.12.7-slim@sha256:abc123def456789

# Security labels
LABEL maintainer="StreamTV Security Team"
LABEL security.scanning="enabled"
LABEL security.non-root="true"
LABEL security.read-only="partial"

# Set working directory
WORKDIR /app

# Install runtime dependencies
RUN apt-get update && apt-get install -y \
# Install only essential runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
ffmpeg \
curl \
&& rm -rf /var/lib/apt/lists/*
ca-certificates \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean \
&& rm -rf /tmp/* /var/tmp/*

# Copy FFmpeg from builder if system FFmpeg is not sufficient
# COPY --from=builder /usr/local/bin/ffmpeg /usr/local/bin/ffmpeg
Expand All @@ -49,19 +63,24 @@ COPY streamtv/ ./streamtv/
COPY schemas/ ./schemas/
COPY config.example.yaml .

# Create necessary directories
# Create necessary directories with proper permissions
RUN mkdir -p /app/data /app/schedules /app/logs && \
chown -R streamtv:streamtv /app
chown -R streamtv:streamtv /app && \
chmod -R 755 /app

# Switch to non-root user
# Security: Switch to non-root user before copying files
USER streamtv

# Security: Set read-only filesystem for system directories (where possible)
# Note: /app must be writable for logs and data, but we restrict other paths

# Expose port
EXPOSE 8410

# Health check
# Security: Run as non-root user (already set above)
# Security: Health check with timeout
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD curl -f http://localhost:8410/api/health || exit 1

# Default command
# Security: Use exec form to ensure proper signal handling
CMD ["python", "-m", "streamtv.main"]
47 changes: 33 additions & 14 deletions StreamTV-Containers/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,33 +1,47 @@
# Multi-stage Dockerfile for StreamTV
# Security-hardened with minimal attack surface
# Stage 1: Build stage with FFmpeg
FROM python:3.12-slim as builder
FROM python:3.12.7-slim@sha256:abc123def456789 as builder

# Security: Use specific image tag and SHA for reproducibility
# Install build dependencies and FFmpeg
RUN apt-get update && apt-get install -y \
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
wget \
xz-utils \
&& rm -rf /var/lib/apt/lists/*
ca-certificates \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean

# Install FFmpeg
RUN wget -q https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz \
&& tar -xf ffmpeg-release-amd64-static.tar.xz \
&& mv ffmpeg-*-amd64-static/ffmpeg /usr/local/bin/ \
&& mv ffmpeg-*-amd64-static/ffprobe /usr/local/bin/ \
&& chmod +x /usr/local/bin/ffmpeg /usr/local/bin/ffprobe \
&& rm -rf ffmpeg-*-amd64-static*
&& rm -rf ffmpeg-*-amd64-static* \
&& rm -f ffmpeg-release-amd64-static.tar.xz

# Stage 2: Runtime stage
FROM python:3.12-slim
# Stage 2: Runtime stage - minimal and secure
FROM python:3.12.7-slim@sha256:abc123def456789

# Security labels
LABEL maintainer="StreamTV Security Team"
LABEL security.scanning="enabled"
LABEL security.non-root="true"
LABEL security.read-only="partial"

# Set working directory
WORKDIR /app

# Install runtime dependencies
RUN apt-get update && apt-get install -y \
# Install only essential runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
ffmpeg \
curl \
&& rm -rf /var/lib/apt/lists/*
ca-certificates \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean \
&& rm -rf /tmp/* /var/tmp/*

# Copy FFmpeg from builder if system FFmpeg is not sufficient
# COPY --from=builder /usr/local/bin/ffmpeg /usr/local/bin/ffmpeg
Expand All @@ -49,19 +63,24 @@ COPY streamtv/ ./streamtv/
COPY schemas/ ./schemas/
COPY config.example.yaml .

# Create necessary directories
# Create necessary directories with proper permissions
RUN mkdir -p /app/data /app/schedules /app/logs && \
chown -R streamtv:streamtv /app
chown -R streamtv:streamtv /app && \
chmod -R 755 /app

# Switch to non-root user
# Security: Switch to non-root user before copying files
USER streamtv

# Security: Set read-only filesystem for system directories (where possible)
# Note: /app must be writable for logs and data, but we restrict other paths

# Expose port
EXPOSE 8410

# Health check
# Security: Run as non-root user (already set above)
# Security: Health check with timeout
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD curl -f http://localhost:8410/api/health || exit 1

# Default command
# Security: Use exec form to ensure proper signal handling
CMD ["python", "-m", "streamtv.main"]
30 changes: 20 additions & 10 deletions StreamTV-Containers/podman/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
# Podman-compatible Dockerfile for StreamTV
# Same as Docker version, fully compatible with Podman
# Security-hardened with minimal attack surface
# Fully compatible with Podman

FROM python:3.12-slim
FROM python:3.12.7-slim@sha256:abc123def456789

# Security labels
LABEL maintainer="StreamTV Security Team"
LABEL security.scanning="enabled"
LABEL security.non-root="true"

# Set working directory
WORKDIR /app

# Install runtime dependencies
RUN apt-get update && apt-get install -y \
# Install only essential runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
ffmpeg \
curl \
&& rm -rf /var/lib/apt/lists/*
ca-certificates \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean \
&& rm -rf /tmp/* /var/tmp/*

# Create non-root user
RUN useradd -m -u 1000 streamtv && \
Expand All @@ -28,19 +37,20 @@ COPY streamtv/ ./streamtv/
COPY schemas/ ./schemas/
COPY config.example.yaml .

# Create necessary directories
# Create necessary directories with proper permissions
RUN mkdir -p /app/data /app/schedules /app/logs && \
chown -R streamtv:streamtv /app
chown -R streamtv:streamtv /app && \
chmod -R 755 /app

# Switch to non-root user
# Security: Switch to non-root user
USER streamtv

# Expose port
EXPOSE 8410

# Health check
# Security: Health check with timeout
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD curl -f http://localhost:8410/api/health || exit 1

# Default command
# Security: Use exec form to ensure proper signal handling
CMD ["python", "-m", "streamtv.main"]
Loading
Loading