alvarcarto / url-to-pdf-api

Web page PDF/PNG rendering done right. Self-hosted service for rendering receipts, invoices, or any content.
MIT License
7.01k stars 774 forks source link

Support for docker alpine image #64

Closed alexsergeyev closed 5 years ago

alexsergeyev commented 6 years ago

Build based on puppeteer documentation https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md

Also based on some changes in https://github.com/alvarcarto/url-to-pdf-api/pull/48 It includes two builds for production and development use.

Production build uses NODE_ENV=production and makes small images (139MB compressed) with ready to use service in docker/kubernetes environment

Development build allow to modify code in local fs and uses docker-compose volumes.

docker-compose up - to start application in development mode (NODE_ENV=development) docker-compose run app npm test - to run specs

All changes compatible to use application in local install same as before. It adds couple new ENV variables to allow to work with docker:

HOST=0.0.0.0 for Docker and fallback to localhost as on master CHROME_PATH=/usr/bin/chromium-browser to use system chrome for alpine

Unofficial build also available at docker-hub.

docker run -p9000:9000 mgyk/url-to-pdf-api
curl "http://localhost:9000/api/render?url=https://github.com/" -o test.pdf