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