Skip to content

Commit c484ac8

Browse files
authored
Merge pull request #9 from SharinPix/update-viewer-core
Add dockerfile, docker-compose.yml and update README
2 parents 5418060 + 76e9e59 commit c484ac8

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,20 @@ or to build it from source. We supply pre-built versions for usage with NPM and
9797
the `pdfjs-dist` name. For more information and examples please refer to the
9898
[wiki page](https://github.com/mozilla/pdf.js/wiki/Setup-pdf.js-in-a-website) on this subject.
9999

100+
## Using PDF.js in docker
101+
+ Remove package `"@jazzer.js/core"` from `package.json`.
102+
+ In `gulpfile.mjs` add the line `server.host='0.0.0.0'` here:
103+
104+
```js
105+
const { WebServer } = await import("./test/webserver.mjs");
106+
const server = new WebServer({ port });
107+
server.host = '0.0.0.0';
108+
server.start();
109+
```
110+
+ Build the docker image using `mutagen-compose build`
111+
+ Start the docker container with `mutagen-compose up pdfjs`
112+
+ Access server at `http://localhost:8888/web/viewer.html`
113+
100114
## Including via a CDN
101115

102116
PDF.js is hosted on several free CDNs:

docker-compose.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
services:
2+
pdfjs:
3+
build: .
4+
container_name: pdfjs_container
5+
ports:
6+
- "8888:8888"
7+
command: bash -c "gulp server"

dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM node:18
2+
3+
RUN useradd -r -m -d /app app
4+
WORKDIR /app
5+
COPY --chown=app:app ./ ./
6+
7+
RUN apt-get update && \
8+
apt-get install -y --no-install-recommends \
9+
libcairo2-dev \
10+
libpango1.0-dev \
11+
libjpeg-dev \
12+
libgif-dev \
13+
librsvg2-dev \
14+
cmake \
15+
python3 \
16+
&& rm -rf /var/lib/apt/lists/*
17+
18+
RUN npm install -g gulp-cli
19+
20+
RUN npm install
21+
22+
USER app
23+
24+
EXPOSE 8888
25+
CMD ["gulp", "server"]

0 commit comments

Comments
 (0)