Carbone On-Premise

Take control of your document generation security and privacy by utilizing Carbone On-premise on your own infrastructure. Our On-premise solution mirrors the powerful Carbone Cloud API, offering a host of exclusive advantages:

  • Unlimited Document Generation and Formats: Experience limitless possibilities for creating and managing documents in various formats.
  • Timeless Usage: Enjoy unrestricted access to Carbone On-premise with no time limitations.
  • Seamless Scalability: Deploy Carbone On-premise across unlimited servers, it grows with your business, making document generation smooth and scalable.
  • Offline Functionality: Run Carbone On-premise without the need for internet access, ensuring uninterrupted operations.
  • Enterprise-Grade Features: Harness all enterprise features, including dynamic images, colors, barcodes, aggregators, HTML rendering, and more.
  • Stateless and Lightweight Carbone Studio Version: Design templates and get a live preview of documents from a streamlined version of Carbone Studio with basic authentication.
  • Easy Installation: Install Carbone server effortlessly, a binary file; it is compatible with containers and can be securely deployed in Ubuntu & Debian's self-configured systemd sandbox.
  • Extensibility with JS Plugins: Customize your experience by adding JavaScript plugins to override storage, authentication, and formatters.
  • SLA support: Receive top-notch support with Service Level Agreement (SLA) coverage, ensuring peace of mind.
  • Continuous Updates: Stay ahead with all incoming updates, ensuring your Carbone On-premise is always up-to-date.
  • Free trial period: Explore the capabilities of Carbone On-premise risk-free with our free trial period.

Pricing for Carbone On-premise is customized based on your company's income and subsidiaries. Licenses are specific to each project or product, ensuring tailored value.

For detailed pricing information or to request a free trial license, contact sales on the chat or by email: contact@carbone.io.

Client Side

API flow

Carbone On-Premise works the same way as Carbone Cloud API,

To generate a document, you have to:

  1. Upload a template POST /template to get a template ID. The template is stored in your file system into the directory template. It is possible to store templates into a custom storage system (s3, object storage)
  2. Generate a report POST /render/:templateId from the template ID and a JSON data-set, then the request returns a unique usable render ID.
  3. Download the report GET /render/:renderId thanks to the render ID.
  4. To get a new document, repeat the process from point 2.

API endpoints

API integration

Software Development Kits

SDKs are available to integrate the Carbone Cloud API into your service/application in a few lines of code:

API Clients for Windows / MacOS / Linux

To test the Cloud API in a few minutes, load a pre-made API specification into:

Terminal

Create your own API integration

Learn more on the Cloud API specification, all API endpoint are details to create your HTTP client on your own language.

Server Install

Carbone On-premise can be installed in different ways:

  • Self-contained binary executable + external LibreOffice
  • Docker container (Libre Office is included)

Basic Install

  1. Download the license and the Carbone On-premise binary for server/OS: Mac, Linux or Windows
  2. On your terminal run chmod +x carbone-ee in order to execute the binary.
  3. Install LibreOffice Link to instructions.
  4. Prepare the license key to be loaded, multiple solution:
    • Set the Environment Variable CARBONE_EE_LICENSE with the license key as the value
    • Or pass the CLI option --license followed by the license key as the value when you start the server (step 5)
    • Or insert the license file in the "config" directory. If the directory doesn't exist, it must be created next to the Carbone On-premise binary. If multiple licenses are available, only the latest license is selected. The binary can't start if the license is outdated or invalid.
  5. Start Carbone web server. It is possible to pass options to Carbone On-Premise through the CLI:
  ./carbone webserver --port 4000 --workdir .

The Carbone server is listening on http://localhost:4000.
To change Carbone server configuration, set options.

If an error appears during the start up, you must verify:

  • if your license is valid
  • if CLI options and values are valid

Systemd Install

Carbone On-Premise contains automatic installation scripts to daemonize with systemd. It has been carefully configured to provide a high level of security. The Systemd installation is working only for Ubuntu or Debian.

  # Generate installation scripts
  ./carbone install
  # Execute installation scripts and follow instructions
  sudo ./install.sh

The Carbone server is listening on http://localhost:4000.
To change Carbone server configuration, set options.

The service is configured to run with "carbone" user (automatically created) in the "/var/www/carbone-ee" directory. It is possible to overwrite values through environment variables CARBONE_USER and CARBONE_WORKDIR.

You must install LibreOffice to generate PDF documents, read instructions.

Docker CLI Install

A pre-built image of Carbone is available on Docker Hub.

On your terminal, start a Carbone container with the following command line.

$ export CARBONE_EE_LICENSE=`MY_CARBONE_LICENSE`

$ docker run --platform linux/amd64 -p 4000:4000 -e LANG=C.UTF-8 -e CARBONE_EE_LICENSE carbone/carbone-ee 

## add the flag "-d" to run it as a background process

Two Carbone images are available for each version:

  • carbone/carbone-ee:latest: Latest version of Carbone containing only standard Debian fonts.
  • carbone/carbone-ee:latest-fonts: Latest version of Carbone containing standard Debian fonts and all Google Fonts (royalty-free).

The Carbone server is listening on http://localhost:4000.
To change Carbone server configuration, add environment variables.
To persist templates and generated documents, you must create two volumes.

Docker Compose Install

A pre-built image of Carbone is available on Docker Hub.
Example of docker-compose.yml to run a Carbone container and pass the license as environment variable CARBONE_EE_LICENSE:

version: "3.9"
services:
  carbone:
    image: carbone/carbone-ee:latest
    platform: linux/amd64
    ports:
      - "4000:4000"
    environment:
      - CARBONE_EE_STUDIO=true
      - CARBONE_EE_LICENSE="my_onpremise_license"
      - LANG=C.UTF-8

Example of docker-compose.yml to run a Carbone container and pass the license as local file my_license.carbone-license:

version: "3.9"
services:
  carbone:
    image: carbone/carbone-ee:latest
    platform: linux/amd64
    ports:
      - "4000:4000"
    secrets:
      - secret.carbone-license
    environment:
      - CARBONE_EE_STUDIO=true
      - CARBONE_EE_LICENSEDIR=/run/secrets/
      - LANG=C.UTF-8
secrets:
  secret.carbone-license:
    file: my_license.carbone-license

The Carbone server is listening on http://localhost:4000.
To change Carbone server configuration, add environment variables.
To persist templates and generated documents, you must create two volumes.

Docker CLI - Build yourself

Contact the support if you want to build your own image of Carbone, we will provide you the Dockerfile.

Build the image with the command:

$ docker build --platform "linux/amd64" -t carbone-ee:latest .

Then start the container:

$ docker container run --name carbone-ee -p 4000:4000 --platform linux/amd64 --volume=/var/tmp/key:/key --env CARBONE_EE_LICENSEDIR=/key --entrypoint ./carbone-ee-linux carbone-ee:latest webserver

## add the flag "-d" to run it as a background process

The server is listening by default on http://localhost:4000.
To change Carbone server configuration, add environment variables through the Docker command.

Stop the container:

$ docker stop carbone-ee

Remove the container:

$ docker container rm carbone-ee

Docker Compose - Build yourself

Contact the support if you want to build your own image of Carbone, we will provide you the Dockerfile.

Open a terminal where the Dockerfile and the docker-compose.yml are located.

Start the server with the command:

$ docker-compose up
## For background mode, add the -d option

The server is listening by default on http://localhost:4000.
To change Carbone server configuration, add environment variables into the Docker-compose.yml.

Command to stop the container without removing it:

$ docker-compose stop

Command to stop the container and removes the container, networks, volumes, and images created by up:

$ docker-compose down

Discover more Docker commands by reading the docker-compose CLI overview.

LibreOffice Install

Carbone uses efficiently LibreOffice to convert documents. Among all tested solutions, it is the most reliable and stable one in production for now. Behind the scene, Carbone server does:

  • starts LibreOffice in "server-mode": headless, no User Interface loaded
  • manages multiple LibreOffice workers to maximize performance (configurable number of workers)
  • automatically restarts LibreOffice worker if it crashes or does not respond
  • job queue, re-try conversion two times if something bad happen

Installing Carbone On-premise with docker doesn't need LibreOffice to be installed, it is already included on the Docker image.

Install for:

  # remove all old version of LibreOffice
  sudo apt remove --purge libreoffice*
  sudo apt autoremove --purge

  # Download LibreOffice debian package. Select the right one (64-bit or 32-bit) for your OS.
  # Get the latest from http://download.documentfoundation.org/libreoffice/stable
  # or download the version currently "carbone-tested":
  wget https://downloadarchive.documentfoundation.org/libreoffice/old/7.4.1.1/deb/x86_64/LibreOffice_7.4.1.1_Linux_x86-64_deb.tar.gz

  # Install required dependencies on ubuntu server for LibreOffice 7.0+
  sudo apt update
  sudo apt install libxinerama1 libfontconfig1 libdbus-glib-1-2 libcairo2 libcups2 libglu1-mesa libsm6 libnss3

  # Uncompress package
  tar -zxvf LibreOffice_7.4.1.1_Linux_x86-64_deb.tar.gz
  cd LibreOffice_7.4.1.1_Linux_x86-64_deb/DEBS

  # Install LibreOffice
  sudo dpkg -i *.deb

  # If you want to use Microsoft fonts in reports, you must install the fonts
  # Andale Mono, Arial Black, Arial, Comic Sans MS, Courier New, Georgia, Impact,
  # Times New Roman, Trebuchet, Verdana,Webdings)
  sudo apt install ttf-mscorefonts-installer

  # If you want to use special characters, such as chinese ideograms, you must install a font that support them
  # For example:
  sudo apt install fonts-wqy-zenhei

Server Options

Options list

Carbone default parameters can be overwritten through:

If an option is reported in different places, CLI options are picked in priority, then environment variables in second place, and finally the configuration file.

Options Default Values Description CLI options ENV
port 4000 Service PORT --port / -p CARBONE_EE_PORT
workdir Actual directory Defines the Carbone working directory to store templates, generated documents, and resources. It creates 6 directories:
- template : for storing templates (cache)
- render : for storing generated documents
- asset : used by Carbone
- config : for storing the config.json, licenses and ES512 keys for authentication
- plugin : for storing custom javascript plugins
--workdir / -w CARBONE_EE_WORKDIR
licenseDir "config/" Absolute directory path to licenses --licenseDir / -L CARBONE_EE_LICENSEDIR
license License as a string, if the option is used, licenseDir option is skipped --license / -l CARBONE_EE_LICENSE
factories 1 Multithread parameter, number of LibreOffice converter --factories / -f CARBONE_EE_FACTORIES
attempts 1 If LibreOffice fails to convert one document, attempts options set the number of re-try --attemps / -a CARBONE_EE_ATTEMPTS
authentication false Authentification documentation at the following link --authentication / -A CARBONE_EE_AUTHENTICATION
studio false Web interface to preview reports. Learn more. --studio / -s CARBONE_EE_STUDIO
studioUser admin:pass If the authentication option is enabled, the browser requests an authentication to access the web page. Credentials have to be formated, such as: [username]:[password]. --studioUser / -S CARBONE_EE_STUDIOUSER
maxDataSize 60MB Maximum JSON data size accepted when rendering a report, the value must be bytes. Calcul example: 100 * 1024 * 1024 = 100MB --maxDataSize / -mds CARBONE_EE_MAXDATASIZE
maxTemplateSize 20MB The file size limit when uploading a new template through the request POST /template, the value must be bytes. Calcul example: 30 * 1024 * 1024 = 30MB CARBONE_EE_MAXTEMPLATESIZE
templatePathRetention 0 Template path retention in days. 0 means infinite retention. --templatePathRetention / -r CARBONE_EE_TEMPLATEPATHRETENTION
lang en Locale language used by Carbone --lang / -l CARBONE_EE_EN
timezone Europe/Paris Timezone for managing dates --timezone / -t CARBONE_EE_TIMEZONE
currencySource Currency source for money conversion. If empty, it depends on the locale. --currencySource / -cs CARBONE_EE_CURRENCYSOURCE
currencyTarget Currency target for money conversion. If empty, it depends on the locale. --currencyTarget / -ct CARBONE_EE_CURRENCYTARGET
currencyRates { EUR : 1, USD : 1.14, ... } Currency rates, it is based on EUR which should be equals to "1". The option can only be set on the config/config.json file.
translations {} Translation object loaded at startup. It can be overwritten by rendering requests. The option can only be set on the config/config.json file.
converterFactoryTimeout 60000 Maximum conversion/socket timeout for one render (unit: ms) CARBONE_EE_CONVERTERFACTORYTIMEOUT
xlsmEnabled false Accept xlsm export --xlsmEnabled / -xe CARBONE_EE_XLSMENABLED
collectStatistics true Carbone gathers anonymous usage data to enhance our understanding, monitor performance, and support users. We strongly advise keeping collectStatistics enabled to benefit from useful features and contribute to Carbone's continuous improvement. Nevertheless, you have the option to disable collectStatistics for the entire Carbone instance by settings the value false. CARBONE_EE_COLLECTSTATISTICS

