diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..921281d --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +.git +.env +env +**/__pycache__ diff --git a/.gitignore b/.gitignore index 342ef14..0e5510a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *.swp +.env env n web planning.txt -__pycache__ +**/__pycache__ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b929809 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +FROM python:3.12-bookworm + +ARG ARCH= + +ENV BUILDARCH=${ARCH} +ENV GRONK_CSS_DIR=./css +ENV GRONK_JS_DIR=./js +ENV GRONK_TEMPLATES_DIR=./templates + +WORKDIR /usr/src/app + +RUN mkdir /notes +RUN mkdir /web + +VOLUME /usr/src/app/notes +VOLUME /usr/src/app/web + +RUN apt-get update \ + && wget -O ./pandoc.deb https://github.com/jgm/pandoc/releases/download/3.1.11/pandoc-3.1.11-1-${BUILDARCH}.deb \ + && apt install -y -f ./pandoc.deb \ + && rm ./pandoc.deb + +COPY requirements.txt ./ +RUN pip install --no-cache-dir -r requirements.txt + +COPY . . + +CMD [ "python3", "-u", "gronk.py", "--output-dir", "./web", "./notes" ] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..d65cc6b --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,11 @@ +version: '3' + +services: + gronk: + build: + context: '.' + args: + ARCH: ${ARCH} + volumes: + - '${SOURCE}:/usr/src/app/notes' + - '${OUTPUT}:/usr/src/app/web' diff --git a/gronk.py b/gronk.py index 77e81a4..4b5dd60 100755 --- a/gronk.py +++ b/gronk.py @@ -28,8 +28,6 @@ GRONK_JS_DIR = Path(os.getenv("GRONK_JS_DIR", "/opt/gronk/js")) GRONK_TEMPLATES_DIR = Path( os.getenv("GRONK_TEMPLATES_DIR", "/opt/gronk/templates/")) -print(f"{GRONK_TEMPLATES_DIR=}") - JINJA_ENV = jinja2.Environment( loader=jinja2.FileSystemLoader(searchpath=GRONK_TEMPLATES_DIR), autoescape=jinja2.select_autoescape) diff --git a/readme.md b/readme.md index 10a5034..6e6fe3e 100644 --- a/readme.md +++ b/readme.md @@ -19,8 +19,30 @@ Tested with [pandoc v2.19.2](https://github.com/jgm/pandoc/releases/tag/2.19.2). ## Install +### Docker + +Run the following, modifing the `-v` arguments as needed to mount the correct folders and +setting the value of `ARCH` to either `amd64` or `arm64` as appropriate. + +``` +docker build . -t gronk --build-arg ARCH=amd64 +docker run -v ./n:/usr/src/app/notes -v ./web:/usr/src/app/web gronk +``` + +#### Compose + +A [docker compose file](./docker-compose.yml) file has been provided. + +Set the following environment variables (or create a .env file) and run `docker compose up`: + +- `ARCH` +- `SOURCE` +- `OUTPUT` + +### Locally + 0. Install [Pandoc](https://pandoc.org/index.html) and [Pip](https://github.com/pypa/pip), python3-dev, and a C compiler -1. Run `make install` as root +1. `sudo make install` ## Other Things to Know @@ -98,7 +120,18 @@ $ gronk.py notes_directory Output of `gronk.py --help`: -TODO add cli output +``` +usage: gronk.py [-h] [-o OUTPUT_DIR] [-F] notes + +positional arguments: + notes + +options: + -h, --help show this help message and exit + -o OUTPUT_DIR, --output-dir OUTPUT_DIR + -F, --force Generate new output html even if source file was modified before output + html +``` The command will generate a website in the `output-dir` directory (`./web` by default). It will then generate a list of all note files and put it in `index.html`.