Skip to content

About

Docker stack for impresso app

Resources

Stars

2 stars

Watchers

5 watching

Forks

Repository files navigation

Impresso app stack

Prepare environment

Copy the example environment file:

cp .env.example .env

Edit the .env file to set the correct secret values for your environment.

Running in production

Link production config files and directories:

ln -s config_prod config
ln -s .env.nosecret-prod .env.nosecret
ln -s .env.prod .env

Production servers do not require a proxy.

docker compose  --env-file ./.env.prod --env-file ./.env.nosecret-prod up

or

docker compose  --env-file ./.env.prod --env-file ./.env.nosecret-prod --profile barista up -d

Running in dev (staging)

Link dev config files and directories:

ln -s config_dev config
ln -s .env.nosecret-dev .env.nosecret
ln -s .env.dev .env

Running in staging (detached mode), with the watchtower service that updates the images every 5 minutes:

docker compose \
  --env-file ./.env \
  --env-file ./.env.nosecret \
  --profile barista \
  -f docker-compose.yml -f docker-compose.watcher.yml \
  -p impresso up -d

Reading logs in production:

docker compose logs -f

The .env.example contains latest images of the services in docker-compose and it is for development purposes.

Running in development

Running outside of the production servers requires a proxy.

docker compose --env-file ./.env --env-file ./.env.nosecret --profile with_proxy up

If barista service needs to be enabled, add --profile barista to the command above.

docker compose --env-file ./.env --env-file ./.env.nosecret --profile with_proxy --profile barista up

Configuration

Docker compose expects several files located in config directory.

Several directories are provided for different configurations:

  • config_prod - production configuration
  • config_dev - development configuration

To use the suitable configuration, create a symlink to the desired configuration directory:

ln -s config_prod config

Nginx configuration

nginx/nginx.conf is shared by all environments and mounted directly by docker compose (it is not part of the config directories). Its Lua filters live in scripts/.

Application logs

Vector ships stdout and stderr from both middle layers, Nginx, Barista, its knowledge-base bootstrap job, user admin, Celery, the auth service, Meilisearch, and Dragonfly to VictoriaLogs. Middle-layer JSON records retain their application timestamp, level, logger, and structured properties. Django JSON records use asctime in UTC and expose level, logger, filename, and lineno. Auth-service access records expose level, client, client_port, method, path, http_version, and status. Nginx access logs expose those same request fields except level and client_port, plus request ID, timing, upstream status, and the public API user ID when present. Access paths omit query strings. Nginx error logs expose severity and request or upstream details when available. Meilisearch emits JSON logs with level, logger, and tracing fields. HTTP records also expose method, path, and status. Dragonfly logs and unparsed lines remain searchable as text. Use container_name and stream to filter by container and by stdout or stderr. Logs persist in the victorialogs-data volume for 30 days by default. Set VICTORIALOGS_RETENTION_PERIOD to change retention.

Sign in to the Impresso app with a staff account, then open /int/logs/ on the same origin. Use HTTPS for deployed sites. HTTP is supported on localhost. OpenResty verifies the app's feathers-jwt signature and expiry, accepts the configured app audience hostname or a loopback hostname, and requires the signed isStaff claim to be true for the UI and query API. The browser session lasts up to 15 minutes. Reload the UI to sign in again after it expires. Vector sends logs over the Compose network.

When deploying the /int/logs prefix, recreate victorialogs, nginx, and vector together so the proxy and ingestion use the same path.

Start or restart Vector with the updated configuration before running the one-shot bootstrap job. Vector collects Docker logs from the time it starts. Vector writes audit events to S3.

Run Vector as a trusted service on the Docker host. It uses the Docker API to read container logs. The read-only socket mount does not restrict Docker API permissions.

Vector's own warnings and errors appear in VictoriaLogs under service:vector stream:internal. A separate bounded sink sends them on a best-effort basis and excludes errors from the diagnostics pipeline itself. Use docker compose logs vector when VictoriaLogs is unavailable.

Find warnings and errors in VictoriaLogs

Match warn, warning, err, and error in any capitalization with this LogsQL query.

level:~"(?i)^(warn(ing)?|err(or)?)$"

To also find HTTP 5xx responses across all services, use this query.

level:~"(?i)^(warn(ing)?|err(or)?)$" OR status:range[500,599]

Slack log notifications

Set SLACK_WEBHOOK_URL in the deployment's .env to the webhook for the alerts channel. For a Slack Workflow Builder webhook (/triggers/), add a Text variable named text to the trigger and insert it into the Send a message to a channel step. Set VICTORIALOGS_URL to the full browser URL of the VictoriaLogs UI, for example https://stack.example.org/int/logs/. Recreate the Vector container with docker compose up -d --force-recreate vector to load both values. Both values are required to enable notifications.

Vector sends at most one summary per minute with warning and error counts by Compose service and a link to VictoriaLogs. Quiet windows produce no message. Nginx and auth-service HTTP 5xx responses count as errors. Log messages stay in VictoriaLogs. Slack delivery is best effort.

The per-error Slack posts, separate user-feedback Slack notifications, and Matomo error tracking have been retired. Use VictoriaLogs to inspect the underlying log records.

