Files
BetterDesk/Dockerfile.console
T
UNITRONIX a3202515d6 Fix Node.js 20 deprecation and Docker secrets lint warnings
GitHub Actions:
- actions/checkout: v4 -> v6 (Node.js 24 native)
- docker/login-action: v3 -> v4 (Node.js 24 native)
- docker/metadata-action: v5 -> v6 (Node.js 24 native)

Docker lint:
- Add check=skip=SecretsUsedInArgOrEnv to Dockerfile + Dockerfile.console
  (PUB_KEY_PATH and API_KEY_PATH are file paths, not secrets)
2026-04-06 17:19:30 +02:00

83 lines
2.6 KiB
Docker

# check=skip=SecretsUsedInArgOrEnv
# 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 \
su-exec \
|| { sleep 2 && apk add --no-cache sqlite curl tini su-exec; } \
&& addgroup -g 10001 -S betterdesk \
&& adduser -u 10001 -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 scripts
COPY docker-entrypoint.sh /app/docker-entrypoint.sh
COPY docker/console-entrypoint.sh /console-entrypoint.sh
RUN chmod +x /app/docker-entrypoint.sh /console-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 API_HOST=0.0.0.0
ENV DATA_DIR=/app/data
ENV RUSTDESK_PATH=/opt/rustdesk
ENV DB_PATH=/app/data/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
# Note: Container starts as root so console-entrypoint.sh can fix volume permissions.
# It drops to betterdesk user via su-exec before running docker-entrypoint.sh.
# Use tini as init to handle signals properly
ENTRYPOINT ["/sbin/tini", "--"]
CMD ["/console-entrypoint.sh"]