Skip to content

Commit 2128fce

Browse files
gbartolinimnencia
andauthored
chore: document running the site via Docker (#444)
Add a README section describing how to serve the site with the `hugomods/hugo` image. Closes #443 Signed-off-by: Gabriele Bartolini <gabriele.bartolini@enterprisedb.com> Signed-off-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com> Co-authored-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com>
1 parent 2b80e16 commit 2128fce

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,41 @@ npm install && npm run prod
4141

4242
This will compile the css file into `assets/css/output.css`. This file is ignored by git, so it is generated each build. If you make changes to `assets/css/main.css` you will need to restart the hugo server (e.g. stop it and run `npm run prod`) to pick up the changes. This is a temporary fix while Hugo & Tailwind JIT learn how to play nicely together.
4343

44+
### Using Docker
45+
46+
If you'd rather not install Hugo and Node.js locally, you can serve the
47+
site with the
48+
[`hugomods/hugo`](https://hub.docker.com/r/hugomods/hugo) image (the
49+
`-node-` variant is required because this site builds CSS through
50+
Tailwind/PostCSS):
51+
52+
``` sh
53+
docker run --rm \
54+
--name cnpg-www \
55+
-p 8080:8080 \
56+
-e HUGO_SECURITY_NODE_PERMISSIONS_ALLOWREAD='*' \
57+
-v "$(pwd)":/src \
58+
--entrypoint sh \
59+
hugomods/hugo:debian-reg-dart-sass-node-git-0.161.1 \
60+
-c "npm install && npm run dev -- --bind 0.0.0.0 -p 8080"
61+
```
62+
63+
The site will then be available at <http://localhost:8080>.
64+
65+
Notes:
66+
67+
- `node_modules/` is in `.gitignore`, so `npm install` writes into your
68+
working tree and is reused across container runs. If you also run
69+
`npm install` on the host, delete `node_modules/` before switching
70+
between host and container (or vice versa) so the Linux-built native
71+
binaries don't clash with the host ones.
72+
- `HUGO_SECURITY_NODE_PERMISSIONS_ALLOWREAD='*'` widens Hugo's default
73+
Node permission policy so `browserslist` (loaded by `postcss-preset-env`)
74+
can walk parent directories looking for its config.
75+
- To serve without drafts, replace `npm run dev` with `npm run prod`.
76+
- The image tag pins Hugo `0.161.1`; bump it as the project's Hugo version
77+
advances.
78+
4479
### CSS
4580

4681
CSS is partly built by hugo & partly built outside of hugo by `npm run css`, which is called by `npm run dev|prod`. If you start to use a new Tailwind class restarting hugo is required (stop the server and `npm run dev`), if you edit `assets/style.css` it should compile in correctly without restart. This is to mitigate [this issue](https://github.com/gohugoio/hugo/issues/8343).

0 commit comments

Comments
 (0)