Options through CLI

To list available options, run the help command, such as:

./carbone webserver --help

Here is an example of passing options to the service:

./carbone webserver --port 4001 --factories 4 --workdir /var/www/carbone --attemps 2 --authentication --studio

Options as Configuration file

To use a configuration file, config.json must be created in the config folder. Here is an example of a configuration:

{
  "port": 4001,
  "bind": "127.0.0.1",
  "factories": 4,
  "attempts": 2,
  "authentication": true,
  "studio" : true,
  "studioUser" : "admin:pass" // login:password if authentication is active
}

Options as Environment variables

Environment variables can be used to define options, the name has to be uppercased and has to start with the prefix "CARBONE_EE_", such as:

export CARBONE_EE_PORT=3600
export CARBONE_EE_BIND=127.0.0.1
export CARBONE_EE_FACTORIES=4
export CARBONE_EE_WORKDIR=/var/www/carbone
export CARBONE_EE_ATTEMPTS=2
export CARBONE_EE_AUTHENTICATION=true

Server Authentication

About authentication

By default, all API endpoints are reachable without authentication, and all requests are authorized. An authentication system is available to restrict the access. When activated, all API endpoints are protected by authentication except GET /render/:renderId and GET /status.

Reasons why GET /render/:renderId is not protected:

  • :renderId contains the custom report name in base64, concatenated with a 22-characters-long cryptographically random numbers with unbiased tranformation. It is somehow a unique password for each rendered report. It is better than any authentication mechanism.
  • :renderId is ephemeral, the resource becomes inaccessible once the file is downloaded.
  • The report can be easily downloaded in any browsers / reverse-proxy / application without complex authentication mechanisms

Enable authentication

Three solutions to enable authentication:

  • Passing the argument on the server CLI: --authentication
  • Or, setting on the configuration file: "authentication" : true
  • Or, setting the environment variable: CARBONE_EE_AUTHENTICATION=true

Then the header Authorization must be passed to all requests, with a ES512 JWT token as value. To generate a token, you can:

  • Use the CLI: ./carbone generate-token generates 40-years valid tokens
  • Using standard libraries in any programming languages https://jwt.io/. Programmatically you can generate and renew tokens. The payload must be signed with the generated public key in config/key.pub (ES512). Tokens must contain at least the following payload:
    {
    "iss": "your-carbone-user",
    "aud": "carbone-ee",
    "exp": 2864189447
    }

Server Studio Light

Carbone Studio Light is a web interface to preview reports with a JSON editor. It is a "light" version of https://studio.carbone.io without files and version management. To enable the Carbone Studio Light:

  • Pass the CLI option --studio to the binary, such as: ./carbone webserver --studio
  • Or, set the env variable CARBONE_EE_STUDIO to true
  • Or, set on the configuration file "studio": true.

Then visit the URL http://127.0.0.1:4000 and enjoy!

If the authentication option is enabled, the browser requests an authentication to access the web page.

Server Customisation

Carbone On-premise gives the possibility to override functions at specific moments to add custom features, such as adding analytics, store data on a specific storage provider, custom authentication, etc... It is possible through:

  • Plugins: Functions to manage file storage, authentication, analytics, logs, or custom behaviors.
  • Middlewares: Functions that are fired before or after HTTP requests. It can be useful for logging, statistics, or custom behaviors.

requirement plugins and middlewares can be only written using NodeJS.

For a better understanding, here is the Carbone On-premise lifecycle:

image

Plugins

Following actions can be customized:

Pre-made plugin by the Carbone team:

To create a custom plugin, it is recommended to create a independant NodeJS repository:

# Create a separate folder
mkdir carbone-on-premise

# Initialize a node repository
npm init

# Move the carbone binary inside this folder
mv /path/to/carbone/binary ./carbone-on-premise

When Carbone On-premise is executed for the first time, default folders are created automatically (explanation here). Custom plugins MUST be inserted in the plugin folder.

Custom write template

To override template storage, create the file storage.js in the plugin folder. It will be possible to upload your template into an Object Storage, S3 API or other storage systems. Export a function called writeTemplate with 5 arguments:

  • req: The req object represents the HTTP request and has properties for the request query string, parameters, body, HTTP headers, and so on.
  • res: The res object represents the HTTP response that a server sends when it gets an HTTP request
  • templateId: Unique template ID as a sha256 hash
  • templatePathTemp: Absolute path of the uploaded template
  • callback: callback function

