Add Telebit Docker Compose setup

This commit is contained in:
Elias Renman
2026-06-25 15:00:08 +02:00
commit d02ad13f73
5 changed files with 105 additions and 0 deletions

2
.dockerignore Normal file
View File

@@ -0,0 +1,2 @@
.env
.git

22
.env.example Normal file
View File

@@ -0,0 +1,22 @@
# Build source for https://github.com/therootcompany/telebit.
TELEBIT_REF=master
# Host port published by Docker. Point external nginx upstreams here.
TELEBIT_PORT=8085
# Base domain assigned to devices, for example: device-a.devices.example.com.
DOMAIN=devices.example.com
# Public hostname clients use for the websocket tunnel.
TUNNEL_DOMAIN=tunnel.example.com
# Public hostname for the management API.
MGMT_DOMAIN=mgmt.devices.example.com
# Shared JWT secret for relay and management. Use at least 16 random chars.
SECRET=change-me-to-a-long-random-secret
# Internal postgres password.
POSTGRES_PASSWORD=change-me-postgres-password
VERBOSE=true

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
.env

21
Dockerfile Normal file
View File

@@ -0,0 +1,21 @@
FROM golang:1.22-alpine AS builder
ARG TELEBIT_REF=master
RUN apk add --no-cache git
WORKDIR /src
RUN git clone --depth 1 --branch "${TELEBIT_REF}" https://github.com/therootcompany/telebit.git .
RUN go generate -mod=vendor ./...
RUN CGO_ENABLED=0 go build -mod=vendor -ldflags="-s -w" -o /out/telebit-relay ./cmd/telebit
RUN CGO_ENABLED=0 go build -mod=vendor -ldflags="-s -w" -o /out/telebit-mgmt ./cmd/mgmt
FROM alpine:3.20
RUN apk add --no-cache ca-certificates
COPY --from=builder /out/telebit-relay /usr/local/bin/telebit-relay
COPY --from=builder /out/telebit-mgmt /usr/local/bin/telebit-mgmt
WORKDIR /var/lib/telebit

59
docker-compose.yml Normal file
View File

@@ -0,0 +1,59 @@
services:
relay:
build:
context: .
args:
TELEBIT_REF: ${TELEBIT_REF:-master}
image: telebit-go:local
command: telebit-relay
restart: unless-stopped
depends_on:
mgmt:
condition: service_started
environment:
SECRET: ${SECRET:?set SECRET in .env}
API_HOSTNAME: ${TUNNEL_DOMAIN:?set TUNNEL_DOMAIN in .env}
LISTEN: :8085
LOCALS: https:${MGMT_DOMAIN:?set MGMT_DOMAIN in .env}:6468
AUTH_URL: http://mgmt:6468/api
ACME_RELAY_URL: http://mgmt:6468/api/acme-relay
VERBOSE: ${VERBOSE:-true}
ports:
- "${TELEBIT_PORT:-8085}:8085"
volumes:
- relay-acme:/var/lib/telebit/acme.d
mgmt:
image: telebit-go:local
command: telebit-mgmt
restart: unless-stopped
depends_on:
postgres:
condition: service_healthy
environment:
SECRET: ${SECRET:?set SECRET in .env}
DOMAIN: ${DOMAIN:?set DOMAIN in .env}
TUNNEL_DOMAIN: ${TUNNEL_DOMAIN:?set TUNNEL_DOMAIN in .env}
DB_URL: postgres://postgres:${POSTGRES_PASSWORD:?set POSTGRES_PASSWORD in .env}@postgres:5432/postgres?sslmode=disable
LISTEN: 0.0.0.0:6468
expose:
- "6468"
postgres:
image: postgres:16-alpine
restart: unless-stopped
environment:
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?set POSTGRES_PASSWORD in .env}
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres -d postgres"]
interval: 10s
timeout: 5s
retries: 5
volumes:
- postgres-data:/var/lib/postgresql/data
volumes:
postgres-data:
relay-acme: