diff --git a/Dockerfile b/Dockerfile index 87b8492..048b82d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,22 @@ # Build stage -FROM python:3.9-slim AS builder +FROM python:3.9-alpine AS builder # Set environment variables to avoid interactive prompts -ENV DEBIAN_FRONTEND=noninteractive +ENV PYTHONDONTWRITEBYTECODE=1 \ + PYTHONUNBUFFERED=1 -# Update package sources to use a faster mirror -RUN echo "deb http://deb.debian.org/debian bookworm main" > /etc/apt/sources.list && \ - echo "deb http://deb.debian.org/debian-security bookworm-security main" >> /etc/apt/sources.list +# Configure apk to use a reliable mirror +RUN echo "https://mirrors.tuna.tsinghua.edu.cn/alpine/v3.18/main" > /etc/apk/repositories && \ + echo "https://mirrors.tuna.tsinghua.edu.cn/alpine/v3.18/community" >> /etc/apk/repositories -# Install build dependencies with retries and cleanup -RUN apt-get update -o Acquire::Retries=3 && \ - apt-get install -y --no-install-recommends \ - gcc=4:12.2.0-3 \ - python3-dev=3.11.2-1+b1 && \ - rm -rf /var/lib/apt/lists/* +# Install build dependencies +RUN apk add --no-cache \ + gcc \ + musl-dev \ + python3-dev \ + libffi-dev \ + openssl-dev \ + make # Install MkDocs and plugins with exact versions RUN pip install --no-cache-dir \ @@ -35,7 +38,7 @@ COPY docs/ ./docs/ RUN mkdocs build --strict # Runtime stage -FROM python:3.9-slim +FROM python:3.9-alpine # Set working directory WORKDIR /site @@ -48,7 +51,7 @@ EXPOSE 80 # Healthcheck to ensure the server is running HEALTHCHECK --interval=30s --timeout=3s \ - CMD curl -f http://localhost:80/ || exit 1 + CMD wget -qO- http://localhost:80/ || exit 1 # Serve the static site with Python's http.server CMD ["python", "-m", "http.server", "80"] \ No newline at end of file