51 lines
1.9 KiB
Docker
51 lines
1.9 KiB
Docker
# Optimized Dockerfile for Raspberry Pi Zero (ARMv6)
|
|
# Minimal memory footprint and no compilation required
|
|
# Using Python 3.11 for compatibility with Pydantic v1
|
|
FROM python:3.11-slim
|
|
|
|
# Set environment variables
|
|
ENV PYTHONDONTWRITEBYTECODE=1 \
|
|
PYTHONUNBUFFERED=1 \
|
|
TZ=Europe/Berlin \
|
|
PIP_NO_CACHE_DIR=1 \
|
|
PIP_DISABLE_PIP_VERSION_CHECK=1
|
|
|
|
# Install only essential runtime dependencies
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
tzdata \
|
|
&& rm -rf /var/lib/apt/lists/* \
|
|
&& ln -snf /usr/share/zoneinfo/$TZ /etc/localtime \
|
|
&& echo $TZ > /etc/timezone
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Copy requirements file first for better layer caching
|
|
COPY requirements-pizero.txt .
|
|
|
|
# Install Python dependencies one by one for better memory management on Pi Zero
|
|
# Using versions that are compatible with Python 3.11 and don't require compilation
|
|
RUN pip install --no-cache-dir --no-compile fastapi==0.95.2
|
|
RUN pip install --no-cache-dir --no-compile pydantic==1.10.9
|
|
RUN pip install --no-cache-dir --no-compile uvicorn==0.22.0
|
|
RUN pip install --no-cache-dir --no-compile httpx==0.24.1
|
|
RUN pip install --no-cache-dir --no-compile icalendar==5.0.7
|
|
RUN pip install --no-cache-dir --no-compile jinja2==3.1.2
|
|
RUN pip install --no-cache-dir --no-compile apscheduler==3.10.1
|
|
RUN pip install --no-cache-dir --no-compile pytz==2023.3
|
|
RUN pip install --no-cache-dir --no-compile python-multipart==0.0.6
|
|
|
|
# Copy application files
|
|
COPY main.py .
|
|
COPY Vektor-Logo.svg ./
|
|
|
|
# Create static directory and copy logo
|
|
RUN mkdir -p static && \
|
|
cp Vektor-Logo.svg static/logo.svg
|
|
|
|
# Expose port
|
|
EXPOSE 8000
|
|
|
|
# Run with limited workers and basic asyncio loop for Pi Zero
|
|
# Using explicit python command to ensure correct Python version
|
|
CMD ["python3.11", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "1", "--loop", "asyncio"] |