Update Dockerfile
This commit is contained in:
parent
b5f63733d7
commit
ebaad620c9
1 changed files with 13 additions and 51 deletions
64
Dockerfile
64
Dockerfile
|
|
@ -1,58 +1,20 @@
|
||||||
# -------------------------------------------------------------
|
# Use the official Python image as a base
|
||||||
# Stage 1: Build the MkDocs site
|
FROM python:3.11-slim
|
||||||
# -------------------------------------------------------------
|
|
||||||
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/*
|
|
||||||
|
|
||||||
|
# Set the working directory in the container
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# 2) Copy and install dependencies (including mkdocs)
|
# Copy the requirements file if you have one
|
||||||
COPY requirements.txt mkdocs.yml ./
|
COPY requirements.txt .
|
||||||
RUN pip install --no-cache-dir -r requirements.txt mkdocs
|
|
||||||
|
|
||||||
# 3) Copy your docs source
|
# Install MkDocs and any other dependencies
|
||||||
COPY docs/ ./docs
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
# If you have extra markdown or assets outside docs/, add more COPY lines here
|
|
||||||
|
|
||||||
# 4) Build the static site into /app/site
|
# Copy the entire MkDocs project into the container
|
||||||
RUN mkdocs build --clean --site-dir site
|
COPY . .
|
||||||
|
|
||||||
|
# Expose the port that MkDocs will run on
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
# -------------------------------------------------------------
|
# Command to run MkDocs
|
||||||
# Stage 2: Deployer
|
CMD ["mkdocs", "build"]
|
||||||
# -------------------------------------------------------------
|
|
||||||
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
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue