Docker Deployment
Relevant source files
The following files were used as context for generating this wiki page:
Docker deployment provides a containerized environment for running Matterbridge, ensuring consistent behavior across different host systems. By encapsulating the Go binary and its configuration, Docker simplifies the setup of complex bridges between multiple protocols like Discord, Slack, and Mattermost.
The deployment leverages pre-built images or custom-built containers to run the application as a portable service. This approach is integrated into the project's ecosystem to facilitate easy scaling and management of chat gateways.
Sources: README.md:273-275, vendor/github.com/pelletier/go-toml/README.md:124-128
Containerization Overview
Matterbridge utilizes Docker to package its Go-based chat bridging logic. The container environment typically includes the matterbridge binary and requires a matterbridge.toml configuration file to define gateways and accounts.
Key Deployment Components
| Component | Description |
|---|---|
| Matterbridge Binary | The core Go executable compiled for Linux/amd64. |
| matterbridge.toml | The configuration file mapped into the container. |
| API Port | Port exposed for the REST API (defined in api.yaml). |
| Volumes | Persistent storage for configuration and logs. |
Sources: README.md:143-150, README.md:273-275, vendor/github.com/pelletier/go-toml/README.md:124-135
Image Build and Architecture
The project supports building Docker images directly from the source code. This involves a multi-stage process where the Go environment is prepared, and the application is compiled before being placed into a minimal runtime image.
The diagram shows the transition from source code to a functional containerized service, highlighting the role of the configuration file.
Sources: README.md:158-165, vendor/golang.org/x/sys/unix/README.md:43-52
Building from Source
For users requiring specific features (like the WhatsApp multidevice beta), images can be built locally using specific build tags.
docker build -t matterbridge .
Sources: vendor/github.com/pelletier/go-toml/README.md:137-140, README.md:173-180
Execution and Configuration
When running the Docker container, the configuration file must be mounted as a volume. This allows the host machine to manage settings while the container provides the runtime environment.
Deployment Workflow
The sequence illustrates how the configuration is passed from the host to the process inside the container.
Sources: README.md:273-275, vendor/github.com/pelletier/go-toml/README.md:129-135
Automated CI/CD Integration
Docker deployment is integrated into the CI/CD pipeline (e.g., Azure Pipelines) to ensure that every master branch update triggers a new image build. This ensures that the latest tag always points to the most recent stable version.
- Checks: Unit tests and linting must pass before the image is built.
- Publishing: Images are pushed to registries like DockerHub.
- Manifests: SHA256 sums are generated for binary integrity verification within the build process.
Sources: vendor/github.com/pelletier/go-toml/azure-pipelines.yml:128-158, vendor/github.com/pelletier/go-toml/v2/CONTRIBUTING.md:120-130
Deployment Summary
Docker deployment is a critical feature for Matterbridge, providing a reproducible and isolated environment for bridging chat protocols. It supports both standard releases through DockerHub and custom builds for experimental features, ensuring flexibility for system administrators. Utilizing containerization minimizes host dependencies and simplifies the integration of the bridge into broader infrastructure, such as Kubernetes clusters.
Sources: README.md:273-275, README.md:300, vendor/github.com/pelletier/go-toml/README.md:124-128