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