docker-mdbook/README.md

39 lines
1.2 KiB
Markdown

# Containerized `mdbook`
`mdbook` (<https://rust-lang.github.io/mdBook/>) is an easy way to generate beautiful book-like websites from simple Markdown text files.
This repository compiles and packages a ready-to-use contianer running `mdbook`.
## Easy Book->Website
`mdbook` repositories are very clean: Just a `src/` folder with a bunch of markdown text files.
`docker-mdbook` makes it easy to turn that clean bundle of text files into a website deployable as a container.
Here's a multi-stage Dockerfile example:
```Dockerfile
####################
# - Stage: SSG
####################
FROM git.sofus.io/python-support/docker-mdbook:0.1.0 AS base
COPY . /src
RUN mdbook build /src --dest-dir /dist
####################
# - Stage: Serve Static Files
####################
FROM ghcr.io/static-web-server/static-web-server:2
COPY --from=base /dist /app
ENV SERVER_PORT 8787
ENV SERVER_ROOT /app
ENV SERVER_LOG_LEVEL info
USER 5020
```
Put this `Dockerfile` in your book repository, then build & run with your favorite container tool:
```bash
podman build . --tag mybook:dev
podman run --rm -it -p 8787:8787 mybook:dev
## In your browser, go to localhost:8787
```
The principle is the same for hot-reloading with ex. `mdbook serve`.