diff --git a/Dockerfile b/Dockerfile index 33cf1b5..2427c7b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,27 +1,32 @@ # Build stage -FROM python:3.9-alpine AS builder +FROM ubuntu:20.04 AS builder -# Set environment variables -ENV PYTHONDONTWRITEBYTECODE=1 \ +# Set environment variables to avoid interactive prompts +ENV DEBIAN_FRONTEND=noninteractive \ + PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 -# 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 +# Configure apt to use reliable mirrors +RUN echo "deb http://archive.ubuntu.com/ubuntu focal main restricted universe" > /etc/apt/sources.list && \ + echo "deb http://archive.ubuntu.com/ubuntu focal-updates main restricted universe" >> /etc/apt/sources.list && \ + echo "deb http://archive.ubuntu.com/ubuntu focal-security main restricted universe" >> /etc/apt/sources.list && \ + echo "deb http://us.archive.ubuntu.com/ubuntu focal main restricted universe" >> /etc/apt/sources.list -# Install build dependencies -RUN apk add --no-cache \ +# Install Python 3.9 and build dependencies +RUN apt-get update -o Acquire::Retries=10 -o Acquire::http::Timeout=30 && \ + apt-get install -y --no-install-recommends \ + python3.9 \ + python3.9-dev \ + python3-pip \ gcc \ - musl-dev \ - python3-dev \ - libffi-dev \ - openssl-dev \ - make \ - linux-headers \ - glibc # Add glibc compatibility layer for missing symbols + g++ \ + make && \ + rm -rf /var/lib/apt/lists/* && \ + ln -sf /usr/bin/python3.9 /usr/bin/python3 -# Install MkDocs and plugins with exact versions -RUN pip install --no-cache-dir \ +# Upgrade pip and install MkDocs and plugins +RUN python3 -m pip install --no-cache-dir --upgrade pip && \ + pip install --no-cache-dir \ mkdocs==1.6.1 \ mkdocs-material==9.5.39 \ mkdocs-macros-plugin==1.2.0 \ @@ -40,7 +45,20 @@ COPY docs/ ./docs/ RUN mkdocs build --strict # Runtime stage -FROM python:3.9-alpine +FROM ubuntu:20.04 + +# Set environment variables +ENV DEBIAN_FRONTEND=noninteractive \ + PYTHONDONTWRITEBYTECODE=1 \ + PYTHONUNBUFFERED=1 + +# Install Python 3.9 minimal for runtime +RUN apt-get update -o Acquire::Retries=10 -o Acquire::http::Timeout=30 && \ + apt-get install -y --no-install-recommends \ + python3.9 \ + curl && \ + rm -rf /var/lib/apt/lists/* && \ + ln -sf /usr/bin/python3.9 /usr/bin/python3 # Set working directory WORKDIR /site @@ -53,7 +71,7 @@ EXPOSE 80 # Healthcheck to ensure the server is running HEALTHCHECK --interval=30s --timeout=3s \ - CMD wget -qO- http://localhost:80/ || exit 1 + CMD curl -f 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 +CMD ["python3", "-m", "http.server", "80"] \ No newline at end of file