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

dockerfile updated #15

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:

strategy:
matrix:
node-version: [14.x, 16.x]
node-version: [16.x, 17.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Based on https://developers.google.com/web/tools/puppeteer/troubleshooting#running_puppeteer_in_docker

FROM node:16.15.0
FROM --platform=linux/amd64 node:17

RUN apt-get update \
&& apt-get install -y wget gnupg ca-certificates \
Expand Down Expand Up @@ -50,6 +50,6 @@ RUN npm i

EXPOSE 8080 8081

ENTRYPOINT [ "node", "./src/server.js", "-H", "8081" ]
ENTRYPOINT [ "node", "--no-deprecation", "./src/server.js", "-H", "8081" ]

CMD ["bash"]
2 changes: 1 addition & 1 deletion __tests__/samples/fileprotocol/data.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"html": [
{ "html" : "<!DOCTYPE html><html class=\"\" style=\"width: 8.25in; height: 11.69in;\"><head><meta content=\"text/html; charset=UTF-8\" http-equiv=\"Content-Type\"/><title></title><link rel=\"stylesheet\" href=\"file:///C:/foo.css\"><link rel=\"stylesheet\" href=\"file:///home/bar.css\"><style>body {background-image: url(\"file:///home/buz.css\");}</style><link rel=\"stylesheet\" href=\"https://bryntum.com/examples/build/grid.stockholm.css?455383\"></head><body></body></html>" }
{ "html" : "<!DOCTYPE html><html class=\"\" style=\"width: 8.25in; height: 11.69in;\"><head><meta content=\"text/html; charset=UTF-8\" http-equiv=\"Content-Type\"/><title></title><link rel=\"stylesheet\" href=\"file:///C:/foo.css\"><link rel=\"stylesheet\" href=\"file:///home/bar.css\"><style>body {background-image: url(\"file:///home/buz.css\");}</style><link rel=\"stylesheet\" href=\"https://bryntum.com/products/grid/build/grid.stockholm.css?455383\"></head><body></body></html>" }
],
"orientation": "portrait",
"format": "A4",
Expand Down
2 changes: 1 addition & 1 deletion __tests__/samples/parallel/parallel2.json

Large diffs are not rendered by default.

Binary file modified __tests__/samples/smoke/base_https.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion __tests__/samples/smoke/base_https.pdf.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion __tests__/samples/smoke/base_https.png.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ services:
build: .
image: bryntum_pdfexport_server
container_name: bryntum_pdfexport_server
# Allows Apple M chips to run this image
platform: linux/amd64
ports:
- "8080:8080"
- "8081:8081"
68 changes: 19 additions & 49 deletions docs/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,41 +29,19 @@ The solution main requirements are listed below. For the full list of required m

**NOTE:** Please read the required libraries licensing info on the projects web-sites.


### Puppeteer

The solution uses puppeteer module to generate PDF and PNG files:

https://www.npmjs.com/package/puppeteer
The solution uses [puppeteer module](https://www.npmjs.com/package/puppeteer) to generate PDF and PNG files.

When building, puppeteer versions for Windows, Linux and Mac are downloaded and placed into the bin directory in the chromium folder.

We recommend using [email protected] (default) as it generates PDFs faster than later versions.

### HummusJS

PDF streams are concatenated with the "HummusJS" module:

https://www.npmjs.com/package/hummus

The HummusJS module contains a binary which need to be shipped with the server executable. The binary is placed under:

./bin/{os}/hummus/binding
### MuhammaraJS

Binaries are built for node 8.9.4, so it is recommended to build server using
same node version. If you have different node version, you might consider
[Node version manager](https://github.com/creationix/nvm) to switch node
to 8.9.4 and back. Or you can rebuild hummus binary for required platform and your local node version.

When the binary does not fit the requirements of your operating system then replace the corresponding binary with the one which is built with `npm install`

./node_modules/hummus/binding
PDF streams are concatenated with the [MuhammaraJS module](https://www.npmjs.com/package/muhammara). Muhammara replaces the previously used HummusJS module, which is no longer maintained. It means we now support newer Node versions, but minimal supported version is 14.

### Merge-img

PNG streams are concatenated with "merge-img" module:

https://www.npmjs.com/package/merge-img
PNG streams are concatenated with [merge-img module](https://www.npmjs.com/package/merge-img)

### SSL certificate (if you are running HTTPS)

Expand All @@ -88,15 +66,12 @@ server address

### Pkg

The solution is wrapped into an executable with "pkg" module:

https://www.npmjs.com/package/pkg
The solution is wrapped into an executable with [pkg module](https://www.npmjs.com/package/pkg).

On build the "pkg" module wraps the `./src/server.js` into an OS specific executable. The output is copied to:

./bin/{os}/


## Building the solution

When all requirements are met. Feel free to adjust the code to your needs and build the solution:
Expand All @@ -114,33 +89,28 @@ The output is placed in the bin directory having the following structure:
- server.key
- chromium
- {os}-{version}
- hummus
- binding

In the `cert` folder you can place your security certificates when running the server as https.

The hummus binary is defaultly shipped and build for Linux/Windows and Mac. When the binary does not fit the requirements of the specific operating system, then copy the binary from the `node_modules` folder as described above.

## Known problems

1. PNG export doesn't work in WSL environment (see [details](#buildinginwsl) below).
2. WSL cannot properly build server for Windows (use Windows version of node to build it).

When encountering any problems on the build:

- Check the requirements based on the used packages, like `nodejs -v` is 8+.
- Delete the `node_modules` folder,
- Delete the `cert` and `chromium` folders in the bin folder (except the HummusJS binaries - else you have to recopy the hummus binding from the `node_modules` folder).
- Delete the server executables in the bin folder.
- Check the requirements based on the used packages, for example that `nodejs -v` is 16+.
- Delete the `node_modules` folder.
- Delete the `cert` and `chromium` folders in the `bin` folder.
- Delete the server executables in the `bin` folder.

## Starting the node server

The server can by executed as a node script:
The server can be executed as a node script:

cd ./server
node src/server.js


<a name="windows"></a>

## Windows
Expand Down Expand Up @@ -172,14 +142,14 @@ group policy:

#### Node cannot rename certain file

At some point during the build process you might see exception of the
following nature:
At some point during the build process you might see the following exception:

Error: EPERM: operation not permitted, rename

There is a similar [issue on github](https://github.com/react-community/create-react-native-app/issues/191)
which shows that multiple users experience this problem with anti-virus
software enabled. There might be a Windows Defender enabled on your machine and then disabling it fixes the issue. But disabling anti-virus completely is not safe. You might consider adding *node.exe* to the list of exceptions for your anti-virus software.
There is a similar [issue on GitHub](https://github.com/react-community/create-react-native-app/issues/191)
which shows that multiple users experience this problem with antivirus software enabled. Windows
Defender might be enabled on your machine, and then disabling it fixes the issue. But disabling antivirus completely is not safe.
Instead we recommend adding *node.exe* to the list of exceptions for your antivirus software.
[Here](https://blog.johnnyreilly.com/2017/06/windows-defender-step-away-from-npm.html)
is a short sum-up of this issue and steps to fix Windows Defender.

Expand Down Expand Up @@ -214,11 +184,11 @@ rough edges still (like puppeteer support).

Server can be built/run in WSL, with few limitations. See compatibility table below:

| Built on | Running on WSL | Running on Windows | Running on Linux |
| Built on | Running on WSL | Running on Windows | Running on Linux |
|----------|:--------------------:|:------------------:|:----------------:|
| WSL | PDF only w/o sandbox | Doesn't work | PDF/PNG |
| Windows | PDF only w/o sandbox | PDF/PNG | PDF/PNG |
| Linux | PDF only w/o sandbox | PDF/PNG | PDF/PNG |
| WSL | PDF only w/o sandbox | Doesn't work | PDF/PNG |
| Windows | PDF only w/o sandbox | PDF/PNG | PDF/PNG |
| Linux | PDF only w/o sandbox | PDF/PNG | PDF/PNG |

Run server inside WSL with no sandbox, e.g.:

Expand Down
14 changes: 11 additions & 3 deletions docs/compatibility.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
## Compatibility

| pdf-export-server | ExtScheduler/ExtGantt | Bryntum Grid/Scheduler/Gantt |
|-------------------|---|---|
| 1.0.0 | * | * |
| 1.0.1 | * | * |
|-------------------|-----------------------|------------------------------|
| 1.0.0 | * | * |
| 1.0.1 | * | * |

## Supported NodeJS versions

| pdf-export-server | NodeJS version | Note |
|-------------------|----------------|-----------------------------------------------------------------------------------------------------|
| 1.0.0 | 14, 16 | Lowest Node version which can run code is 8.9. However it is outdated and therefore not recommended |
| 1.0.1 | 14, 16 | |
| 1.1.0 | 16+ | We moved from unsupported HummusJS to MuhammaraJS which has minimal requirement of Node 16 |
Loading