Files
3engines_doc/Dockerfile
govardhan 4ef34483bd dup
2025-06-19 20:49:49 +05:30

54 lines
1.4 KiB
Docker

# Build stage
FROM python:3.9-slim AS builder
# Set environment variables to avoid interactive prompts
ENV DEBIAN_FRONTEND=noninteractive
# 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
# 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 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-slim
# 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 curl -f http://localhost:80/ || exit 1
# Serve the static site with Python's http.server
CMD ["python", "-m", "http.server", "80"]