Skip to content

Create Docker container for Subarr #4

@cerede2000

Description

@cerede2000

Could you publish docker image for Subarr ?

A Dockerfile and Compose base if that helps :)

Dockerfile

# ---------- Build stage ----------
FROM node:20-alpine AS build
ARG SUBARR_VERSION=master

RUN apk add --no-cache git
WORKDIR /app

# Grab Subarr
RUN git clone --depth=1 --branch "${SUBARR_VERSION}" https://github.com/derekantrican/subarr.git /app

# Install deps at workspace root
# (npm ci if lockfile present, else npm install)
RUN if [ -f package-lock.json ]; then npm ci --no-audit --no-fund; else npm install --no-audit --no-fund; fi

# Build the React client now (so runtime won’t need to write /app/client/build)
RUN npm --workspace client run build

# Trim dev deps to keep the final copy lighter
RUN npm prune --omit=dev

# ---------- Runtime stage ----------
FROM node:20-alpine AS runtime
# add tools you want; add ffmpeg/yt-dlp only if you’ll use "Process" actions
RUN apk add --no-cache tzdata curl
ENV TZ=Europe/Paris NODE_ENV=production PORT=5000

WORKDIR /app

# Copy only what we need to run
COPY --from=build /app/package*.json /app/
COPY --from=build /app/server /app/server
COPY --from=build /app/client/build /app/client/build
# Preserve any remaining node_modules from build if present
COPY --from=build /app/node_modules /app/node_modules

# Non-root user & permissions
RUN addgroup -S app -g 10001 && adduser -S app -G app -u 10001 \
  && chown -R app:app /app
USER app

EXPOSE 5000
# IMPORTANT: start server directly (do NOT run the script that rebuilds the client)
CMD ["node", "server/index.js"]

BUILD : docker compose build --no-cache

compose:

services:
  subarr:
    build:
      context: .
      args:
        SUBARR_VERSION: master   # or a specific tag/commit
    image: subarr:local
    container_name: subarr
    environment:
      - TZ=Europe/Paris
      - PORT=5000
    ports:
      - "5050:5000"
    # NOTE: we do NOT set read_only here, because the server likely writes its SQLite DB
    # into /app/server (path not documented). If you later confirm a dedicated data dir,
    # we can re-enable read_only and mount just that path R/W.
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "curl", "-fsS", "http://localhost:5000/"]
      interval: 30s
      timeout: 5s
      retries: 5

RUN : docker compose up -d

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions