tubearr/Dockerfile
John Lightner 4606dce553 feat: Tubearr — full project state through M006/S01
Migrated git root from W:/programming/Projects/ to W:/programming/Projects/Tubearr/.
Previous history preserved in Tubearr-full-backup.bundle at parent directory.

Completed milestones: M001 through M005
Active: M006/S02 (Add Channel UX)
2026-03-24 20:20:10 -05:00

66 lines
2.3 KiB
Docker

# ============================================================
# Tubearr — Multi-stage Docker build
# ============================================================
# Stage 1: Install all dependencies (including devDependencies)
# Stage 2: Compile TypeScript backend + Vite frontend
# Stage 3: Slim Alpine runtime with Node 22, yt-dlp, ffmpeg
# ============================================================
# ── Stage 1: Dependencies ──────────────────────────────────
FROM node:22-alpine AS deps
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
# ── Stage 2: Build ─────────────────────────────────────────
FROM deps AS build
# Copy source and config files needed for compilation
COPY src/ ./src/
COPY tsconfig.json ./
COPY drizzle/ ./drizzle/
# Compile TypeScript backend (outputs to dist/)
RUN npm run build
# Build Vite frontend SPA (outputs to dist/frontend/)
RUN npm run build:frontend
# ── Stage 3: Runtime ───────────────────────────────────────
FROM node:22-alpine AS runtime
# Install yt-dlp and ffmpeg — the core download/transcode tools
RUN apk add --no-cache python3 py3-pip ffmpeg \
&& pip install --no-cache-dir --break-system-packages yt-dlp
WORKDIR /app
# Copy only what the runtime needs from the build stage
COPY --from=build /app/dist/ ./dist/
COPY --from=build /app/drizzle/ ./drizzle/
COPY package.json package-lock.json ./
# Install production-only dependencies (no devDependencies)
RUN npm ci --omit=dev
# Add tsx for ESM-compatible execution (handles extensionless imports that
# tsc emits but Node's native ESM loader rejects).
# Installed locally alongside production deps so Node's --import can resolve it.
RUN npm install tsx
# Create default directories following *arr family conventions
# /config — DB, logs, cookies, settings (like Radarr/Sonarr /config)
# /media — downloaded/organized media files
RUN mkdir -p /config /media
# Runtime environment defaults
ENV NODE_ENV=production
ENV TUBEARR_DB_PATH=/config/tubearr.db
ENV TUBEARR_MEDIA_PATH=/media
ENV TUBEARR_COOKIE_PATH=/config/cookies
EXPOSE 8989
CMD ["node", "--import", "tsx/esm", "dist/index.js"]