Sage Infrastructure Solutions Group IncSage Infrastructure Solutions Group IncLoading…

Sage Infrastructure Solutions Group Inc

Install with Docker Compose

The steps below create a folder with three files (docker-compose.yml, .env.example, init.sh), generate the secrets, and start the stack.

1. Create the folder and files

mkdir -p /opt/emberseal && cd /opt/emberseal

Save this as docker-compose.yml:

name: emberseal-prod

x-logging: &logging
  driver: json-file
  options:
    max-size: "20m"
    max-file: "5"

x-hardening: &hardening
  security_opt:
    - no-new-privileges:true
  restart: unless-stopped
  logging: *logging

services:
  emberseal:
    <<: *hardening
    image: ${EMBERSEAL_IMAGE:-harbor.sageisg.com/emberseal/emberseal}:${EMBERSEAL_TAG:-latest}
    depends_on:
      surrealdb:
        condition: service_healthy
      valkey:
        condition: service_healthy
      clamav:
        condition: service_started
    environment:
      LISTEN_ADDR: 0.0.0.0:4342
      PUBLIC_URL: ${PUBLIC_URL:?set PUBLIC_URL in .env}
      TLS_CERT_FILE: /tls/fullchain.pem
      TLS_KEY_FILE: /tls/privkey.pem
      SURREAL_URL: ws://surrealdb:8000
      SURREAL_USER: root
      SURREAL_PASS: ${SURREAL_PASS:?set SURREAL_PASS in .env}
      SURREAL_NS: emberseal
      SURREAL_DB: emberseal
      REDIS_ADDR: valkey:6379
      REDIS_PASSWORD: ${REDIS_PASSWORD:?set REDIS_PASSWORD in .env}
      CLAMD_ADDR: clamav:3310
      BOOTSTRAP_ADMIN_EMAIL: ${BOOTSTRAP_ADMIN_EMAIL:?set BOOTSTRAP_ADMIN_EMAIL in .env}
      BOOTSTRAP_ADMIN_PASSWORD_FILE: /run/secrets/bootstrap_admin_password
      EMBERSEAL_ENC_KEY_FILE: /run/secrets/emberseal_enc_key
    secrets:
      - emberseal_enc_key
      - bootstrap_admin_password
    volumes:
      - ./tls:/tls:ro
    ports:
      - "${HTTPS_BIND:-0.0.0.0}:${HTTPS_PORT:-443}:4342"
    user: "${EMBERSEAL_UID:-65532}:${EMBERSEAL_GID:-65532}"
    read_only: true
    tmpfs:
      - /tmp:size=512m,mode=1777
    cap_drop: [ALL]
    networks: [internal, egress]
    healthcheck:
      test: ["CMD", "/emberseal", "healthcheck"]
      interval: 15s
      timeout: 6s
      retries: 5
      start_period: 30s

  surrealdb:
    <<: *hardening
    image: surrealdb/surrealdb:v3.0.5
    user: root
    command:
      - start
      - --bind=0.0.0.0:8000
      - --user=root
      - --pass=${SURREAL_PASS:?set SURREAL_PASS in .env}
      - --log=info
      - rocksdb:///data/emberseal.db
    volumes:
      - surrealdb-data:/data
    networks: [internal]
    healthcheck:
      test: ["CMD", "/surreal", "is-ready", "--endpoint", "http://127.0.0.1:8000"]
      interval: 15s
      timeout: 20s
      retries: 10
      start_period: 30s

  valkey:
    <<: *hardening
    image: valkey/valkey:8-alpine
    command: ["valkey-server", "--requirepass", "${REDIS_PASSWORD:?set REDIS_PASSWORD in .env}",
              "--save", "300", "1", "--appendonly", "yes", "--appendfsync", "everysec", "--protected-mode", "yes"]
    environment:
      REDISCLI_AUTH: ${REDIS_PASSWORD}
    volumes:
      - valkey-data:/data
    networks: [internal]
    healthcheck:
      test: ["CMD", "valkey-cli", "ping"]
      interval: 10s
      timeout: 5s
      retries: 10

  clamav:
    <<: *hardening
    image: clamav/clamav-debian:stable
    volumes:
      - clamav-data:/var/lib/clamav
    networks: [egress]
    healthcheck:
      test: ["CMD", "clamdcheck.sh"]
      interval: 60s
      timeout: 15s
      retries: 5
      start_period: 600s

secrets:
  emberseal_enc_key:
    file: ./secrets/emberseal_enc_key
  bootstrap_admin_password:
    file: ./secrets/bootstrap_admin_password

volumes:
  surrealdb-data:
  valkey-data:
  clamav-data:

networks:
  internal:
    internal: true
  egress:

