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.
78 lines
2.3 KiB
Docker
78 lines
2.3 KiB
Docker
# Dockerfile for BetterDesk Console (Node.js)
|
|
# Multi-stage build for smaller production image
|
|
#
|
|
# Stage 1: Install dependencies (cached layer)
|
|
# Stage 2: Production image with only runtime deps
|
|
|
|
# ---- Build stage ----
|
|
FROM node:20-alpine AS build
|
|
|
|
WORKDIR /app
|
|
|
|
# Build dependencies for native modules (better-sqlite3, bcrypt)
|
|
# Note: sqlite-dev is NOT needed — better-sqlite3 bundles its own SQLite
|
|
RUN apk add --no-cache python3 make g++ || { sleep 2 && apk add --no-cache python3 make g++; }
|
|
|
|
# Copy package files first (better Docker cache)
|
|
COPY web-nodejs/package.json web-nodejs/package-lock.json* ./
|
|
|
|
# Install production dependencies (native modules build automatically)
|
|
RUN npm install --production
|
|
|
|
# ---- Production stage ----
|
|
FROM node:20-alpine
|
|
|
|
LABEL maintainer="UNITRONIX"
|
|
LABEL description="BetterDesk Console - Web Management Panel"
|
|
LABEL version="2.4.0"
|
|
|
|
WORKDIR /app
|
|
|
|
# Install runtime dependencies (retry for transient DNS failures)
|
|
RUN apk add --no-cache \
|
|
sqlite \
|
|
curl \
|
|
tini \
|
|
|| { sleep 2 && apk add --no-cache sqlite curl tini; } \
|
|
&& addgroup -S betterdesk \
|
|
&& adduser -S -G betterdesk betterdesk
|
|
|
|
# Copy application files FIRST, then overlay compiled node_modules.
|
|
# This prevents local node_modules from overwriting Alpine/musl native modules.
|
|
COPY web-nodejs/ .
|
|
COPY --from=build /app/node_modules ./node_modules/
|
|
|
|
# Copy entrypoint script
|
|
COPY docker-entrypoint.sh /app/docker-entrypoint.sh
|
|
RUN chmod +x /app/docker-entrypoint.sh
|
|
|
|
# Create data directories
|
|
RUN mkdir -p /app/data /opt/rustdesk && \
|
|
chown -R betterdesk:betterdesk /app /opt/rustdesk
|
|
|
|
# Environment variables (defaults)
|
|
ENV NODE_ENV=production
|
|
ENV PORT=5000
|
|
ENV HOST=0.0.0.0
|
|
ENV DATA_DIR=/app/data
|
|
ENV RUSTDESK_PATH=/opt/rustdesk
|
|
ENV DB_PATH=/opt/rustdesk/db_v2.sqlite3
|
|
ENV PUB_KEY_PATH=/opt/rustdesk/id_ed25519.pub
|
|
ENV API_KEY_PATH=/opt/rustdesk/.api_key
|
|
ENV SERVER_BACKEND=betterdesk
|
|
ENV DOCKER=true
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
|
|
CMD curl -f http://localhost:5000/health || exit 1
|
|
|
|
# Expose ports
|
|
# 5000 - Web console
|
|
# 21121 - RustDesk Client API (WAN-facing)
|
|
EXPOSE 5000 21121
|
|
|
|
USER betterdesk
|
|
|
|
# Use tini as init to handle signals properly
|
|
ENTRYPOINT ["/sbin/tini", "--"]
|
|
CMD ["/app/docker-entrypoint.sh"] |