# ============================================ # StreamDock - Multi-Stage Docker Build # ============================================ # --- Build Stage --- FROM golang:1.23-alpine AS builder RUN apk add --no-cache git WORKDIR /build # Dependencies zuerst (Caching) COPY go.mod go.sum ./ RUN go mod download # Source kopieren und bauen COPY . . RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o streamdock ./cmd/streamdock # --- Runtime Stage --- FROM alpine:3.21 RUN apk add --no-cache \ ca-certificates \ tzdata \ ffmpeg \ su-exec \ && adduser -D -h /app streamdock WORKDIR /app # Binary kopieren COPY --from=builder /build/streamdock . # Web-Assets kopieren COPY --from=builder /build/web ./web # Verzeichnisse erstellen RUN mkdir -p /app/data/config /app/data/recordings /app/data/avatars \ && chown -R streamdock:streamdock /app # Entrypoint-Script: Rechte sicherstellen, dann als streamdock-User starten COPY --from=builder --chmod=755 /build/entrypoint.sh /app/entrypoint.sh # Volumes VOLUME ["/app/data/config", "/app/data/recordings"] # Ports EXPOSE 8080 # Umgebungsvariablen ENV STREAMDOCK_HOST=0.0.0.0 \ STREAMDOCK_PORT=8080 \ STREAMDOCK_DB_PATH=/app/data/config/streamdock.db \ STREAMDOCK_RECORDINGS_PATH=/app/data/recordings \ STREAMDOCK_AVATARS_PATH=/app/data/avatars # Health Check HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \ CMD wget -qO- http://localhost:8080/api/auth/me || exit 1 ENTRYPOINT ["/app/entrypoint.sh"]