Skip to content

Commit 73f56f0

Browse files
committed
docs: Document "learn-ocaml build --base-url $URL"
1 parent 90f391b commit 73f56f0

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
How to deploy learn-ocaml statically
2+
====================================
3+
4+
This section explains how to deploy a static version of learn-ocaml on
5+
an HTTP server.
6+
7+
## Using pre-built docker images
8+
9+
You will just need to:
10+
11+
- install Docker Engine (<https://docs.docker.com/get-docker/>)
12+
- build the `www` folder by using the commands below
13+
- use an HTTP server to serve learn-ocaml statically.
14+
15+
Assuming your exercise repository is in directory `$REPOSITORY` and
16+
you want to generate the website contents in directory `$TARGET/www`
17+
to serve it at `$URL` (the base URL **without trailing slash**), then
18+
you can run:
19+
20+
```bash
21+
# Remove old version
22+
cd "$TARGET"
23+
rm -fr www
24+
# Get the last (dev) version of learn-ocaml
25+
sudo docker pull ocamlsf/learn-ocaml:master
26+
# Build the site within a Docker container
27+
sudo docker run --rm -i --entrypoint="" \
28+
-v "$REPOSITORY:/repository" -v "$TARGET:/home/learn-ocaml/target" \
29+
ocamlsf/learn-ocaml:master \
30+
sh -c "learn-ocaml build --repo=/repository --base-url $URL && mv www target/"
31+
```
32+
33+
Regarding the `--base-url` option, if you plan to deploy the `www`
34+
directory with **GitHub Pages**, assuming the underlying GitHub repo
35+
(either public or private) is `https://github.com/user-name/repo-name`
36+
then you should first run:
37+
38+
```bash
39+
export URL=https://user-name.github.io/repo-name
40+
```
41+
42+
For a comprehensive example of one such deployment, you may take a
43+
look at the following repository:
44+
- <https://github.com/pfitaxel/pfitaxel-demo>
45+
- deployed to <https://pfitaxel.github.io/pfitaxel-demo>
46+
- thanks to this [`deploy` script](https://github.com/pfitaxel/pfitaxel-demo/blob/master/deploy).
47+
48+
## Manual compilation
49+
50+
Note: you need a working `opam` environment (version 2.0+) as well as
51+
an `opam switch` and a compiled version of `learn-ocaml` (see
52+
[How to deploy a learn-ocaml instance](howto-deploy-a-learn-ocaml-instance.md#manual-compilation)
53+
for details).
54+
55+
Assuming your exercise repository is in directory `$REPOSITORY` and
56+
you want to generate the website contents in directory `$TARGET/www`
57+
to serve it at `$URL` (the base URL **without trailing slash**), then
58+
you can run:
59+
60+
```bash
61+
rm -fr "$TARGET/www"
62+
cd .../learn-ocaml # go to the learn-ocaml git repo
63+
learn-ocaml build --repo=$REPOSITORY --base-url $URL
64+
mv www "$TARGET/www"
65+
```

0 commit comments

Comments
 (0)