mirror of
https://github.com/UNITRONIX/BetterDesk.git
synced 2026-09-10 09:35:39 +00:00
3390c75547
Generate a UUID when RequestRelay/RelayResponse messages contain an empty uuid to prevent relay pairing failures (updates in signal/handler.go: handleRequestRelay, handleRequestRelayTCP, handleRelayResponseForward). Add validation in config.GetRelayServers to reject obviously invalid/too-short hosts (prevents relay entries like "a:21117"). Add retry wrappers to apk add commands in Dockerfile, Dockerfile.server, and Dockerfile.console to work around transient DNS failures during image builds. Update changelog (.github/copilot-instructions.md) with these fixes and related notes.
72 lines
2.0 KiB
Docker
72 lines
2.0 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 || { sleep 2 && apk add --no-cache git; }
|
|
|
|
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 (modernc.org/sqlite is pure Go — no CGO needed)
|
|
RUN CGO_ENABLED=0 GOOS=linux go build \
|
|
-ldflags="-s -w" \
|
|
-tags "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 \
|
|
|| { sleep 2 && 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", "-key-file", "/opt/rustdesk/id_ed25519"]
|