Additional file informations are available the request header:

  • req.headers['carbone-template-extension']: file extension (eg: 'xml')
  • req.headers['carbone-template-mimetype']: file mimetype (eg: 'application/xml')
  • req.headers['carbone-template-size']: file size in bytes
const fs = require('fs');
const path = require('path');
const os = require('os');

function writeTemplate (req, res, templateId, templatePathTemp, callback) {
  fs.rename(templatePathTemp, path.join(os.tmpdir(), 'PREFIX_' + templateId), (err) => {
    if (err) {
      return callback(err);
    }
    return callback(null);
  });
}

// Export the writeTemplate function
module.exports = {
  writeTemplate
}

Custom read template

To override template reading, the file storage.js in the plugin folder has to be created. The function to explort is readTemplate which is described as follow:

function readTemplate (req, templateId, callback) {
  // Read your template and return a local path for carbone
}

module.exports = {
  readTemplate
}

The function must return a local path because Carbone needs to read the file from a disk.

Custom delete template

To override template deletion, add the function deleteTemplate in the storage.js file in the plugin folder and export it, for instance:

// You can access req and res.
// For example, if you store your template on amazon S3, you could delete it
function deleteTemplate (req, res, templateId, callback) {
  // Delete the template and either return a local path to unlink it or just use res to return a response
  return callback(null, path.join(os.tmpdir(), 'PREFIX_' + templateId));
}

module.exports = {
  deleteTemplate
}

Custom write render

To override render writing, add the function afterRender in the storage.js file in the plugin folder and export it.

function afterRender (req, res, err, reportPath, reportName, statistics, next) {
  // Write or rename your render
  // TemplateID available: req.params.templateId
  return next(null)
}

module.exports = {
  afterRender
}

For example, this function can be used to move the render on Buckets, or it is also possible to change the response object:

res.send({
  success: true,
  data: {
    newField: reportName
  }
});

The statistics argument return an object with:

{
  "renderId": "",
  "template": "filename",
  "user"      : "if authentication enabled, the user ID is returned, it is coming from the JWT token",
  "options"   : "Rendering options as an object",
  "jsonSize"  : "size of the JSON data-set as bytes"
}

Custom read render

The function readRender has to be exported in the storage.js located in the plugin folder.

function readRender (req, res, renderName, next) {
  // Return the directly render or a local path
}

This function can be used to return directly the file using res , it is also possible to return the new render name, or return a path from the afterRender function.

// Return the new render name
function readRender (req, res, renderName, next) {
  return next(null, 'newRenderName')
}

// OR

// Return the new path on disk
function (req, res, renderName, next) {
  return next(null, renderName, '/new/path/on/disk')
}

Before Render

Before render plugin can be used to add pre-rendering actions, such as adding a prefix to the rendered filename. To do this, add a function beforeRender in the storage.js plugin. In these functions, the req request variable is available and options can be altered.

function beforeRender (req, res, carboneData, carboneOptions, next) {
  // add a prefix to rendered filename
  carboneOptions.renderPrefix = 'myPrefix';
  next(null);
}

Authentication (Get Public Key)

For the authentication checking, it is possible to define a new location to store public keys. The file authentication.js has to be created in the plugin folder. Export the function getPublicKey described as follow:

const fs = require('fs');
const path = require('path');

/**
 * @param {Object} req : Request from the request
 * @param {Object} res : Response from the request
 * @param {Object} payload : https://github.com/Ideolys/kitten-jwt#api-usage to see object details
 * @param {Function} callback : Function to call at the end
 * @return (publicKeyContent)
 */
function getPublicKey (req, res, payload, callback) {
  // Read the public key on disk or somewhere else
  fs.readFile(path.join(__dirname, '..', 'config', 'key.pub'), 'utf8', (err, content) => {
    if (err) {
      return callback(new Error('Cannot read public key ' + err.toString()));
    }

    // Return the public key content in the callback
    return callback(content)
  });
}

// Export the getPublicKey function
module.exports = {
  getPublicKey
}

Middlewares

Middlewares can be added before or after route. It can be useful to log or get stats about requests. Add a middlewares.js file in the plugin folder and export two arrays:

  • before
  • after
function beforeMiddleware (req, res, next) {
  console.log('I am executed before all route')
  return next()
}

function afterMiddleware (req, res, next) {
  console.log('I am executed after all route')
}

module.exports = {
  before: [beforeMiddleware], // Middlewares in this array will be executed before routes
  after: [afterMiddleware] // Middlewares in this array will be executed after routes
}

