Skip to content

Commit

Permalink
Add a basic Dockerfile (#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterDaveHello authored May 17, 2024
1 parent 6fa6e4f commit 6c46a75
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
.git/
Dockerfile
22 changes: 22 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM node:20-alpine

RUN apk add --no-cache \
chromium \
nss \
freetype \
harfbuzz \
ca-certificates \
ttf-freefont \
font-noto-cjk

WORKDIR /app

COPY package.json package-lock.json ./

RUN npm install

COPY . ./

ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser

ENTRYPOINT ["/app/bin/index.js"]
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,20 @@ mdpdf.convert(options).then((pdfPath) => {
* `header` - A sub object which contains some header settings
* `height` - Height of the documents header in mm (default 45mm). If you wish to use a header, then this must be set.
* `border` - The document borders

## Docker Usage

To build the Docker image for mdpdf, use the following command:

```bash
docker build -t mdpdf .
```

To run mdpdf within a Docker container, you can use the following command. This example mounts the current directory to the `/app` directory inside the container and converts `example.md` to `example.pdf`:

```bash
docker run --rm -v $(pwd):/app mdpdf example.md
```

This allows you to use mdpdf without needing to install Node.js or any dependencies on your host machine, only Docker is required.

0 comments on commit 6c46a75

Please sign in to comment.