Add Dockerfile to serve documentation
Use a container to preview the documentation for those of us who cannot or do not want to install npm/nodejs on their machines. - Add a Dockefile to create a docker image containing nodejs and the software needed to serve the documentation - Extend README.md with the option to use the Dockerfile to preview the documentation
This commit is contained in:
parent
ca68a77a76
commit
29cae330d0
15
Dockerfile
Normal file
15
Dockerfile
Normal file
|
@ -0,0 +1,15 @@
|
|||
FROM node:12.22.12-stretch-slim
|
||||
|
||||
RUN apt-get update && apt-get -y upgrade
|
||||
|
||||
RUN apt-get install -y git
|
||||
|
||||
RUN mkdir /opt/documentation && chown node: /opt/documentation
|
||||
|
||||
USER node
|
||||
|
||||
WORKDIR /opt/documentation
|
||||
|
||||
RUN npm install
|
||||
|
||||
CMD [ "npm", "run", "serve"]
|
33
README.md
33
README.md
|
@ -32,6 +32,39 @@ should automatically reload all changed pages using the amazing Browsersync.
|
|||
When you're done, commit your changes to your fork and write a pull request for
|
||||
Codeberg/Documentation. We're happy about every contribution!
|
||||
|
||||
### Local development using the Dockerfile
|
||||
|
||||
If you do not have nodejs installed or do not want to run the development web server directly on your host,
|
||||
you can also use a docker container.
|
||||
|
||||
You must have a container-engine installed (docker, podman, etc.)
|
||||
|
||||
First build the container image:
|
||||
|
||||
```shell
|
||||
docker build -t codeberg/documentation-server .
|
||||
```
|
||||
|
||||
You do not have to rebuild the image every time. Once you build the image you can always start the development
|
||||
webserver using the container engine:
|
||||
|
||||
```shell
|
||||
docker run --rm -v $PWD/opt/documentation codeberg/documentation-server:latest
|
||||
```
|
||||
|
||||
Use the "External" URL the container outputs on startup to access your documentation.
|
||||
|
||||
Changes to files in the documentation are reflected in the browser as the server regularly updates the generated files.
|
||||
|
||||
Use `Ctrl-C` to exit / end the container.
|
||||
|
||||
The parameters are:
|
||||
|
||||
`--rm` removes the container after it's use
|
||||
`-v` mounts the current (documentation repository root) folder to `/opt/documentation` in the container.
|
||||
|
||||
`codeberg/documentation-server:latest` refers to the container image built in the first step (using `docker build`).
|
||||
|
||||
### Build & Deployment
|
||||
Like for local development, before building and deploying you first have to install
|
||||
the dependencies (once):
|
||||
|
|
Loading…
Reference in a new issue