Load Plugins for Docker

This section shares three methods to load plugins into you Docker or Kubernetes environment.

First, you must include your plugin files into one folder named plugin, such as:

  • plugin/storage.js
  • plugin/middlewares.js

Mount plugins through the Docker CLI

The following command mount the folder plugin into the /app/plugin as volume thanks to -v ./plugin:/app/plugin. The config folder is also mounted into the /app/config. The config/config.json contains the Carbone On-premise License, and credentials used for the plugin. If you don't use the config folder, you can omit -v ./config:/app/config.

The Carbone server will detect and load automatically plugin/storage.js and plugin/middlewares.js files on start-up.

docker run --platform linux/amd64 --name carbone -p 4000:4000 -e LANG=C.UTF-8 -v ./plugin:/app/plugin -v ./config:/app/config carbone/carbone-ee

Mount plugins through Docker Compose

The following Docker compose file docker-compose.yml starts a Carbone instance and mount two volumes for the plugin and config folders. The Carbone server will detect and load automatically storage.js and middlewares.js files on start-up.

version: "3.9"
services:
  carbone:
    image: carbone/carbone-ee:latest
    platform: linux/amd64
    ports:
      - "4000:4000"
    volumes:
      - ./plugin:/app/plugin
      - ./config:/app/config
    environment:
      - LANG=C.UTF-8

Build a new Carbone image and add the plugin

You can build your custom Carbone image, and it can load plugin and config folders. Create a Dockerfile, then write:

FROM carbone/carbone-ee:latest

USER root

ADD ./plugin /app/plugin
ADD ./config /app/config

RUN chown -R carbone:nogroup /app/config 
RUN chown -R carbone:nogroup /app/plugin 

USER carbone

ENTRYPOINT ./carbone-ee-linux webserver

It will add to the latest image of Carbone your plugin and config folders. Build the image named carbone-custom with the command:

$ docker build --platform "linux/amd64" -t carbone-custom .

Then start the container based on the carbone-custom image:

docker container run --name carbone -p 4000:4000  -e LANG=C.UTF-8 --platform linux/amd64 carbone-custom

The Carbone server will detect and load automatically storage.js and middlewares.js files on start-up.

Server Storage Persistence

When the Carbone instance starts, directories are created next to the binary, and must persist:

  • render: Directory to store generated documents, used by the following API endpoints: POST /render/:templateID, and GET /render/:renderID.
  • template: Directory to store templates, used by the following API endpoints: POST /template, GET /template, and DELETE /template

Two strategies are available to store and access files:

  • For Docker, Kubernetes, SWARM, VM infrastructures: create 2 volumes shared across all pods. For the Docker container, the template and render folders are located into the /app folder.
  • OR, for any infrastructure, create a custom plugin that save and load templates/renders into a remote storage (S3, SWIFT, or other). Plugins are loaded and executed into the Carbone server when the following API endpoints are requested POST|GET|DELETE /template, POST /render/:templateID, and GET /render/:renderID. Click to learn more about plugins.

S3 Persistence

Store your templates and generated document in S3 (AWS, OVHCloud, scaleway, and any S3 provider).
A pre-made plugin is available, follow the configuration on the following link:
https://github.com/carboneio/carbone-ee-plugin-s3

Docker Compose Persistence

The following Docker compose file docker-compose.yml starts a Carbone instance and creates two volumes for template and render folders:

version: "3.9"
services:
  carbone:
    image: carbone/carbone-ee:latest
    platform: linux/amd64
    ports:
      - "4000:4000"
    secrets:
      - source: carbone-license
        target: /app/config/prod.carbone-license
    environment:
      - CARBONE_EE_STUDIO=true
      - LANG=C.UTF-8
    volumes:
      - ./templates:/app/template
      - ./renders:/app/render
secrets:
  carbone-license:
    file: your_license.carbone-license

Details:

  • Templates and generated documents are stored on the host machine directories named templates, and renders .
  • If the container restarts, templates and renders will still be available accessible.
  • In your docker-compose.yml file, a volume is defined under the volumes section. The designation ./templates corresponds to the name of the local folder and /app/template to the name of the folder in the container. Both will be linked.
  • For Docker, the Carbone working directory is /app. It is possible to change the working directory by defining the "workdir" option.

Docker CLI Persistence

Command line for starting a Carbone instance and creating 2 volumes for template and render folders:


$ export CARBONE_EE_LICENSE=`MY_CARBONE_LICENSE`

