FROM python:3.15.0a7-alpine3.22 ENV PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple RUN apk add --no-cache ca-certificates openssl # Upgrade pip and install MkDocs dependencies RUN pip install --upgrade pip RUN pip install mkdocs-material==9.5.5 mkdocs-glightbox WORKDIR /hello-algo # Build the main docs COPY docs ./build/docs COPY mkdocs.yml mkdocs.yml RUN mkdocs build -f mkdocs.yml # Build Chinese (Traditional) docs COPY zh-hant/docs ./build/zh-hant/docs COPY zh-hant/mkdocs.yml ./zh-hant/mkdocs.yml RUN mkdocs build -f ./zh-hant/mkdocs.yml # Build English docs COPY en/docs ./build/en/docs COPY en/mkdocs.yml ./en/mkdocs.yml RUN mkdocs build -f ./en/mkdocs.yml WORKDIR /hello-algo/site EXPOSE 8000 CMD ["python", "-m", "http.server", "8000"]
# Exclude version control and CI metadata .git .gitmodules # Environment and virtual envs .env* **/.venv **/venv # Build artifacts build/ site/ .website/ # Python caches __pycache__/ **/*.pyc **/*.pyo # Large directories that are not needed for the build .codes/ # OS files .DS_Store # Logs *.log
ERROR: permission denied while trying to connect to the docker API at unix:///var/run/docker.sock
Image python:3.15.0a7-alpine3.22 exists on Docker Hub.
FROM python:3.10.0-alpine ENV PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple RUN apk add --no-cache ca-certificates openssl # Upgrade pip and install MkDocs dependencies RUN pip install --upgrade pip RUN pip install mkdocs-material==9.5.5 mkdocs-glightbox WORKDIR /hello-algo # Build the main docs COPY docs ./build/docs COPY mkdocs.yml mkdocs.yml RUN mkdocs build -f mkdocs.yml # Build Chinese (Traditional) docs COPY zh-hant/docs ./build/zh-hant/docs COPY zh-hant/mkdocs.yml ./zh-hant/mkdocs.yml RUN mkdocs build -f ./zh-hant/mkdocs.yml # Build English docs COPY en/docs ./build/en/docs COPY en/mkdocs.yml ./en/mkdocs.yml RUN mkdocs build -f ./en/mkdocs.yml WORKDIR /hello-algo/site EXPOSE 8000 CMD ["python", "-m", "http.server", "8000"]
FROM python:3.10.0-alpine ENV PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple RUN apk add --no-cache ca-certificates # Upgrade pip and install MkDocs dependencies RUN pip install --upgrade pip RUN pip install mkdocs-material==9.5.5 mkdocs-glightbox WORKDIR /hello-algo # Build main docs COPY mkdocs.yml . COPY docs ./docs RUN mkdocs build -f mkdocs.yml -d site # Build zh-hant docs COPY zh-hant ./zh-hant RUN mkdocs build -f zh-hant/mkdocs.yml -d site/zh-hant # Build english docs COPY en ./en RUN mkdocs build -f en/mkdocs.yml -d site/en WORKDIR /hello-algo/site EXPOSE 8000 CMD ["python", "-m", "http.server", "8000"]
ERROR: permission denied while trying to connect to the docker API at unix:///var/run/docker.sock
FROM python:3.15.0a7-alpine3.22 ENV PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple RUN apk add --no-cache ca-certificates openssl # Upgrade pip and install MkDocs dependencies RUN pip install --upgrade pip RUN pip install mkdocs-material==9.5.5 mkdocs-glightbox WORKDIR /hello-algo # Build the main docs COPY docs ./docs COPY mkdocs.yml mkdocs.yml RUN mkdocs build -f mkdocs.yml -d site # Build Chinese (Traditional) docs COPY zh-hant/docs ./zh-hant/docs COPY zh-hant/mkdocs.yml ./zh-hant/mkdocs.yml RUN mkdocs build -f zh-hant/mkdocs.yml -d site/zh-hant # Build English docs COPY en/docs ./en/docs COPY en/mkdocs.yml ./en/mkdocs.yml RUN mkdocs build -f en/mkdocs.yml -d site/en WORKDIR /hello-algo/site EXPOSE 8000 CMD ["python", "-m", "http.server", "8000"]
ERROR: permission denied while trying to connect to the docker API at unix:///var/run/docker.sock
# Use stable Python on Alpine for MkDocs
FROM python:3.12-alpine
# Use a fast PyPI mirror
ENV PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple
# Install Python build tools and MkDocs dependencies
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir mkdocs-material==9.5.5 mkdocs-glightbox
WORKDIR /hello-algo
# Optional: copy any MkDocs overrides if present in the build context
COPY overrides ./build/overrides
# Build the default docs (top-level)
COPY docs ./build/docs
COPY mkdocs.yml mkdocs.yml
RUN mkdocs build -f mkdocs.yml
# Build the Chinese (Traditional) translation docs
COPY zh-hant/docs ./build/zh-hant/docs
COPY zh-hant/mkdocs.yml ./zh-hant/mkdocs.yml
RUN mkdocs build -f ./zh-hant/mkdocs.yml
# Build the English docs
COPY en/docs ./build/en/docs
COPY en/mkdocs.yml ./en/mkdocs.yml
RUN mkdocs build -f ./en/mkdocs.yml
# Serve the generated site on port 8000
WORKDIR /hello-algo/site
EXPOSE 8000
CMD ["python", "-m", "http.server", "8000"]
Concerns: COPY overrides ./build/overrides will fail at build time if the overrides directory does not exist in the build context., The sequence of copies for zh-hant/en docs copies content into build/paths, but MkDocs config likely expects docs relative to each language subdirectory (e.g., zh-hant/docs or en/docs). This mismatch will cause MkDocs builds to fail., There is potential ambiguity about where the MkDocs site is generated; multiple builds may override /hello-algo/site, and the final result depends on the last build step., No explicit validation that the docs were actually built successfully; the image may build but exit with a non-zero status during docs build without a failing CMD visible.
# Use stable Python on Alpine for MkDocs
FROM python:3.12-alpine
# Use a fast PyPI mirror
ENV PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple
# Install Python build tools and MkDocs dependencies
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir mkdocs-material==9.5.5 mkdocs-glightbox
WORKDIR /hello-algo
# Copy and build the root MkDocs docs
COPY docs ./docs
COPY mkdocs.yml ./mkdocs.yml
RUN mkdocs build -f mkdocs.yml
# Copy and build the Chinese (Traditional) documentation
COPY zh-hant/docs ./zh-hant/docs
COPY zh-hant/mkdocs.yml ./zh-hant/mkdocs.yml
RUN mkdocs build -f zh-hant/mkdocs.yml
# Copy and build the English documentation
COPY en/docs ./en/docs
COPY en/mkdocs.yml ./en/mkdocs.yml
RUN mkdocs build -f en/mkdocs.yml
# Serve the generated site on port 8000
WORKDIR /hello-algo/site
EXPOSE 8000
CMD ["python", "-m", "http.server", "8000"]
ERROR: permission denied while trying to connect to the docker API at unix:///var/run/docker.sock
# Git and CI directories .git .gitignore .github/ # Common build artifacts and environments build/ dist/ *.egg-info/ venv/ env/ ENV/ # Python caches and logs __pycache__/ *.pyc *.log # IDEs .vscode/ .idea/ .DS_Store
ERROR: permission denied while trying to connect to the docker API at unix:///var/run/docker.sock
# Use stable Python on Alpine for MkDocs
FROM python:3.12-alpine
# Use a fast PyPI mirror
ENV PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple
# Install Python build tools and MkDocs dependencies
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir mkdocs mkdocs-material==9.5.5 mkdocs-glightbox
WORKDIR /hello-algo
# Build and aggregate multilingual MkDocs sites into a single output directory
RUN mkdir -p site_root site_zh site_en
# Copy and build the root documentation
COPY docs ./docs
COPY mkdocs.yml ./mkdocs.yml
RUN mkdocs build -f mkdocs.yml --site-dir site_root
# Copy and build the Traditional Chinese docs
COPY zh-hant/docs ./zh-hant/docs
COPY zh-hant/mkdocs.yml ./zh-hant/mkdocs.yml
RUN mkdocs build -f zh-hant/mkdocs.yml --site-dir site_zh
# Copy and build the English docs
COPY en/docs ./en/docs
COPY en/mkdocs.yml ./en/mkdocs.yml
RUN mkdocs build -f en/mkdocs.yml --site-dir site_en
# Aggregate built sites into the final output directory
RUN mkdir -p site && \
cp -r site_root/. site/ && \
mkdir -p site/zh-hant && cp -r site_zh/. site/zh-hant && \
mkdir -p site/en && cp -r site_en/. site/en
# Serve the generated site on port 8000
WORKDIR /hello-algo/site
EXPOSE 8000
CMD ["python", "-m", "http.server", "8000"]
ERROR: permission denied while trying to connect to the docker API at unix:///var/run/docker.sock
FROM python:3.15.0a7-alpine3.22 ENV PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple RUN pip install --upgrade pip RUN pip install mkdocs mkdocs-material==9.5.5 mkdocs-glightbox WORKDIR /hello-algo # Create a non-root user for running the final server RUN adduser -D mkdocs COPY overrides ./build/overrides COPY docs ./build/docs COPY mkdocs.yml mkdocs.yml RUN mkdocs build -f mkdocs.yml -d site COPY zh-hant/docs ./build/zh-hant/docs COPY zh-hant/mkdocs.yml ./zh-hant/mkdocs.yml RUN mkdocs build -f ./zh-hant/mkdocs.yml -d site/zh-hant COPY en/docs ./build/en/docs COPY en/mkdocs.yml ./en/mkdocs.yml RUN mkdocs build -f ./en/mkdocs.yml -d site/en WORKDIR /hello-algo/site EXPOSE 8000 USER mkdocs CMD ["python", "-m", "http.server", "8000"]
.git .gitignore node_modules build site __pycache__ *.pyc *.pyo *.log *.tmp *.bak *.swp *.swo *.DS_Store .env .env.* venv .envs *.egg-info dist tests tests/**
ERROR: permission denied while trying to connect to the docker API at unix:///var/run/docker.sock
FROM python:3.15.0a7-alpine3.22 ENV PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple RUN pip install --upgrade pip RUN pip install mkdocs mkdocs-material==9.5.5 mkdocs-glightbox WORKDIR /hello-algo # Build all MkDocs sites from the repository (docs, zh-hant, en) # Copy the entire repository to the image for flexible build context COPY . . # Create a non-root user for running the final server RUN adduser -D mkdocs # Ensure the site directory exists RUN mkdir -p site # Build docs into separate subdirectories to avoid overwriting RUN mkdocs build -f mkdocs.yml -d site RUN mkdocs build -f zh-hant/mkdocs.yml -d site/zh-hant RUN mkdocs build -f en/mkdocs.yml -d site/en # Serve the built site WORKDIR /hello-algo/site EXPOSE 8000 USER mkdocs CMD ["python", "-m", "http.server", "8000"]