Skip to content

Commit 77fae0a

Browse files
authored
Add Docker Compose Quickstart (#99)
1 parent f18feae commit 77fae0a

File tree

4 files changed

+107
-0
lines changed

4 files changed

+107
-0
lines changed

bufstream/docker-compose/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
minio
2+
postgres

bufstream/docker-compose/README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
![The Buf logo](https://raw.githubusercontent.com/bufbuild/buf-examples/main/.github/buf-logo.svg)
2+
3+
# Docker Compose for Bufstream
4+
5+
This directory contains an example `docker-compose.yml` file that sets up all required infrastructure for a [Bufstream][bufstream] environment suitable for local testing and development.
6+
7+
To get started, just run:
8+
9+
```
10+
$ docker compose up
11+
```
12+
13+
## Services
14+
15+
This Compose project will start the following services:
16+
17+
- MinIO (https://min.io/) for S3 compatible storage.
18+
* Its API endpoint is available at http://localhost:9000.
19+
* Its admin endpoint is available at http://localhost:9001.
20+
- A MinIO Client (mc - https://min.io/docs/minio/linux/reference/minio-mc.html) to bootstrap an initial bucket.
21+
- PostgreSQL (https://www.postgresql.org/) for metadata storage.
22+
* It is available on the standard Postgres port (5432).
23+
- A Bufstream broker.
24+
* Its Kafka endpoint is available at localhost:9092.
25+
* Its admin endpoint listens on its default port (9089), allowing you to run [`bufstream admin`](https://buf.build/docs/bufstream/reference/cli/admin/) commands against the broker.
26+
27+
## Volumes
28+
29+
When this Compose project starts, it will create two directories:
30+
31+
1. `minio`: A volume used by the `minio` service for object storage.
32+
2. `postgres`: A volume used by the `postgres` service for its database storage.
33+
34+
Before committing this `docker-compose.yml` file to your own repository, add these to your `.gitignore`.
35+
36+
## Networks
37+
38+
This example uses host networking. You may encounter issues if there are port conflicts. If you need to use port mappings, see [Docker's documentation](https://docs.docker.com/compose/how-tos/networking/).
39+
40+
[bufstream]: https://buf.build/product/bufstream
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
storage:
2+
# Using a local MinIO instance requires the S3 provider, a region, and for
3+
# force_path_style to be true.
4+
provider: S3
5+
region: example_region
6+
force_path_style: true
7+
# The included docker-compose.yml creates a bucket named "bufstream" after
8+
# deploying MinIO to localhost:9000 with the following credentials.
9+
bucket: bufstream
10+
endpoint: http://localhost:9000
11+
access_key_id:
12+
string: minioadmin
13+
secret_access_key:
14+
string: minioadmin
15+
# The included docker-compose.yml creates a database with these credentials.
16+
postgres:
17+
dsn:
18+
string: postgres://root:password@localhost:5432/bufstream
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
services:
2+
# Bufstream uses PostgreSQL 14+ (https://www.postgresql.org/) for storing cluster metadata.
3+
postgres:
4+
image: postgres:14
5+
environment: ["POSTGRES_USER=root", "POSTGRES_PASSWORD=password", "POSTGRES_DB=bufstream"]
6+
network_mode: host
7+
volumes: ["./postgres:/var/lib/postgresql/data"]
8+
healthcheck:
9+
test: ["CMD", "pg_isready", "-d", "bufstream"]
10+
interval: 2s
11+
retries: 30
12+
13+
# MinIO provides local S3-compatible object storage.
14+
minio:
15+
image: minio/minio:RELEASE.2025-05-24T17-08-30Z
16+
network_mode: host
17+
volumes: ["./minio:/data"]
18+
healthcheck:
19+
test: ["CMD", "curl", "--silent", "--fail", "--output", "/dev/null", "http://localhost:9000/minio/health/live"]
20+
interval: 2s
21+
retries: 30
22+
command: ["server", "/data", "--console-address", ":9001"]
23+
24+
# Minio Client (https://min.io/docs/minio/linux/reference/minio-mc.html) bootstraps a MinIO bucket.
25+
mc:
26+
image: minio/mc:RELEASE.2025-05-21T01-59-54Z
27+
depends_on:
28+
minio: { "condition": "service_healthy" }
29+
network_mode: host
30+
entrypoint: >
31+
/bin/sh -c "
32+
until (/usr/bin/mc alias set minio http://localhost:9000 minioadmin minioadmin) do echo '...waiting...' && sleep 1; done;
33+
/usr/bin/mc mb minio/bufstream; /usr/bin/mc anonymous set public minio/bufstream;
34+
"
35+
36+
# The Bufstream broker, available at localhost:9092.
37+
bufstream:
38+
image: bufbuild/bufstream:0.3.29
39+
depends_on:
40+
postgres: { "condition": "service_healthy" }
41+
mc: { "condition": "service_completed_successfully" }
42+
network_mode: host
43+
hostname: bufstream
44+
volumes: ["./bufstream.yaml:/bufstream.yaml"]
45+
healthcheck:
46+
test: ["CMD", "/usr/local/bin/bufstream", "admin", "status", "--exit-code", "--url", "http://127.0.0.1:9089"]
47+
command: ["serve", "--config", "/bufstream.yaml"]

0 commit comments

Comments
 (0)