Update Dockerfile

This commit is contained in:
gugulethu 2025-06-20 16:43:30 +02:00
commit ebaad620c9

View file

@ -1,58 +1,20 @@
# -------------------------------------------------------------
# Stage 1: Build the MkDocs site
# -------------------------------------------------------------
FROM python:3.11-slim AS builder
# 1) Install build prerequisites
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
gcc git rsync \
&& rm -rf /var/lib/apt/lists/*
# Use the official Python image as a base
FROM python:3.11-slim
# Set the working directory in the container
WORKDIR /app
# 2) Copy and install dependencies (including mkdocs)
COPY requirements.txt mkdocs.yml ./
RUN pip install --no-cache-dir -r requirements.txt mkdocs
# Copy the requirements file if you have one
COPY requirements.txt .
# 3) Copy your docs source
COPY docs/ ./docs
# If you have extra markdown or assets outside docs/, add more COPY lines here
# Install MkDocs and any other dependencies
RUN pip install --no-cache-dir -r requirements.txt
# 4) Build the static site into /app/site
RUN mkdocs build --clean --site-dir site
# Copy the entire MkDocs project into the container
COPY . .
# Expose the port that MkDocs will run on
EXPOSE 80
# -------------------------------------------------------------
# Stage 2: Deployer
# -------------------------------------------------------------
FROM alpine:3.18 AS deployer
# we need rsync in this stage
RUN apk add --no-cache rsync
WORKDIR /app
# Bring the built site in
COPY --from=builder /app/site ./site
# container will expect you to bind-mount your local nginx docroot into /deploy
VOLUME ["/deploy"]
COPY --chmod=+x << 'EOF' /usr/local/bin/deploy.sh
#!/bin/sh
set -e
SRC="/app/site/"
DST="/deploy/"
echo "Deploying site from $SRC to $DST …"
# simple sync, deletes stale files on DEST
rsync -av --delete "$SRC" "$DST"
echo "✅ Deployment complete."
EOF
ENTRYPOINT ["/usr/local/bin/deploy.sh"]
CMD [""] # no-op; all logic in entrypoint
# Command to run MkDocs
CMD ["mkdocs", "build"]