Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Add Dockerfile for easier usage and integration #293

Open
PeterDaveHello opened this issue May 15, 2024 · 7 comments
Open

feature: Add Dockerfile for easier usage and integration #293

PeterDaveHello opened this issue May 15, 2024 · 7 comments
Labels

Comments

@PeterDaveHello
Copy link

Problem:

The md-to-pdf project currently lacks a Dockerfile, which may lead to:

  1. Complicated setup process for users who need to manually install Node.js, headless Chrome, and other dependencies on their local machines.
  2. Inconsistent runtime environments across different systems, increasing the chances of encountering issues due to varying configurations.
  3. Difficulty in deploying the tool on various platforms and cloud services that support Docker containers.
  4. Challenges in integrating md-to-pdf into CI/CD pipelines for automated conversion of Markdown files to PDF.

Solution:

Add a Dockerfile to the project, providing an official, containerized environment with all necessary dependencies pre-installed. This would simplify the setup process, ensure consistency across different systems, enhance portability, and enable seamless integration with CI/CD pipelines.

If you believe this feature would be valuable to the project, I would be happy to submit a pull request containing a basic Dockerfile. Please let me know your thoughts on this suggestion. Thank you for considering this proposal!

@simonhaenisch
Copy link
Owner

simonhaenisch commented May 17, 2024

Hey sure why not, can we base it on the one from https://pptr.dev/guides/docker?

FROM ghcr.io/puppeteer/puppeteer:latest

RUN npm install --global md-to-pdf

CMD [md-to-pdf]

sth like this?

@PeterDaveHello
Copy link
Author

We can, just the image seems to be a little bit huge, but maybe nobody cares? I don't know. Let me know if you have preference, maybe I can help test and send a PR for it.

@simonhaenisch
Copy link
Owner

simonhaenisch commented May 17, 2024

google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-khmeros fonts-kacst fonts-freefont-ttf libxss1 dbus dbus-x11

this is the list of packages it installs (source), what would you omit? Or would you not base it on node:20? Not sure how to make it smaller 🤷🏻‍♂️

Edit: maybe by not installing Chrome, and letting the puppeteer package download it post-install instead? Hm or maybe it's better to just also add ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD 1.

@simonhaenisch
Copy link
Owner

FROM ghcr.io/puppeteer/puppeteer:latest

ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD 1

USER root

RUN npm install --global md-to-pdf

USER pptruser

ENTRYPOINT ["md-to-pdf"]

CMD ["--help"]

this is what I came up with now and seems to work fine but happy to get a better suggestion (:

$ docker build . -t md-to-pdf

then

$ docker run -v $(pwd):$(pwd) -w $(pwd) md-to-pdf readme.md

[11:06:17] generating PDF from readme.md [started]
[11:06:24] generating PDF from readme.md [completed]

@PeterDaveHello
Copy link
Author

I used to use Alpine-based node.js image and install the dependencies as mentioned here, but no guarantee which is better:

https://pptr.dev/troubleshooting/#running-on-alpine

@simonhaenisch
Copy link
Owner

Might be better cause the Puppeteer image comes with Puppeteer pre-installed which we don't actually need. But I like that this way we don't need to define/maintain a list of deps to install, leaving that to the Puppeteer team 🤓

@PeterDaveHello
Copy link
Author

Sure, sounds great, I found the image even correctly handles Chinese fonts already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants