diff --git a/.gitignore b/.gitignore index b3672cb..0352ba9 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ _site/ .cache/ + # Integrated development environments (IDEs) and text editors ## JetBrains .idea/ @@ -15,6 +16,9 @@ _site/ ## npm - Node.js node_modules/ +## pnpm - Node.js +.pnpm-store/ + # Web servers ## Codeberg Pages diff --git a/.prettierignore b/.prettierignore index 46430d7..bd5535a 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,2 +1 @@ pnpm-lock.yaml -.pnpm-store/ diff --git a/Dockerfile b/Dockerfile index f9465f0..e0e3ffc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,21 @@ -FROM node:16.15.1-stretch-slim +# The main purpose of this Dockerfile is to install the `pnpm` package manager in the official Node.js image +# and use an init script as the entrypoint of a custom image to build and run the documentation site. +FROM node:lts-slim@sha256:0afb7822fac7bf9d7c1bf3b6e6c496dee6b2b64d8dfa365501a3c68e8eba94b2 -RUN apt-get update && apt-get -y upgrade +EXPOSE 8080/tcp +SHELL [ "bash", "-c" ] +ENTRYPOINT [ "./container-init.sh" ] -RUN apt-get install -y git curl -RUN curl -fsSL https://get.pnpm.io/install.sh | sh - +ENV CI="true" -RUN mkdir /opt/documentation && chown node: /opt/documentation +# renovate: datasource=npm depName=pnpm +ENV PNPM_VERSION="10.23.0" + +RUN apt-get update \ +&& DEBIAN_FRONTEND=noninteractive apt-get --assume-yes upgrade \ +&& rm --recursive --force /var/lib/apt/lists/* + +RUN npm install --global pnpm@${PNPM_VERSION} USER node - -WORKDIR /opt/documentation - -RUN pnpm install - -CMD [ "pnpm", "run", "serve"] +WORKDIR /docs diff --git a/README.md b/README.md index ac260a3..5f7ab42 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ You only have to do this once. Then run -`pnpm run serve` +`pnpm run dev` to start a development web server that by default is listening at `http://localhost:8080`. @@ -48,14 +48,14 @@ You must have a container-engine installed (docker, podman, etc.) First build the container image: ```shell -docker build -t Codeberg/Documentation-server . +docker build --tag codeberg-docs:dev . ``` 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 +docker run --name "codeberg-docs" --rm --tty --interactive --volume "${PWD}:/docs" --publish "127.0.0.1:8080:8080/tcp" codeberg-docs:dev ``` Use the "External" URL the container outputs on startup to access your documentation. @@ -67,9 +67,9 @@ 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. +`--volume` mounts the current (documentation repository root) folder to `/docs` in the container. -`Codeberg/Documentation-server:latest` refers to the container image built in the first step (using `docker build`). +`codeberg-docs:dev` refers to the container image built in the first step (using `docker build`). ### Build & Deployment diff --git a/container-init.sh b/container-init.sh new file mode 100755 index 0000000..27dc8f0 --- /dev/null +++ b/container-init.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +# This script allows developers to easily build and preview the +# Codeberg documentation locally when using containers. +pnpm install +pnpm run dev diff --git a/package.json b/package.json index 65b712e..c114041 100644 --- a/package.json +++ b/package.json @@ -3,8 +3,8 @@ "description": "The documentation site for Codeberg", "private": true, "scripts": { - "build": "rm -rf _site/ && eleventy", - "serve": "eleventy --serve" + "build": "eleventy", + "dev": "eleventy --serve --incremental" }, "devDependencies": { "@11ty/eleventy": "3.1.2",