Skip to content

Dockerized html-pdf-chrome, with headless chromium running in the background 🐳

License

Notifications You must be signed in to change notification settings

theohbrothers/docker-html-pdf-chrome

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

docker-html-pdf-chrome

github-actions github-release docker-image-size

Dockerized html-pdf-chrome, with headless chromium running in the background.

Tags

Tag Dockerfile Build Context
:0.8.4, :latest View
  • All images are based on alpine, and include node and npm

Usage

To export a remote HTML page as .pdf:

docker run --rm -it -e URL=http://localhost -e PDF_FILE=export.pdf -v $(pwd):$(pwd) -w $(pwd) --network host theohbrothers/docker-html-pdf-chrome:0.8.4
docker run --rm -it -e URL=https://example.com -e PDF_FILE=export.pdf -v $(pwd):$(pwd) -w $(pwd) theohbrothers/docker-html-pdf-chrome:0.8.4

For export more complex cases, mount your custom script as /export.js:

docker run --rm -it -v $(pwd)/export.js:/export.js -v $(pwd):$(pwd) -w $(pwd) theohbrothers/docker-html-pdf-chrome:0.8.4 node /export.js

For a sleeping container (to reduce overhead of restarting chromium every run):

docker run --rm -it -e SLEEP=1 -v $(pwd):$(pwd) -w $(pwd) theohbrothers/docker-html-pdf-chrome:0.8.4

See html-pdf-chrome usage.

Development

Requires Windows powershell or pwsh.

# Install Generate-DockerImageVariants module: https://github.com/theohbrothers/Generate-DockerImageVariants
Install-Module -Name Generate-DockerImageVariants -Repository PSGallery -Scope CurrentUser -Force -Verbose

# Edit ./generate templates

# Generate the variants
Generate-DockerImageVariants .

Variant versions

versions.json contains a list of Semver versions, one per line.

To update versions in versions.json:

./Update-Versions.ps1

To update versions in versions.json, and open a PR for each changed version, and merge successful PRs one after another (to prevent merge conflicts), and finally create a tagged release and close milestone:

$env:GITHUB_TOKEN = 'xxx'
./Update-Versions.ps1 -PR -AutoMergeQueue -AutoRelease

To perform a dry run, use -WhatIf.