59 lines
1.4 KiB
Docker
59 lines
1.4 KiB
Docker
# Build stage
|
|
FROM python:3.9-alpine AS builder
|
|
|
|
# Set environment variables
|
|
ENV 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
|
|
|
|
# Install build dependencies
|
|
RUN apk add --no-cache \
|
|
gcc \
|
|
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 \
|
|
mkdocs==1.6.1 \
|
|
mkdocs-material==9.5.39 \
|
|
mkdocs-macros-plugin==1.2.0 \
|
|
mkdocs-minify-plugin==0.8.0 \
|
|
mkdocs-awesome-pages-plugin==2.9.2 \
|
|
mkdocs-glightbox==0.4.0
|
|
|
|
# Set working directory
|
|
WORKDIR /docs
|
|
|
|
# Copy configuration and docs
|
|
COPY mkdocs.yml .
|
|
COPY docs/ ./docs/
|
|
|
|
# Build the static site with strict mode
|
|
RUN mkdocs build --strict
|
|
|
|
# Runtime stage
|
|
FROM python:3.9-alpine
|
|
|
|
# Set working directory
|
|
WORKDIR /site
|
|
|
|
# Copy the built site from the builder stage
|
|
COPY --from=builder /docs/site .
|
|
|
|
# Expose port 80
|
|
EXPOSE 80
|
|
|
|
# Healthcheck to ensure the server is running
|
|
HEALTHCHECK --interval=30s --timeout=3s \
|
|
CMD wget -qO- http://localhost:80/ || exit 1
|
|
|
|
# Serve the static site with Python's http.server
|
|
CMD ["python", "-m", "http.server", "80"] |