Test Slack delivery
  1. Use a Slack test channel webhook in SLACK_WEBHOOK_URL, set VICTORIALOGS_URL, and recreate Vector as shown above. Keep the middle layer running.

  2. From the Compose project directory, write one synthetic warning and one synthetic error to the middle-layer container's main stdout. Vector picks them up through its Docker log source.

    docker compose exec -T --user 0 impresso-middle-layer sh -c '
      timestamp=$(date -u +%Y-%m-%dT%H:%M:%SZ)
      exec > /proc/1/fd/1
      printf "{\"@timestamp\":\"%s\",\"level\":\"WaRn\",\"message\":\"slack-smoke-test warning\",\"logger\":\"app.slack-test\"}\n" "$timestamp"
      printf "{\"@timestamp\":\"%s\",\"level\":\"eRrOr\",\"message\":\"slack-smoke-test error\",\"logger\":\"app.slack-test\"}\n" "$timestamp"
    '
  3. Allow about a minute for the Slack summary. The impresso-middle-layer counts should include one warning and one error from the test, plus any real events in the same window. Follow the link in the message and search for _time:10m logger:="app.slack-test" to verify that both records arrived.

  4. If the records appear but the summary is missing, verify that both variables were loaded and check docker compose logs --since 5m vector for errors from slack_alerts. If you temporarily changed the webhook, restore its original value and recreate Vector after testing.

Gatus monitoring

The Gatus dashboard is available at /status/ on the Nginx site. It is also available directly at http://127.0.0.1:8080 on the Docker host. Set GATUS_PORT to change the direct-access port. Check history is stored in the gatus-data volume.

Gatus checks both middle layers, Dragonfly, user admin, Celery, Barista, Meilisearch, auth, annotations, Solr and MySQL. Set GATUS_MONITOR_BARISTA=false when running without the barista profile to disable the Barista and Meilisearch checks.

The annotation API defaults to https://impresso-annotation.epfl.ch/api. Set ANNOTATION_BASE_URL to override it, omitting the trailing slash. The Solr probe runs a zero-row query against SOLR_CONTENT_ITEM_INDEX using the existing reader credentials. The MySQL probe connects to DB_DATABASE with the stack's database credentials and runs SELECT 1.

Compose builds gatus-probes from the dedicated image in gatus/. After editing the probe code or dependencies, rebuild it with docker compose up -d --build gatus-probes.

Proxy and extra nginx configuration

A special note about the database. Our setup assumes the database is accessed via an SSH tunnel to the database host. If the database port is accessible directly, you can simplify the configuration by setting the db hostname, port and credentials in the relevant config files, commenting out the mysql-tunnel section in docker-compose.yml. In this case you also do not need the files in the config/ssh folder, those are used for the DB tunnel only.

Host configuration

Increase the default limit of open files on the host server to increase the maximum allowed number of connections. See socket.io performance tuning.

Apps versions

Tags of impresso docker images are read from the .env file. The default file with all tags set to latest is provided in this repository.

Dragonfly (Redis replacement)

We use Dragonfly instead of Redis as the in-memory data store. The reasons:

  • BullMQ / Celery broker — services use BullMQ (Node) and Celery (Python) for job queues, both of which require full Lua scripting support. Redis-compatible alternatives with disk spillover (KVRocks, Pika) have limited Lua support and do not work with BullMQ.
  • Disk spillover — Dragonfly supports SSD tiering via --tiered_prefix, allowing the dataset to exceed available RAM. On Linux hosts with io_uring support, cold data is automatically offloaded to disk. On macOS (Docker Desktop), tiering is disabled automatically at startup since io_uring is not available.
  • noeviction — the store is configured with noeviction so that job queue data and session tokens are never silently dropped. Writes will error if RAM is exhausted rather than losing data.

Key configuration details

  • Startup script: scripts/dragonfly-entrypoint.sh — detects io_uring availability at runtime and enables/disables tiered storage accordingly.
  • Max RAM: 2GB. Hourly RDB snapshots are written to the dragonfly-data volume.
  • --default_lua_flags=allow-undeclared-keys is required for BullMQ compatibility. Dragonfly enforces strict key declaration in Lua scripts by default; BullMQ constructs keys dynamically inside scripts, which trips this restriction. This flag disables the check at a minor performance cost to Lua calls.
  • On Linux production servers, ensure io_uring is not disabled (/proc/sys/kernel/io_uring_disabled should be 0) and the container has seccomp=unconfined (already set in docker-compose.yml) to allow the necessary syscalls.

Docker specific configuration notes for components

Frontend Web App

When building docker container for the app make sure:

  • webpack compiles the app with PUBLIC_PATH environmental variable set to /app/ (assuming that the app base URL in nginx configuration is /app).
  • BASE_URL in prod.env.js is set to '"/app"' (assuming that the app base URL in nginx configuration is /app).
  • MIDDLELAYER_API in prod.env.js is set to '""'
  • MIDDLELAYER_API_PATH in prod.env.js is set to '"/api"' (assuming that middle layer API base URL in nginx configuration is /api)
  • MIDDLELAYER_API_SOCKET_PATH in prod.env.js is set to '"/api/socket.io/"' (assuming that middle layer API base URL in nginx configuration is /api)
  • MIDDLELAYER_MEDIA_PATH in prod.env.js is set to '"/api/media"' (assuming that the api base URL in nginx configuration is /api)

About

Docker stack for impresso app

Resources

Stars

2 stars

Watchers

5 watching

Forks

Releases

Packages

Contributors

Languages