$ docker run --platform linux/amd64 -p 4000:4000 -e LANG=C.UTF-8 -e CARBONE_EE_LICENSE -v $(pwd)/renders:/app/render -v $(pwd)/templates:/app/template carbone/carbone-ee:latest

Details:

  • Templates and generated documents are stored on the host machine directories named templates, and renders .
  • If the container restarts, templates and renders will still be available accessible.
  • To mount a directory from the host machine into a container using the docker run command, you can use the -v or --volume option. Here's the syntax: docker run -v /host/path:/container/path carbone/carbone-ee:latest Replace /host/path with the absolute path of the directory on the host machine that you want to mount, and /container/path with the corresponding path inside the container, either /app/template or /app/render.
  • The $(pwd) stands for "print working directory." When you use $(pwd) in a command, it gets replaced with the current working directory's absolute path.
  • For Docker, the Carbone working directory is /app. It is possible to change the working directory by defining the "workdir" option.

Server Fonts

To use a custom font into a document, you must install the font on your operating system. When Carbone server is started, fonts from the OS are loaded automatically.

To install a custom font, you typically need to copy the font file(s) to a specific directory where the system can find and use them. Here are the general steps to install a custom font for each Carbone On-premise installation method:

Install font into Linux

  1. Locate the Font File: First, make sure you have the font file(s) you want to install. These are often in TrueType Font (.ttf) or OpenType Font (.otf) format.
  2. Copy the Font File(s): Copy the font file(s) to one of the system font directories. A common location for user-installed fonts is ~/.local/share/fonts/ for individual users or /usr/local/share/fonts/ for system-wide installation. You might need administrative privileges to copy files to system-wide directories. For example, you can use the cp command to copy the font file(s) to the appropriate directory:
    cp /path/to/font.ttf /usr/local/share/fonts/
  3. Update the Font Cache: After copying the font file(s), you need to update the font cache so that the system recognizes the new font(s). You can do this using the fc-cache command. Run the following command in your terminal:
    fc-cache -f -v
    This command will rebuild the font cache, making the newly installed fonts available to the system.
  4. Restart the Carbone Server: You need to restart the Carbone server to load the newly installed font(s).

Install font into Carbone Docker

You'll find two Carbone images per version on Dockerhub:

  • carbone/carbone-ee:latest: Latest version of Carbone containing only standard Debian fonts.
  • carbone/carbone-ee:latest-fonts: Latest version of Carbone containing standard Debian fonts and all Google Fonts (royalty-free).

If you wish to use custom fonts, there are three methods to load them:

Load fonts by building a new Carbone docker image

For creating a new Carbone image with custom fonts, first create Dockerfile:

FROM carbone/carbone-ee:latest-fonts

USER root

RUN mkdir /usr/share/fonts/custom_fonts

