Skip to content

Commit df795dd

Browse files
leinaccavivace
andcommitted
Add Docker image for local development (#462)
Co-authored-by: Antonio Vivace <[email protected]>
1 parent a52ee14 commit df795dd

File tree

2 files changed

+70
-7
lines changed

2 files changed

+70
-7
lines changed

DEPLOY.md

+46-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,45 @@
1-
## Deploy
1+
# Deploy
22

3-
This document will explain you how to run a local copy of Pan Docs.
3+
This document will explain you how to set up a local copy of Pan Docs.
4+
5+
```sh
6+
# Start by cloning the repository
7+
git clone https://github.com/gbdev/pandocs.git
8+
# and moving to the pandocs directory
9+
cd pandocs
10+
```
11+
12+
## Docker
13+
14+
If you have [Docker installed](https://docs.docker.com/engine/install/), you can pull and use the provided image by running:
15+
16+
```sh
17+
docker run -p 8001:8000 \
18+
--mount "type=bind,source=$(pwd)/custom,target=/code/custom" \
19+
--mount "type=bind,source=$(pwd)/preproc,target=/code/preproc" \
20+
--mount "type=bind,source=$(pwd)/renderer,target=/code/renderer" \
21+
--mount "type=bind,source=$(pwd)/src,target=/code/src" \
22+
--mount "type=bind,source=$(pwd)/theme,target=/code/theme" \
23+
-it ghcr.io/gbdev/pandocs
24+
```
25+
26+
That's it! Pan Docs is live at [localhost:8001](https://localhost:8001).
27+
28+
Be aware of the following caveat:
29+
30+
- The locally running site will not update from changes to files in the `theme/` or `custom/` directories (e.g. highlight.js builds, CSS style overrides). You must trigger the build by manually changing a file in the `src/` directory.
31+
32+
### Building the image
33+
34+
If you prefer to build the image yourself:
35+
36+
```sh
37+
docker build -t pandocs .
38+
```
39+
40+
## Local
41+
42+
If you prefer to install every dependency locally:
443

544
1. Install [Rust](https://www.rust-lang.org/tools/install), [mdBook](https://github.com/rust-lang/mdBook#readme), and [Python 3](https://www.python.org/downloads) (3.9 or an earlier version).
645
mdBook is the tool rendering the documentation, Rust is used for some custom plugins and Python scripts are used to render some images. E.g.:
@@ -42,11 +81,11 @@ Be aware of the following caveats:
4281

4382
- `mdbook watch` and `mdbook serve` do *not* watch for changes to files in the `theme/` or `custom/` directories (e.g. highlight.js builds, CSS style overrides). You must trigger the build by either restarting the command, or manually changing one of the watched files.
4483

45-
### Special markup
84+
## Special markup
4685

4786
Pan Docs uses a custom mdBook preprocessor & renderer to enable some special markup:
4887

49-
#### Custom Containers
88+
### Custom Containers
5089

5190
Those mimick Vuepress' [custom containers](https://vuepress.vuejs.org/guide/markdown.html#custom-containers) functionality.
5291

@@ -79,7 +118,7 @@ will render as
79118

80119
<img src=".github/example_container.png"></img>
81120

82-
#### Internal links
121+
### Internal links
83122

84123
```markdown
85124
[VRAM Sprite Attribute Table (OAM)](<#VRAM Sprite Attribute Table (OAM)>)
@@ -91,7 +130,7 @@ Note that the angle brackets [are only required if there are spaces in the URL](
91130

92131
In effect, this means that linking to a section is as simple as copy-pasting its name in the URL field, prepending a `#`, and wrapping everything in `<>` if the name contains a space.
93132

94-
### Syntax highlighting
133+
## Syntax highlighting
95134

96135
Syntax highlighting is provided within the browser, courtesy of [`highlight.js`](https://github.com/highlightjs/highlight.js).
97136
[RGBASM syntax](https://rgbds.gbdev.io/docs/rgbasm.5) is highlighted via [a plugin](https://github.com/gbdev/highlightjs-rgbasm), but this requires a custom build of `highlight.js`.
@@ -121,7 +160,7 @@ node tools/build.js -t browser rgbasm c
121160
cp build/highlight.min.js ../pandocs/theme/highlight.js
122161
```
123162

124-
### Folder structure
163+
## Folder structure
125164

126165
```
127166
.

Dockerfile

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Get a python 3.10 image
2+
FROM python:3.10.9
3+
LABEL org.opencontainers.image.source=https://github.com/gbdev/pandocs
4+
SHELL ["bash", "-lc"]
5+
RUN apt update
6+
RUN apt install curl -y
7+
8+
# Install rust and mdbook
9+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
10+
RUN apt install gcc -y
11+
RUN source "$HOME/.cargo/env"
12+
RUN cargo install mdbook
13+
14+
COPY . /code
15+
WORKDIR /code
16+
17+
# Init python3 env
18+
RUN python -m venv env
19+
RUN source env/bin/activate
20+
RUN pip install -r requirements.txt
21+
22+
# Serve pandocs at localhost:8000
23+
RUN mdbook build
24+
CMD mdbook watch & (cd /code/docs/pandocs/ && python3 -m http.server)

0 commit comments

Comments
 (0)