Skip to content
Draft
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
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules
tmp
log
.git
.github
*.log
.env
dist
tests
19 changes: 19 additions & 0 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Create Docker image and deploy

on:
workflow_dispatch:
push:
branches:
- main

jobs:
flow:
name: Highsoft Flow
uses: highsoft-corp/hs-platform-workflows/.github/workflows/flow_docker.yml@feat/multi-env-builds
secrets: inherit
with:
registry: ghcr.io
folder_name: .
image_name: ${{ github.repository }}
use_image_per_environment: false
platforms: linux/amd64

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}
Comment on lines +11 to +19
47 changes: 47 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
FROM node:20-bookworm-slim

ENV NODE_ENV=production \
PUPPETEER_SKIP_DOWNLOAD=true \
PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium \
PUPPETEER_TEMP_DIR=/tmp/hc-export

# Install browser and fonts
RUN apt-get update && apt-get install -y --no-install-recommends \
chromium \
fonts-liberation \
fonts-noto \
fonts-noto-color-emoji \
fonts-noto-cjk \
texlive-fonts-recommended \
texlive-fonts-extra \
cm-super \
fontconfig \
ca-certificates \
curl \
unzip \
&& rm -rf /var/lib/apt/lists/*

# Install Highcharts export server fonts
RUN curl -fsSL https://assets.highcharts.com/export-srv/fonts.zip -o /tmp/fonts.zip \
&& mkdir -p /usr/share/fonts/highcharts \
&& unzip -o /tmp/fonts.zip -d /usr/share/fonts/highcharts \
&& rm /tmp/fonts.zip \
&& fc-cache -f

WORKDIR /app

# Install deps
COPY package*.json ./
RUN npm ci --omit=dev --ignore-scripts

COPY . .

# Set up temp folder
RUN mkdir -p /tmp/hc-export && chown -R node:node /app /tmp/hc-export

# Run as unprivileged node user
USER node

EXPOSE 7801

CMD ["node", "./bin/cli.js", "--enableServer", "1", "--loadConfig", "./docker/config.json"]
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,42 @@ To use the Export Server, simply run the following command with the correct argu
highcharts-export-server <arguments>
```

# Running with Docker

Build and run:

```
docker build -t highcharts-export-server .
docker run --rm -p 7801:7801 highcharts-export-server
```

Or with Docker Compose:

```
docker compose up --build
```

The server listens on port `7801`. Test it with `curl http://localhost:7801/health`.

Settings can be overridden at runtime with environment variables, which take
precedence over the loaded config file. For example, to allow a few concurrent
workers or change the port:

```
docker run --rm -p 8080:8080 \
-e POOL_MAX_WORKERS=4 \
-e SERVER_PORT=8080 \
highcharts-export-server
```

By default the server fetches Highcharts scripts from the CDN on first export
(and caches them), so the container needs outbound network access on startup.
For fully offline operation, use the bundled `highcharts` dependency instead:

```
docker run --rm -p 7801:7801 -e HIGHCHARTS_USE_NPM=true highcharts-export-server
```

# Configuration

There are four main ways of loading configurations:
Expand Down
6 changes: 6 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
services:
export-server:
build: .
ports:
- "7801:7801"
restart: unless-stopped
65 changes: 65 additions & 0 deletions docker/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"pool": {
"minWorkers": 1,
"maxWorkers": 1
},
"other": {
"browserShellMode": false
},
"logging": {
"toFile": false,
"toConsole": true
},
"puppeteer": {
"args": [
"--allow-running-insecure-content",
"--ash-no-nudges",
"--autoplay-policy=user-gesture-required",
"--block-new-web-contents",
"--disable-accelerated-2d-canvas",
"--disable-background-networking",
"--disable-background-timer-throttling",
"--disable-backgrounding-occluded-windows",
"--disable-breakpad",
"--disable-checker-imaging",
"--disable-client-side-phishing-detection",
"--disable-component-extensions-with-background-pages",
"--disable-component-update",
"--disable-default-apps",
"--disable-dev-shm-usage",
"--disable-domain-reliability",
"--disable-extensions",
"--disable-features=CalculateNativeWinOcclusion,InterestFeedContentSuggestions,WebOTP",
"--disable-hang-monitor",
"--disable-ipc-flooding-protection",
"--disable-logging",
"--disable-notifications",
"--disable-offer-store-unmasked-wallet-cards",
"--disable-popup-blocking",
"--disable-print-preview",
"--disable-prompt-on-repost",
"--disable-renderer-backgrounding",
"--disable-search-engine-choice-screen",
"--disable-session-crashed-bubble",
"--disable-setuid-sandbox",
"--disable-site-isolation-trials",
"--disable-speech-api",
"--disable-sync",
"--enable-unsafe-webgpu",
"--hide-crash-restore-bubble",
"--hide-scrollbars",
"--metrics-recording-only",
"--mute-audio",
"--no-default-browser-check",
"--no-first-run",
"--no-pings",
"--pipe",
"--no-startup-window",
"--password-store=basic",
"--process-per-tab",
"--use-mock-keychain",
"--no-sandbox",
"--no-zygote"
]
}
}
14 changes: 11 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading