Files
BetterDesk/Dockerfile.server
T
UNITRONIX 6f5c6b09bb Switch to Apache-2.0, update docs & Dockerfiles
Replace AGPL-3.0 with Apache License 2.0 across the repository and update related documentation and metadata. Remove legacy RustDesk-specific architecture docs, delete deprecated Dockerfile.hbbr, rename Dockerfile.hbbs → Dockerfile.server and update docker-compose / install scripts to use it. Add Apache license headers to protobuf defs, remove obsolete web service (hbbsApi.js), and adjust README, CONTRIBUTING and PROJECT_STRUCTURE to reflect the license and commercial/clean-room notices. Includes a small formatting tweak in client_api_handlers.go.
2026-03-06 23:45:46 +01:00

70 lines
1.9 KiB
Docker

# Dockerfile for BetterDesk Server (Go)
# Multi-stage build: compile from source, then copy to minimal runtime image
#
# The BetterDesk server is a single binary that replaces both hbbs and hbbr.
# It provides: signal (UDP/TCP/WS), relay (TCP/WS), HTTP API, admin console.
#
# Build: docker build -f Dockerfile.server -t betterdesk-server:local .
# ---- Build stage ----
FROM golang:1.25-alpine AS builder
RUN apk add --no-cache git gcc musl-dev sqlite-dev
WORKDIR /src
# Copy Go module files first (cache dependencies)
COPY betterdesk-server/go.mod betterdesk-server/go.sum ./
RUN go mod download
# Copy full source
COPY betterdesk-server/ .
# Build static binary
RUN CGO_ENABLED=1 GOOS=linux go build \
-ldflags="-s -w -extldflags '-static'" \
-tags "sqlite_omit_load_extension netgo osusergo" \
-o /betterdesk-server .
# ---- Runtime stage ----
FROM alpine:3.20
LABEL maintainer="UNITRONIX"
LABEL description="BetterDesk Server - RustDesk-compatible signal + relay"
LABEL version="2.4.0"
RUN apk add --no-cache \
ca-certificates \
curl \
sqlite \
tini \
&& addgroup -S betterdesk \
&& adduser -S -G betterdesk betterdesk
COPY --from=builder /betterdesk-server /usr/local/bin/betterdesk-server
RUN chmod +x /usr/local/bin/betterdesk-server
# Create data directory
RUN mkdir -p /opt/rustdesk && chown betterdesk:betterdesk /opt/rustdesk
WORKDIR /opt/rustdesk
# Ports:
# 21114 - HTTP API
# 21115 - NAT type test
# 21116 - Signal (TCP+UDP)
# 21117 - Relay (TCP)
# 21118 - WebSocket Signal
# 21119 - WebSocket Relay
EXPOSE 21114 21115 21116/tcp 21116/udp 21117 21118 21119
# Health check via API
HEALTHCHECK --interval=30s --timeout=10s --start-period=15s --retries=3 \
CMD curl -sf http://localhost:21114/api/health || exit 1
USER betterdesk
ENTRYPOINT ["/sbin/tini", "--"]
CMD ["/usr/local/bin/betterdesk-server", "-mode", "all", "-db", "/opt/rustdesk/db_v2.sqlite3", "-key-file", "/opt/rustdesk/id_ed25519"]