-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContainerfile
More file actions
142 lines (118 loc) · 6.04 KB
/
Containerfile
File metadata and controls
142 lines (118 loc) · 6.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# --------------------------------------------------------------------------
# THIS FILE IS AUTOGENERATED - DO NOT EDIT MANUALLY
#
# Source: Containerfile.j2
# --------------------------------------------------------------------------
# Seerr - Unified media request management
# Multi-stage build matching upstream pattern: prod-deps + build + runtime
ARG BASE_VERSION=15
FROM ghcr.io/daemonless/base:${BASE_VERSION} AS base
# Build dependencies (shared across stages)
RUN pkg update && pkg install -y \
node22 npm-node22 python311 \
gmake pkgconf sqlite3 vips \
FreeBSD-clang FreeBSD-lld FreeBSD-toolchain FreeBSD-clibs-dev FreeBSD-runtime-dev \
FreeBSD-zlib-dev FreeBSD-openssl-dev FreeBSD-xz-dev FreeBSD-bzip2-dev \
ca_root_nss \
&& pkg clean -ay && rm -rf /var/cache/pkg/* /var/db/pkg/repos/*
RUN ln -sf /usr/bin/clang /usr/bin/cc && \
ln -sf /usr/bin/clang++ /usr/bin/c++
RUN corepack enable
ENV PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
ENV NODE_OPTIONS="--max-old-space-size=2048"
# Download source
RUN SEERR_VERSION=$(fetch -qo - "https://api.github.com/repos/seerr-team/seerr/releases/latest" | jq -r '.tag_name') && \
echo "Building Seerr ${SEERR_VERSION}" && \
mkdir -p /app/seerr && \
fetch -qo - "https://github.com/seerr-team/seerr/archive/refs/tags/${SEERR_VERSION}.tar.gz" | \
tar xzf - -C /app/seerr --strip-components=1 && \
echo "${SEERR_VERSION#v}" > /app/version
WORKDIR /app/seerr
# --- Stage: production dependencies ---
FROM base AS prod-deps
RUN CYPRESS_INSTALL_BINARY=0 pnpm install --prod --frozen-lockfile --ignore-scripts && \
pnpm rebuild sqlite3 bcrypt && \
rm -rf $(pnpm store path)
# --- Stage: build ---
FROM base AS build
RUN CYPRESS_INSTALL_BINARY=0 pnpm install --frozen-lockfile
# Patch Next.js SWC for FreeBSD: no native binary exists
# 1. Install WASM SWC matching the Next.js minor version
# 2. Copy WASM files into Next.js's wasm/ dir (bypasses pnpm resolution)
# 3. Stub downloads, force WASM fallback, remove process.exit(1)
RUN NEXT_DIR=$(ls -d node_modules/.pnpm/next@*/node_modules/next) && \
NEXT_VER=$(jq -r .version ${NEXT_DIR}/package.json) && \
NEXT_MINOR=$(echo ${NEXT_VER} | sed 's/\.[0-9]*$//') && \
echo "Next.js ${NEXT_VER}: installing WASM SWC ~${NEXT_MINOR}.0" && \
pnpm add "@next/swc-wasm-nodejs@~${NEXT_MINOR}.0" && \
WASM_SRC=$(ls -d node_modules/.pnpm/@next+swc-wasm-nodejs@*/node_modules/@next/swc-wasm-nodejs) && \
mkdir -p ${NEXT_DIR}/wasm/@next/swc-wasm-nodejs && \
cp -r ${WASM_SRC}/* ${NEXT_DIR}/wasm/@next/swc-wasm-nodejs/ && \
echo "WASM SWC copied to ${NEXT_DIR}/wasm/"
COPY <<'PATCH' /tmp/patch-swc.js
const fs = require('fs');
const p = process.argv[2];
// Stub download functions (prevent 404 crashes)
fs.writeFileSync(p + '/dist/lib/download-swc.js',
'module.exports.downloadNativeNextSwc=async function(){};module.exports.downloadWasmSwc=async function(){};');
// Force WASM-first path and remove hard exit
let idx = fs.readFileSync(p + '/dist/build/swc/index.js', 'utf8');
idx = idx.replace(
/shouldLoadWasmFallbackFirst\s*=\s*[^;]+;/,
'shouldLoadWasmFallbackFirst = true;');
idx = idx.replace('process.exit(1)', '/* patched */');
fs.writeFileSync(p + '/dist/build/swc/index.js', idx);
console.log('SWC patched for FreeBSD WASM fallback');
PATCH
RUN NEXT_DIR=$(ls -d node_modules/.pnpm/next@*/node_modules/next) && \
node /tmp/patch-swc.js "${NEXT_DIR}"
RUN pnpm build && \
rm -rf .next/cache $(pnpm store path)
# --- Stage: production image ---
FROM ghcr.io/daemonless/base:${BASE_VERSION}
ARG FREEBSD_ARCH=amd64
ARG PACKAGES="node22 vips sqlite3"
ARG UPSTREAM_URL="https://api.github.com/repos/seerr-team/seerr/releases/latest"
ARG UPSTREAM_JQ=".tag_name"
ARG HEALTHCHECK_ENDPOINT="http://localhost:5055/api/v1/status"
ENV HEALTHCHECK_URL="${HEALTHCHECK_ENDPOINT}"
# --- Metadata (Injected by Generator) ---
LABEL org.opencontainers.image.title="Seerr" \
org.opencontainers.image.description="Unified media request management (Plex, Jellyfin, Emby) on FreeBSD." \
org.opencontainers.image.source="https://github.com/daemonless/seerr" \
org.opencontainers.image.url="https://seerr.io/" \
org.opencontainers.image.documentation="https://docs.seerr.io/" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.vendor="daemonless" \
org.opencontainers.image.authors="daemonless" \
io.daemonless.category="Media Management" \
io.daemonless.port="5055" \
io.daemonless.volumes="/config" \
io.daemonless.arch="${FREEBSD_ARCH}" \
io.daemonless.upstream-url="${UPSTREAM_URL}" \
io.daemonless.upstream-jq="${UPSTREAM_JQ}" \
io.daemonless.healthcheck-url="${HEALTHCHECK_ENDPOINT}" \
io.daemonless.packages="${PACKAGES}"
# Runtime dependencies only
RUN pkg update && \
pkg install -y ${PACKAGES} && \
pkg clean -ay && \
rm -rf /var/cache/pkg/* /var/db/pkg/repos/*
# Copy full source tree, then overlay prod deps and build output (matching upstream)
COPY --from=base --chown=bsd:bsd /app/seerr /app/seerr
COPY --from=base --chown=bsd:bsd /app/version /app/version
COPY --from=prod-deps --chown=bsd:bsd /app/seerr/node_modules /app/seerr/node_modules
COPY --from=build --chown=bsd:bsd /app/seerr/.next /app/seerr/.next
COPY --from=build --chown=bsd:bsd /app/seerr/dist /app/seerr/dist
# Fix fresh-install crash: enable synchronize (creates schema) and skip broken migrations
RUN node -e "let f='/app/seerr/dist/datasource.js',s=require('fs').readFileSync(f,'utf8');require('fs').writeFileSync(f,s.replace('synchronize: false','synchronize: true'))" && \
node -e "let f='/app/seerr/dist/index.js',s=require('fs').readFileSync(f,'utf8');require('fs').writeFileSync(f,s.replace(/await dbConnection\.runMigrations\(\)/g,'/* migrations handled by synchronize */'))"
# Create config directory
RUN mkdir -p /config && chown bsd:bsd /config
# Copy service files
COPY root/ /
RUN chmod +x /etc/services.d/*/run /etc/cont-init.d/* 2>/dev/null || true
# --- Expose (Injected by Generator) ---
EXPOSE 5055
# --- Volumes (Injected by Generator) ---
VOLUME /config