Headless render engine: data+tpl to optimized HTML & CSS, for pages, ads and emails.
boilerplate & example repository
Build an image where the locales and templates are baked in, thus can be pushed to a image repository and used/deployed directly.
FROM bemiteu/render
COPY --chown=node:node ./locales /home/node/app/locales
COPY --chown=node:node ./templates /home/node/app/templatesExample setup of a docker-compose suite, with public APIs and redis for caching stylesheets.
version: "3.9"
services:
render:
image: "bemiteu/render"
environment:
ACCESS_PUBLIC_DESCRIBE: "yes"
ACCESS_PUBLIC_RENDER: "yes"
APP_ENV: local
NODE_ENV: development
REDIS_HOST: redis:6379
PORT: 80
OA_SERVER_SELECT: "false"
OA_SERVER_URL: auto
CACHE_EX_STYLE: 600
# HOME_FOOTER: "<span>my org</span>"
# HOME_NO_DOCS: "yes"
volumes:
- ./locales:/home/node/app/locales
- ./templates:/home/node/app/templates
depends_on:
- redis
ports:
- "3000:80"
redis:
image: redis:alpineConfigure with ENV variables.
The following variables allows restricting the API for authenticated users, using JWTs as bearer token in authorization header.
Enabled by setting either ID_KEY_URL or ID_KEY_MEM.
ID_ISSUER:[string], for issuer validationID_KEY_MEM:[string], the JWT secret key to useID_KEY_URL:[string], the url from where to load the JWT public key, e.g./verify-keyID_KEY_ALGO:[string], defaults toHS256ID_AUDIENCE:[string], enforces audience validationID_HOST:[string], host of your ID service, required forID_KEY_URL
The following variables enables logging with Google Cloud Log.
GCP_LOG:[string], path to the authentication file, if set enables google cloud loggingLOG_PROJECT:[string], id of the google cloud projectLOG_ID:[string], id of the logging bucketLOG_SERVICE_NAME:[string], used inresource.labels.service- labels
APP_ENVas `
CACHE_EX_STYLE:[number], how long built styles should be cached, in secondsACCESS_PUBLIC_RENDER:['true' | '1' | 'yes' | 'on'], if the render endpoint can be accessed without authenticationACCESS_PUBLIC_DESCRIBE:['true' | '1' | 'yes' | 'on'], if thedocument-typesAPIs can be accessed without authenticationHOME_NO_DOCS:['true' | '1' | 'yes' | 'on'], if truly will show links to docs on homeHOME_FOOTER:[string], if set used as footer on home, must only contain HTML which is allowed inpOA_SERVER_SELECT:['true' | '1' | 'yes' | 'on'], when truly will allow user to select serverOA_SERVER_URL:['auto' | string], used as the OpenAPI Server URL, whenautousing the current host
Creates a new template folder & file structure in the templates folder.
Uses the mounts from docker-compose.yml, so nothing to add here.
docker-compose run --rm render node cli.js tpl:init my-tplOptionally specify which locale should be created with the second param:
docker-compose run --rm render node cli.js tpl:init my-tpl frAlso requires all ENV vars!
Using current folder on Windows:
docker run --rm -it -v %cd%/templates:/home/node/app/templates -v %cd%/locales:/home/node/app/locales bemiteu/render node cli.js tpl:init my-tplUsing current folder on Unix:
docker run --rm -it \
-v `pwd`/templates:/home/node/app/templates \
-v `pwd`/locales:/home/node/app/locales \
bemiteu/render node cli.js tpl:init my-tplThis project adheres to semver, until 1.0.0 and beginning with 0.1.0: all 0.x.0 releases are like MAJOR releases and all 0.0.x like MINOR or PATCH, modules below 0.1.0 should be considered experimental.
This project is free software distributed under the MIT License.