Skip to content

Standalone mjml server, listening on port 8080/tcp.

License

Notifications You must be signed in to change notification settings

draytechnologies/mjml-server

 
 

Repository files navigation

MJML docker microservice / server

Lines of Code Coverage Duplicated Lines (%) CircleCI

CircleCI

CI Releases

Our default release pipeline is enabled for this repository. Merge to deploy to stage; Release/tag to deploy to production.

Description

Standalone mjml server, listening on port 8080/tcp.

Due to various challenges this image sports the following features:

  • Clean and fast shutdowns on docker.
  • Simple CORS capabilities.
  • Small footprint (at least in a npm way).
  • Supports healthchecks.

Table of contents

Overview

This image spools up a simple mjml server instance, listening to port 8080/tcp per default.

Due to GDPR / DSGVO reasons I required the mjml instance to be under my own control, as the processing personal information is processed in mail content generation.

Starting the image is as easy as running a test instance through docker

docker-compose up
cd test
curl --data "@raw.mjml" http://localhost:8080

Defaults

The production defaults, without any override, default to:

CORS=""
MAX_REQUEST_BODY="2048kb"
MJML_KEEP_COMMENTS="false"
MJML_VALIDATION_LEVEL="soft"
MJML_BEAUTIFY="false"
HEALTHCHECK="true"
CHARSET="utf8"
DEFAULT_RESPONSE_CONTENT_TYPE="text/html; charset=utf-8"

Development

For development environments I would suggest to switch it to

CORS="*"
MJML_KEEP_COMMENTS="true"
MJML_VALIDATION_LEVEL="strict"
MJML_BEAUTIFY="false"
HEALTHCHECK="false"

This will escalate any issues you have with invalid mjml code to the docker log (stdout or docker-compose logs).

Troubleshooting

Make sure you pass along a plain Content-Type header and pass the mjml as raw body.

Catch errors by looking at the HTTP response code.

Kubernetes

As the default Dockerfile specific HEALTHCHECK directive is not supported by kubernetes, you might need to specify your own probes:

spec:
  containers:
  - name: ...
    livenessProbe:
      exec:
        command:
        - curl - 'http://localhost:8080/health/liveness'
      initialDelaySeconds: 30
      periodSeconds: 30
    readinessProbe:
      exec:
        command:
        - curl - 'http://localhost:8080/health/readiness'
      initialDelaySeconds: 25

About

Standalone mjml server, listening on port 8080/tcp.

Resources

License

Stars

Watchers

Forks

Languages

  • JavaScript 78.1%
  • Makefile 9.7%
  • Dockerfile 7.4%
  • Shell 4.8%