|
| 1 | +# Overseerr - Media request management |
| 2 | +# Multi-stage build: compile with npm, run with node only |
| 3 | + |
| 4 | +ARG BASE_VERSION=15 |
| 5 | +FROM ghcr.io/daemonless/base:${BASE_VERSION} AS builder |
| 6 | + |
| 7 | +# Build dependencies |
| 8 | +RUN pkg update && pkg install -y \ |
| 9 | + node20 npm-node20 yarn-node20 python311 \ |
| 10 | + gmake pkgconf sqlite3 \ |
| 11 | + FreeBSD-clang FreeBSD-lld FreeBSD-toolchain FreeBSD-clibs-dev FreeBSD-runtime-dev \ |
| 12 | + ca_root_nss \ |
| 13 | + && pkg clean -ay |
| 14 | + |
| 15 | +# Symlink compilers |
| 16 | +RUN ln -sf /usr/bin/clang /usr/bin/cc && \ |
| 17 | + ln -sf /usr/bin/clang++ /usr/bin/c++ |
| 18 | + |
| 19 | +# Get latest release and download |
| 20 | +ENV PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin |
| 21 | +ENV NODE_OPTIONS="--max-old-space-size=2048" |
| 22 | + |
| 23 | +RUN OVERSEERR_VERSION=$(fetch -qo - "https://api.github.com/repos/sct/overseerr/releases/latest" | jq -r '.tag_name') && \ |
| 24 | + echo "Building Overseerr ${OVERSEERR_VERSION}" && \ |
| 25 | + mkdir -p /app/overseerr && \ |
| 26 | + fetch -qo - "https://github.com/sct/overseerr/archive/refs/tags/${OVERSEERR_VERSION}.tar.gz" | \ |
| 27 | + tar xzf - -C /app/overseerr --strip-components=1 && \ |
| 28 | + echo "${OVERSEERR_VERSION#v}" > /app/version |
| 29 | + |
| 30 | +WORKDIR /app/overseerr |
| 31 | + |
| 32 | +RUN CYPRESS_INSTALL_BINARY=0 yarn install --frozen-lockfile --network-timeout 1000000 && \ |
| 33 | + yarn build && \ |
| 34 | + yarn install --production --ignore-scripts --prefer-offline && \ |
| 35 | + rm -rf src server .next/cache node_modules/.cache && \ |
| 36 | + find node_modules -name "*.d.ts" -delete && \ |
| 37 | + find node_modules -name "*.map" -delete && \ |
| 38 | + find node_modules -name "*.md" -delete && \ |
| 39 | + find node_modules -type d -name "test" -exec rm -rf {} + 2>/dev/null || true && \ |
| 40 | + find node_modules -type d -name "tests" -exec rm -rf {} + 2>/dev/null || true && \ |
| 41 | + find node_modules -type d -name "__tests__" -exec rm -rf {} + 2>/dev/null || true |
| 42 | + |
| 43 | +# Production image |
| 44 | +FROM ghcr.io/daemonless/base:${BASE_VERSION} |
| 45 | + |
| 46 | +ARG FREEBSD_ARCH=amd64 |
| 47 | +ARG PACKAGES="node20" |
| 48 | +ARG UPSTREAM_URL="https://api.github.com/repos/sct/overseerr/releases/latest" |
| 49 | +ARG UPSTREAM_JQ=".tag_name" |
| 50 | +{%- if ports %} |
| 51 | +ARG HEALTHCHECK_ENDPOINT="http://localhost:{{ ports[0].port }}/api/v1/status" |
| 52 | +{%- else %} |
| 53 | +ARG HEALTHCHECK_ENDPOINT="http://localhost:5055/api/v1/status" |
| 54 | +{%- endif %} |
| 55 | + |
| 56 | +ENV HEALTHCHECK_URL="${HEALTHCHECK_ENDPOINT}" |
| 57 | + |
| 58 | +# --- Metadata (Injected by Generator) --- |
| 59 | +LABEL org.opencontainers.image.title="{{ title }}" \ |
| 60 | + org.opencontainers.image.description="{{ description }}" \ |
| 61 | + org.opencontainers.image.source="{{ repo_url }}" \ |
| 62 | + org.opencontainers.image.url="{{ web_url }}" \ |
| 63 | + org.opencontainers.image.documentation="https://docs.overseerr.dev/" \ |
| 64 | + org.opencontainers.image.licenses="MIT" \ |
| 65 | + org.opencontainers.image.vendor="daemonless" \ |
| 66 | + org.opencontainers.image.authors="daemonless" \ |
| 67 | + io.daemonless.category="{{ category }}" \ |
| 68 | +{%- if ports %} |
| 69 | + io.daemonless.port="{{ ports[0].port }}" \ |
| 70 | +{%- endif %} |
| 71 | +{%- if volumes %} |
| 72 | + io.daemonless.volumes="{{ volumes | map(attribute='path') | join(',') }}" \ |
| 73 | +{%- endif %} |
| 74 | +{%- if mlock %} |
| 75 | + org.freebsd.jail.allow.mlock="required" \ |
| 76 | +{%- endif %} |
| 77 | + io.daemonless.arch="${FREEBSD_ARCH}" \ |
| 78 | + io.daemonless.upstream-url="${UPSTREAM_URL}" \ |
| 79 | + io.daemonless.upstream-jq="${UPSTREAM_JQ}" \ |
| 80 | + io.daemonless.healthcheck-url="${HEALTHCHECK_ENDPOINT}" \ |
| 81 | + io.daemonless.packages="${PACKAGES}" |
| 82 | + |
| 83 | +# Runtime dependencies only |
| 84 | +RUN pkg update && \ |
| 85 | + pkg install -y ${PACKAGES} && \ |
| 86 | + pkg clean -ay && \ |
| 87 | + rm -rf /var/cache/pkg/* /var/db/pkg/repos/* |
| 88 | + |
| 89 | +# Copy built application from builder (with correct ownership) |
| 90 | +COPY --from=builder --chown=bsd:bsd /app/overseerr /app/overseerr |
| 91 | +COPY --from=builder --chown=bsd:bsd /app/version /app/version |
| 92 | + |
| 93 | +# Create config directory |
| 94 | +RUN mkdir -p /config && chown bsd:bsd /config |
| 95 | + |
| 96 | +# Copy service files |
| 97 | +COPY root/ / |
| 98 | +RUN chmod +x /etc/services.d/*/run /etc/cont-init.d/* 2>/dev/null || true |
| 99 | + |
| 100 | +# --- Expose (Injected by Generator) --- |
| 101 | +{%- if ports %} |
| 102 | +EXPOSE {{ ports | map(attribute='port') | join(' ') }} |
| 103 | +{%- endif %} |
| 104 | + |
| 105 | +# --- Volumes (Injected by Generator) --- |
| 106 | +{%- if volumes %} |
| 107 | +VOLUME {{ volumes | map(attribute='path') | join(' ') }} |
| 108 | +{%- endif %} |
0 commit comments