From b90529c01fe4b99b46255aeb91de6b2ff729c36e Mon Sep 17 00:00:00 2001 From: govardhan Date: Thu, 19 Jun 2025 21:37:58 +0530 Subject: [PATCH] cc --- Dockerfile | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2075a33..33cf1b5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,24 @@ # 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 +# Set environment variables +ENV PYTHONDONTWRITEBYTECODE=1 \ + PYTHONUNBUFFERED=1 -# Configure apt to use reliable mirrors -RUN echo "deb http://ftp.debian.org/debian bookworm main" > /etc/apt/sources.list && \ - echo "deb http://ftp.debian.org/debian-security bookworm-security main" >> /etc/apt/sources.list && \ - echo "deb http://ftp.us.debian.org/debian bookworm 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 and clean up in one step -RUN apt-get update -o Acquire::Retries=10 -o Acquire::http::Timeout=30 && \ - apt-get install -y --no-install-recommends \ +# Install build dependencies +RUN apk add --no-cache \ gcc \ - python3-dev && \ - rm -rf /var/lib/apt/lists/* + musl-dev \ + python3-dev \ + libffi-dev \ + openssl-dev \ + make \ + linux-headers \ + glibc # Add glibc compatibility layer for missing symbols # Install MkDocs and plugins with exact versions RUN pip install --no-cache-dir \ @@ -36,7 +40,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 @@ -49,7 +53,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