Skip to content

Docker setup

Self-host Silex with Docker by building the image from source.

Overview

Silex ships a Dockerfile at the repository root. It builds the monorepo (Node.js server, all connectors, and the web editor) into a single image, configured as the full SaaS. You manage the instance through environment variables.

Note: the silexlabs/silex-platform image on Docker Hub is built from this Dockerfile and powers the hosted instance and the CapRover one-click app. Building it yourself from source, as shown below, always tracks the latest code and avoids depending on a specific registry (a move to a libre registry is being discussed).

Prerequisites

  • Docker installed
  • Git
  • Basic understanding of environment variables and port forwarding

Quick start

Clone the repository and build the image:

git clone --recurse-submodules https://github.com/silexlabs/Silex.git
cd Silex
docker build -t silex .

Run it:

docker run -d --name silex -p 6805:6805 \
  -e SILEX_SESSION_SECRET="$(openssl rand -base64 32)" \
  -e SILEX_URL=http://localhost:6805 \
  -e STORAGE_CONNECTORS=fs \
  -e HOSTING_CONNECTORS=fs,download \
  -e SILEX_FS_ROOT=/data/storage \
  -e SILEX_FS_HOSTING_ROOT=/data/hosting \
  -v "$PWD/data:/data" \
  silex

Silex is now running at http://localhost:6805. You will see the dashboard with an empty list of websites.

With Docker Compose

Create docker-compose.yml in the repository root:

services:
  silex:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: silex
    ports:
      - "6805:6805"
    environment:
      SILEX_SESSION_SECRET: ${SILEX_SESSION_SECRET}
      SILEX_URL: http://localhost:6805
      STORAGE_CONNECTORS: fs
      HOSTING_CONNECTORS: fs,download
      SILEX_FS_ROOT: /data/storage
      SILEX_FS_HOSTING_ROOT: /data/hosting
    volumes:
      - ./data:/data
    restart: unless-stopped

Set the session secret in a .env file next to it:

echo "SILEX_SESSION_SECRET=$(openssl rand -base64 32)" > .env

Build and start:

docker compose up -d --build

Environment variables

Variable Default Purpose
SILEX_PORT 6805 Internal port the Node server listens on
SILEX_HOST localhost Internal hostname (keep as localhost in Docker)
SILEX_PROTOCOL http Protocol before a reverse proxy (http or https)
SILEX_URL http://localhost:6805 Public URL users visit (update for production)
SILEX_SESSION_SECRET (none) Session encryption key, random and at least 32 chars
SILEX_SESSION_NAME silex-session Session cookie name
SILEX_DEBUG false Set to true to reload config files on each request (dev only)
STORAGE_CONNECTORS ftp Comma-separated: fs, gitlab, ftp (the examples here use fs for a self-contained instance)
HOSTING_CONNECTORS ftp,download Comma-separated: fs, gitlab, ftp, download
SILEX_FS_ROOT (cwd-relative) Path for the filesystem storage connector
SILEX_FS_HOSTING_ROOT (cwd-relative) Path for the filesystem hosting connector
SILEX_SERVER_CONFIG (built-in SaaS config) Path to a custom server config file
SILEX_CLIENT_CONFIG (built-in SaaS config) Path to a custom client config file

Express request limits

For large file uploads or large JSON payloads:

Variable Default Purpose
SILEX_EXPRESS_JSON_LIMIT 1mb Max JSON request body
SILEX_EXPRESS_TEXT_LIMIT 10mb Max text request body
SILEX_EXPRESS_URLENCODED_LIMIT 1mb Max URL-encoded request body
environment:
  SILEX_EXPRESS_JSON_LIMIT: 50mb
  SILEX_EXPRESS_TEXT_LIMIT: 50mb

GitLab connectors

To enable GitLab storage and hosting:

environment:
  STORAGE_CONNECTORS: fs,gitlab
  HOSTING_CONNECTORS: fs,download,gitlab
  GITLAB_DISPLAY_NAME: GitLab.com
  GITLAB_CLIENT_ID: your-oauth-app-id
  GITLAB_CLIENT_SECRET: your-oauth-app-secret
  GITLAB_DOMAIN: gitlab.com

For a second GitLab instance, add GITLAB2_* variables and append gitlab2 to the connector lists. See Storage connectors for OAuth setup.

FTP connectors

environment:
  STORAGE_CONNECTORS: ftp
  HOSTING_CONNECTORS: ftp
  FTP_STORAGE_PATH: /public_html
  FTP_HOSTING_PATH: /public_html

Users authenticate with their FTP credentials in the UI.

Reverse proxy with Caddy

Caddy auto-manages SSL certificates. Add it to your docker-compose.yml:

services:
  silex:
    build:
      context: .
      dockerfile: Dockerfile
    expose:
      - 6805
    environment:
      SILEX_URL: https://silex.example.com
      SILEX_PROTOCOL: https
      SILEX_SESSION_SECRET: ${SILEX_SESSION_SECRET}
      STORAGE_CONNECTORS: fs
      HOSTING_CONNECTORS: fs,download
      SILEX_FS_ROOT: /data/storage
      SILEX_FS_HOSTING_ROOT: /data/hosting
    volumes:
      - ./data:/data
    restart: unless-stopped

  caddy:
    image: caddy:latest
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile:ro
      - caddy-data:/data
    depends_on:
      - silex

volumes:
  caddy-data:

Create a Caddyfile:

silex.example.com {
  reverse_proxy silex:6805
}

Point your domain's A record to your server, then docker compose up -d --build. Caddy provisions and renews the certificate automatically.

Volumes and data persistence

The example mounts ./data into the container, with websites under /data/storage and published sites under /data/hosting. This persists across container restarts. Back it up regularly:

tar czf data-backup.tar.gz ./data

Updating

Pull the latest code and rebuild:

git pull
git submodule update --init --recursive
docker compose up -d --build

Troubleshooting

Container fails to start

docker compose logs silex

Common issues:

  • Port 6805 already in use: change ports to ["8080:6805"]
  • SILEX_SESSION_SECRET too short: must be at least 32 characters
  • Permission denied on the data volume: chmod -R 777 ./data

Published sites are stored but not served

The filesystem hosting connector writes files inside the container, it does not web-serve them. To serve published sites, use the download connector to get a ZIP, or use GitLab Pages or FTP hosting. See Deploying to other hosting platforms.

CORS errors

If the editor and API are on different domains:

environment:
  SILEX_CORS_URL: https://your-domain.com

See also

Edit this page on GitLab