-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(docker): example how to run in alpine docker image
- Loading branch information
Showing
6 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
FROM node:20.9.0-alpine3.18 | ||
|
||
RUN apk update && apk add --no-cache make g++ python3 ghostscript graphicsmagick ghostscript-fonts | ||
|
||
WORKDIR /worker | ||
COPY . /worker | ||
|
||
RUN npm install | ||
|
||
CMD node index.mjs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Example Docker alpine | ||
|
||
Build the image: | ||
```shell | ||
docker build -t pdf2pic-docker . | ||
``` | ||
|
||
Run the container: | ||
```shell | ||
docker run pdf2pic-docker | ||
``` |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { fromBuffer } from 'pdf2pic'; | ||
import fs from 'fs/promises' | ||
|
||
const pdfBuffer = await fs.readFile('example.pdf'); | ||
const convert = fromBuffer(pdfBuffer, { width: 1024, preserveAspectRatio: true }); | ||
const result = await convert(1, { responseType: 'buffer' }); | ||
|
||
console.log(result); | ||
|
||
await fs.writeFile('page_1.png', result.buffer, 'binary'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "example-docker", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.mjs", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"pdf2pic": "^3.1.1" | ||
} | ||
} |