COPY ./*.ttf /usr/share/fonts/custom_fonts

RUN fc-cache -f -v

USER carbone

ENTRYPOINT ./carbone-ee-linux webserver

All the font files ending with .tff are copied into the custom_fonts directory. Then is it required to rebuild the font cache with fc-cache -f -v, making the newly installed fonts available to the system.

Build the image named carbone-custom with the command:

docker build --platform "linux/amd64" -t carbone-custom .

Then start the container based on the carbone-custom image:

docker container run --name carbone -p 4000:4000  -e LANG=C.UTF-8 --platform linux/amd64 carbone-custom

The Carbone server will detect and load automatically font files on start-up.

Load fonts as volume with Docker CLI

To load custom fonts using Docker CLI, you would typically mount a volume containing the font files into the container.

Using volumes allows you to keep the font files outside of the container and mount them into the container at runtime. This approach can be useful if you want to keep your Docker image smaller or if you need to update the fonts without rebuilding the image.

Run the Carbone Docker container with a volume: When running your container, use the -v flag to mount a directory containing your font files into the container. For example starting the latest version of Carbone:

docker run --platform linux/amd64 --name carbone -p 4000:4000 -e LANG=C.UTF-8  -v /path/to/local/fonts:/usr/share/fonts/custom_fonts carbone/carbone-ee:latest

Replace /path/to/local/fonts with the path to the directory containing your font files on your local machine. /usr/share/fonts/custom_fonts is the directory inside the container where the fonts will be mounted.

The Carbone server will detect and load automatically font files on start-up. If you want to add or update fonts, you must restart the container.

Load fonts as volume with Docker Compose

To load custom fonts using Docker Compose, you would typically mount a volume containing the font files into the container.

Using volumes allows you to keep the font files outside of the container and mount them into the container at runtime. This approach can be useful if you want to keep your Docker image smaller or if you need to update the fonts without rebuilding the image.

Here is a docker-compose.yml loading custom fonts:

version: "3.9"
services:
  carbone:
    image: carbone/carbone-ee:latest
    platform: linux/amd64
    ports:
      - "4000:4000"
    volumes:
      - /path/to/local/fonts:/usr/share/fonts/custom_fonts
    environment:
      - LANG=C.UTF-8

Replace the /path/to/local/fonts with the path to the directory containing your font files on your local machine. /usr/share/fonts/custom_fonts is the directory inside the container where the fonts will be mounted.

Then start the container with:

docker-compose up

The Carbone server will detect and load automatically font files on start-up. If you want to add or update fonts, you must restart the container.

Server Upgrade

Upgrade Carbone Binary

Here's a guide to upgrading a Carbone binary for Linux, Mac or Windows.

  1. Download the latest version of Carbone on your Carbone Account: https://account.carbone.io/

  1. Use cp to move the binary into the existing Carbone server folder
    cp ./<carbone-ee> /Path/To/Existing/Carbone/Server/.
    Replace <carbone-ee> with the name of the binary, and /Path/To/Existing/Carbone/Server/ with the path of the existing directory
  2. Stop the existing Carbone process
  3. Start the new Carbone binary
  4. The Carbone server is listening on http://localhost:4000

Upgrade Carbone Docker CLI

Upgrading a Carbone Docker image version used for production involves a few steps to ensure a smooth transition and minimal disruption to your services. Here's a guide to upgrading a Carbone Docker image version:

  1. Make use your templates and renders folders are persistent: either mounted as volume, or saved into S3 with a plugin (link documentation).
  2. Backup your server configuration: retreive existing environment variables, license key, or make sure the existing JSON configuration file config/config.json is mounted as volume
  3. Pull the Latest Image: Before upgrading, pull the latest version of the Carbone Docker image from Dockerhub registry. You can do this using the docker pull command:
    docker pull carbone/carbone-ee:<tag>
    Replace <tag> with the version/tag you want to pull.
  4. Stop and Remove Existing Containers: If your containers are currently running based on the old image version, you'll need to stop and remove them before starting new containers with the updated image. You can do this using the docker stop and docker rm commands:
    docker stop <container_name_or_id>
    docker rm <container_name_or_id>
    Replace with the name or ID of your existing container(s) (Use docker ps to find the IDs of running contianers).
  5. Run New Containers with the Updated Image: Now that you have the latest version of the Docker image and have stopped and removed the existing containers, you can run new containers using the updated image. You can do this using the docker run command:
    docker run -d --name <new_container_name> --platform linux/amd64 -p 4000:4000 -e LANG=C.UTF-8 -e CARBONE_EE_LICENSE carbone/carbone-ee:<tag> 
    Replace <new_container_name> with the name you want to give to the new container and <tag> with the tag of the updated Docker image.

When starting the container, pass the Carbone On-premise license as environment variable, all Carbone options as environment variables, and you can optionally mount volumes for:

Finally, The Carbone server is listening on http://localhost:4000

Upgrade Carbone Docker Compose

Here's how you can upgrade a Carbone Docker container using Docker Compose:

  1. Update docker-compose.yml: Edit your docker-compose.yml file and update the image tag/version. For example:
    version: "3.9"
    services:
     carbone:
         image: carbone/carbone-ee:<version>  # Update the image version here
         # Other configurations...
    Replace <version> with the new image version you want to use. You can write latest if you want to use the latest version.
  2. Pull the Latest Image: If the new image is not already available locally, you can pull it using the following command:
    docker-compose pull
  3. Restart the Container: Run the following command to restart the containers with the updated image:
    docker-compose up -d
    The -d flag runs the containers in detached mode.

Finally, The Carbone server is listening on http://localhost:4000

Server Stop

When the Carbone server receives SIGTERM signal, (what we call "SOFT STOP")

  • The GET /status API request returns HTTP status 503 instead of 200. It can be used as a trigger (liveness, readiness probes) for a load balancer, reverse-proxy, or kubernetes.
  • If there is no report generation in progress, it will exist within 15 seconds.
  • If there is a report in progress, it waits until the process is finished before exiting
  • After 5 minutes, it still exists, even if there is some report generation in progress