Skip to content

Dockerized Trellis

Aaron Coburn edited this page May 25, 2020 · 18 revisions

Docker containers for Trellis are published on Docker Hub. Stable containers are published with each release while development versions are published with each commit to master.

Docker Compose and Swarm Mode

Docker provides the docker-compose command for quickly starting a number of related services on a single Docker host. These services are defined in a YAML Compose configuration file. Docker can also deploy such a Compose service stack to a cluster that is running in "swarm mode". Swarm mode distributes your application on a swarm-enabled Docker cluster and handles concerns like overlay networking between services and setting up an ingress network to direct public traffic to front-end services.

Here is a compose stack that configures the Trellis service with PostgreSQL database storage:

version: "3"
services:
  trellis:
    image: trellisldp/trellis:latest
    environment:
      TRELLIS_DB_USERNAME: changeme
      TRELLIS_DB_PASSWORD: changeme
      TRELLIS_DB_URL: jdbc:postgresql://db/db-name
    ports:
      - 80:8080
    depends_on:
      - db
    volumes:
      - /local/trellis/data:/opt/trellis/data
      - /local/trellis/log:/opt/trellis/log
      # Please see note below about the ./etc directory
      # - /local/trellis/etc:/opt/trellis/etc
  db:
    image: postgres
    environment:
      POSTGRES_DB: db-name
      POSTGRES_PASSWORD: changeme
      POSTGRES_USER: changeme
      PGDATA: /var/lib/postgresql/data/pgdata/mydata
    volumes:
      - /local/postgresql/data/folder:/var/lib/postgresql/data/pgdata/mydata

The first half of the YAML document is a minimal configuration for the Trellis LDP service, exposing that service on the Docker host's port 80. The "db" service specifies a PostgreSQL Docker image, which is pulled from Docker Hub and run with the listed environment variables pass into it. These reflect the defaults configured in the Trellis Docker image. It also specifies a data directory for database persistence and maps that path to a folder on the Docker host. The trellis data volumes contain file-based resources (e.g. binaries and mementos), application logs and configuration files.

Note: the example above suggests mapping /opt/trellis/etc to a local directory. If you plan to enable this configuration, you will need to manage the Trellis config.yml file yourself. To do this, please first make a copy of config.yml, placing it in the ./etc directory, as the Trellis server will need that file to start up correctly.

To launch this Trellis stack on a single machine, save it as "docker-compose.yml". Then run docker-compose up in the same directory. (Installation of the Docker engine and Docker Compose are required.)

To launch this Trellis stack on a swarm, save it as "docker-compose.yml". Then run docker stack deploy --compose-file docker-compose.yml trellis. You must do this from the management node within a Docker Swarm enabled cluster. In addition, if you map local folders to PostgreSQL storage, then you must ensure that the folder exists and that the PostgreSQL node is consistently deployed to the same host. This is currently beyond the scope of this guide. Please see Docker documentation regarding placement constraints.

Clone this wiki locally