Skip to content

Embedded Carbone in a Docker image with simple REST interface

Notifications You must be signed in to change notification settings

kodira/carbone-docker

 
 

Repository files navigation

Carbone Docker

Embedded Carbone in a Docker image with simple REST API.

Authentication

Requests require HTTP Basic Authentication. Username and password must be passed to the server process via the USERNAME and PASSWORD environment variables, otherwise it will exit immedately with a non-zero exit code and, thus, stop the container.

E-Mail deployment

Generated reports can be sent via E-Mail if the request has a email field with a JSON object. The object can contain the following properties:

  • to: string[] - an Array of strings containing email addresses to which the mail is sent. If left out, empty or invalid, no emails will be sent.
  • subject: string - used as a subject line on all sent mails
  • text: string - used as the plaintext message body on all sent mails

The SMTP client connection can be configured by a set of environment variables:

  • SMTP_HOST, SMTP_PORT - host and port to connect to
  • SMTP_USER - username for SMTP authentication and as sender in messages' FROM field
  • SMTP_PASSWORD - password for SMTP authentication
  • SMTP_UNSAFE: if left undefined or empty (default), will attempt to use TLS encryption.

You can execute npm run smtp-dummy to launch a local dummy SMTP server that will log all received mails to standard output.

Executing local-run.sh will setup all environment variables to connect to it and launch the API server.

File Storage

By default, generated files are sent directly to the client. Set the STORAGE_PATH environment variable to a writable location and they will be stored there.

  • each file will be content-hashed
  • generated files it will be stored as <STORAGE_PATH>/<hash>/result.pdf
  • files will be retrievable via HTTP GET (authenticated) on /files/<hash>
  • requests to /render will not get the file in the response body. Instead, they will be redirected to the above location (status code 301).

How to consume exposed API ?

The simpliest way to use this image is to use node and install carbone-connect package. We extended the API with authentication, so this doesn't work anymore. :(

From carbone.io website

Fast, Simple and Powerful report generator in any format PDF, DOCX, XLSX, ODT, PPTX, ODS [, ...]

... using your JSON data as input.

See carbone.io website for full Carbone documentation.

About

Embedded Carbone in a Docker image with simple REST interface

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 79.7%
  • Dockerfile 9.1%
  • HTML 8.7%
  • Shell 2.5%