Skip to content

Add dockerfile, docker-compose.yml and update README #9

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

Merged
merged 2 commits into from
Oct 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,20 @@ or to build it from source. We supply pre-built versions for usage with NPM and
the `pdfjs-dist` name. For more information and examples please refer to the
[wiki page](https://github.com/mozilla/pdf.js/wiki/Setup-pdf.js-in-a-website) on this subject.

## Using PDF.js in docker
+ Remove package `"@jazzer.js/core"` from `package.json`.
+ In `gulpfile.mjs` add the line `server.host='0.0.0.0'` here:

```js
const { WebServer } = await import("./test/webserver.mjs");
const server = new WebServer({ port });
server.host = '0.0.0.0';
server.start();
```
+ Build the docker image using `mutagen-compose build`
+ Start the docker container with `mutagen-compose up pdfjs`
+ Access server at `http://localhost:8888/web/viewer.html`

## Including via a CDN

PDF.js is hosted on several free CDNs:
Expand Down
7 changes: 7 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
services:
pdfjs:
build: .
container_name: pdfjs_container
ports:
- "8888:8888"
command: bash -c "gulp server"
25 changes: 25 additions & 0 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM node:18

RUN useradd -r -m -d /app app
WORKDIR /app
COPY --chown=app:app ./ ./

RUN apt-get update && \
apt-get install -y --no-install-recommends \
libcairo2-dev \
libpango1.0-dev \
libjpeg-dev \
libgif-dev \
librsvg2-dev \
cmake \
python3 \
&& rm -rf /var/lib/apt/lists/*

RUN npm install -g gulp-cli

RUN npm install

USER app

EXPOSE 8888
CMD ["gulp", "server"]
Loading