SurrealDB and Valkey sit on an internal network with no published ports and no internet access. ClamAV shares the egress network with Emberseal so it can update its signatures.

Save this as .env.example:

# Infrastructure only. Everything else (SMTP, sign-in, policy, branding,
# antivirus, SMS) is configured in the admin interface.

# Public HTTPS URL users and recipients reach (no trailing slash).
PUBLIC_URL=https://emberseal.example.com

# Image to run. Pin a version, e.g. 0.9.14, rather than latest.
EMBERSEAL_IMAGE=harbor.sageisg.com/emberseal/emberseal
EMBERSEAL_TAG=latest

# The app runs as this host uid/gid so it can read secrets/ and tls/
# while they stay private (0600). init.sh fills in your user.
EMBERSEAL_UID=
EMBERSEAL_GID=

# Where HTTPS is published on the host.
HTTPS_BIND=0.0.0.0
HTTPS_PORT=443

# Internal service passwords (never exposed outside the internal network).
SURREAL_PASS=
REDIS_PASSWORD=

# Break-glass local admin, re-applied on every start.
# Its password lives in secrets/bootstrap_admin_password.
BOOTSTRAP_ADMIN_EMAIL=admin@example.com

Save this as init.sh and make it executable (chmod +x init.sh). It creates .env with random internal passwords, the secret files, and a temporary self-signed certificate. It never overwrites existing files.

#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")"
umask 077

rand() { openssl rand -base64 48 | tr -dc 'A-Za-z0-9' | head -c "${1:-32}"; }

if [[ ! -f .env ]]; then
  sed -e "s/^SURREAL_PASS=.*/SURREAL_PASS=$(rand 40)/" \
      -e "s/^EMBERSEAL_UID=.*/EMBERSEAL_UID=$(id -u)/" \
      -e "s/^EMBERSEAL_GID=.*/EMBERSEAL_GID=$(id -g)/" \
      -e "s/^REDIS_PASSWORD=.*/REDIS_PASSWORD=$(rand 40)/" \
      .env.example > .env
  echo "created .env"
  echo "next: set PUBLIC_URL and BOOTSTRAP_ADMIN_EMAIL in .env, then run ./init.sh again"
  exit 0
fi
if grep -qE '^PUBLIC_URL=https://emberseal\.example\.com' .env; then
  echo "error: PUBLIC_URL in .env is still the example value; set your real https URL first" >&2
  exit 1
fi

mkdir -p secrets tls
if [[ ! -f secrets/emberseal_enc_key ]]; then
  openssl rand -base64 32 > secrets/emberseal_enc_key
  echo "created secrets/emberseal_enc_key  — BACK THIS UP SEPARATELY."
fi
if [[ ! -f secrets/bootstrap_admin_password ]]; then
  rand 24 > secrets/bootstrap_admin_password
  echo "created secrets/bootstrap_admin_password"
fi
chmod 700 secrets tls
chmod 600 secrets/*

if [[ ! -f tls/fullchain.pem ]]; then
  host="$(grep -E '^PUBLIC_URL=' .env | sed -E 's#^PUBLIC_URL=https?://([^/:]+).*#\1#')"
  openssl req -x509 -newkey rsa:3072 -nodes -days 30 \
    -keyout tls/privkey.pem -out tls/fullchain.pem \
    -subj "/CN=${host}" -addext "subjectAltName=DNS:${host}" 2>/dev/null
  chmod 600 tls/*.pem
  echo "created a 30-day self-signed placeholder certificate for ${host}"
fi

2. Configure and generate secrets

./init.sh                 # creates .env
$EDITOR .env              # PUBLIC_URL, BOOTSTRAP_ADMIN_EMAIL, EMBERSEAL_TAG, port
./init.sh                 # creates secrets/ and a placeholder certificate

[!WARNING] secrets/emberseal_enc_key is the master key. It wraps every message's encryption key. Back it up somewhere separate from the database. If it's lost, stored messages can't be read, and it can't be rotated.

3. Install your certificate and start

Copy your real certificate (full chain) and private key over the placeholders:

cp /path/to/fullchain.pem tls/fullchain.pem
cp /path/to/privkey.pem   tls/privkey.pem
chmod 600 tls/*.pem
docker compose up -d
docker compose ps         # emberseal should be "healthy" within about 30 seconds

The certificate is reloaded automatically when the files change, so renewals need no restart.

4. Sign in

Open your PUBLIC_URL, sign in as BOOTSTRAP_ADMIN_EMAIL with the password from secrets/bootstrap_admin_password, and accept the licence agreement. Then follow First-time setup.

The bootstrap admin is re-applied from these values on every start, so it always works as a break-glass login. To change its password, edit the file and restart the emberseal container.