Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
174 lines (169 loc) · 10.5 KB
/
Copy pathDockerfile
File metadata and controls
174 lines (169 loc) · 10.5 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# Node.js for the runtime Jellyfin Web installer, which builds upstream
# jellyfin-web in the container. Jellyfin Web 12.x requires Node.js >=24,
# independent of the Silo frontend toolchain. The installer runs the npm
# release each Jellyfin Web version declares in engines.npm.
FROM node:24-slim AS jellyfin_web_node
# Stage 1: Build frontend
FROM node:24-slim AS frontend
RUN corepack enable && corepack prepare pnpm@10.32.1 --activate
WORKDIR /app/web
COPY web/package.json web/pnpm-lock.yaml ./
COPY web/vendor/foliate-js ./vendor/foliate-js
RUN --mount=type=cache,target=/root/.local/share/pnpm/store \
pnpm install --frozen-lockfile
COPY web/ .
# The v2 contract fixtures are imported by web tests, which `tsrs -b` type-checks
# as part of the build; they live outside web/ so copy them explicitly.
COPY contracts/api/v2/fixtures/ /app/contracts/api/v2/fixtures/
# Web tests also import the shared design schema vectors under docs/.
COPY docs/design/schemas/ /app/docs/design/schemas/
RUN pnpm run build
# Allow CI to inject prebuilt frontend assets via a named `frontend_dist`
# context while local builds keep using the in-Docker frontend stage.
FROM scratch AS frontend_dist
COPY --from=frontend /app/web/dist/. /
# Stage 2: Build Go binary
# The floating 1.27 tag is deliberate so images get Go patch releases without a manual bump.
FROM golang:1.27 AS build
ENV CGO_ENABLED=1
ENV GOPROXY=https://proxy.golang.org,direct
ENV GOPRIVATE=github.com/Silo-Server/*
ENV GONOSUMDB=github.com/Silo-Server/*
RUN apt-get update && apt-get install -y --no-install-recommends libvips-dev && rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY go.mod go.sum ./
COPY internal/compat/zishang520-webtransport-go/ internal/compat/zishang520-webtransport-go/
RUN go mod download
COPY internal/ internal/
COPY migrations/ migrations/
# The settings contract is a Go package (contracts/settings/v1) that embeds the
# manifest, so the binary carries the exact bytes it was built from. It lives
# outside internal/ because clients vendor these files.
COPY contracts/ contracts/
RUN --network=none go build ./internal/... ./migrations/... ./contracts/...
COPY cmd/ cmd/
COPY web/embed.go web/embed.go
COPY --from=frontend_dist / web/dist
RUN --network=none go build -o /silo ./cmd/silo/
ARG BUILD_REVISION
ARG BUILD_DIRTY=false
ARG BUILD_NUMBER
ARG BUILD_DATE
RUN --network=none go build \
-ldflags "-X github.com/Silo-Server/silo-server/internal/buildinfo.revisionOverride=${BUILD_REVISION} -X github.com/Silo-Server/silo-server/internal/buildinfo.dirtyOverride=${BUILD_DIRTY} -X github.com/Silo-Server/silo-server/internal/buildinfo.buildNumberOverride=${BUILD_NUMBER} -X github.com/Silo-Server/silo-server/internal/buildinfo.builtAtOverride=${BUILD_DATE}" \
-o /silo ./cmd/silo/
# The macOS transcode node (darwin/arm64), cross-compiled on the build host.
# The silo_node tag leaves out libvips and the web app, so it needs no cgo and
# links only system frameworks; the Go linker signs it ad hoc. A Mac copies it
# out of the image so it matches this server (docs/architecture/transcode-nodes.md).
FROM --platform=$BUILDPLATFORM golang:1.27 AS node_darwin
ENV GOPROXY=https://proxy.golang.org,direct
ENV GOPRIVATE=github.com/Silo-Server/*
ENV GONOSUMDB=github.com/Silo-Server/*
WORKDIR /app
COPY go.mod go.sum ./
COPY internal/compat/zishang520-webtransport-go/ internal/compat/zishang520-webtransport-go/
RUN go mod download
COPY internal/ internal/
COPY migrations/ migrations/
COPY contracts/ contracts/
COPY cmd/ cmd/
COPY web/embed.go web/embed_node.go web/
RUN --network=none CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -tags silo_node -trimpath -o /dev/null ./cmd/silo/
ARG BUILD_REVISION
ARG BUILD_DIRTY=false
ARG BUILD_NUMBER
ARG BUILD_DATE
RUN --network=none CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -tags silo_node -trimpath \
-ldflags "-s -w -X github.com/Silo-Server/silo-server/internal/buildinfo.revisionOverride=${BUILD_REVISION} -X github.com/Silo-Server/silo-server/internal/buildinfo.dirtyOverride=${BUILD_DIRTY} -X github.com/Silo-Server/silo-server/internal/buildinfo.buildNumberOverride=${BUILD_NUMBER} -X github.com/Silo-Server/silo-server/internal/buildinfo.builtAtOverride=${BUILD_DATE}" \
-o /silo-darwin-arm64 ./cmd/silo/
# Stage 3: Runtime
# CI rebuilds this stage without the layer cache (no-cache-filters: runtime in
# trusted-linux-build.yml) so every image picks up Debian security updates; the
# upgrade covers packages already in the base image between Debian's refreshes
# of the trixie-slim tag.
FROM debian:trixie-slim AS runtime
ARG TARGETARCH
ARG INTEL_GMMLIB_VERSION=22.10.0
ARG INTEL_IGC_VERSION=2.34.4
ARG INTEL_IGC_BUILD=21428
ARG INTEL_NEO_VERSION=26.18.38308.1
# Intel's current OpenCL runtime only drives Gen12 and newer graphics. Gen8 to
# Gen11 (UHD 630, Jasper Lake and similar) need the legacy1 runtime and its
# IGC 1.x compiler, which install alongside the current ones.
ARG INTEL_IGC_LEGACY_VERSION=1.0.17537.24
ARG INTEL_NEO_LEGACY_VERSION=24.35.30872.36
ARG JELLYFIN_FFMPEG_VERSION=8.1.3-1
# SHA-256 of the PGDG signing key file (primary key B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8).
# The key comes from the same host as the packages, so pin it here.
ARG PGDG_KEY_SHA256=0144068502a1eddd2a0280ede10ef607d1ec592ce819940991203941564e8e76
# Backups run pg_dump and pg_restore on the API server (internal/backup), and
# pg_dump must be at least the database server's major version, so the
# PostgreSQL 18 client comes from the PostgreSQL apt repository, as the
# omnibus image's server does.
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y --no-install-recommends ca-certificates curl gnupg && \
curl -fsSL https://repo.jellyfin.org/jellyfin_team.gpg.key \
| gpg --dearmor -o /usr/share/keyrings/jellyfin.gpg && \
echo "deb [signed-by=/usr/share/keyrings/jellyfin.gpg arch=${TARGETARCH}] https://repo.jellyfin.org/debian trixie main" \
> /etc/apt/sources.list.d/jellyfin.list && \
install -d /etc/apt/keyrings && \
curl -fsSL --retry 5 --retry-all-errors -o /etc/apt/keyrings/pgdg.asc https://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc && \
echo "${PGDG_KEY_SHA256} /etc/apt/keyrings/pgdg.asc" | sha256sum -c - && \
echo "deb [signed-by=/etc/apt/keyrings/pgdg.asc arch=${TARGETARCH}] https://apt.postgresql.org/pub/repos/apt trixie-pgdg main" \
> /etc/apt/sources.list.d/pgdg.list && \
apt-get update && \
apt-get install -y --no-install-recommends "jellyfin-ffmpeg8=${JELLYFIN_FFMPEG_VERSION}-trixie" git libvips42 fonts-noto-core fonts-noto-cjk \
postgresql-client-18 && \
apt-get purge -y gnupg && apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/*
# Explicit modern-runtime image option for isolated Intel Flex/DG2 devices.
# The default preserves Media SDK for older supported Intel graphics.
ARG INTEL_QSV_RUNTIME=auto
COPY scripts/configure-intel-qsv-runtime.sh /tmp/configure-intel-qsv-runtime.sh
RUN sh /tmp/configure-intel-qsv-runtime.sh "${INTEL_QSV_RUNTIME}" "${TARGETARCH}" && \
rm /tmp/configure-intel-qsv-runtime.sh
# Debian's Intel OpenCL runtime lags the media hardware supported by the
# Jellyfin FFmpeg build. Match Jellyfin's container packaging on amd64, legacy
# runtime included, so QSV tone mapping can use the quality-preserving OpenCL
# path on every Intel generation the media driver supports. Other architectures
# retain software tone mapping unless their own hardware executor probes clean.
RUN if [ "${TARGETARCH}" = "amd64" ]; then \
runtime_dir="$(mktemp -d)" && \
cd "${runtime_dir}" && \
curl -fsSLO --retry 5 --retry-all-errors "https://github.com/intel/compute-runtime/releases/download/${INTEL_NEO_VERSION}/libigdgmm12_${INTEL_GMMLIB_VERSION}_amd64.deb" && \
curl -fsSLO --retry 5 --retry-all-errors "https://github.com/intel/intel-graphics-compiler/releases/download/v${INTEL_IGC_VERSION}/intel-igc-core-2_${INTEL_IGC_VERSION}+${INTEL_IGC_BUILD}_amd64.deb" && \
curl -fsSLO --retry 5 --retry-all-errors "https://github.com/intel/intel-graphics-compiler/releases/download/v${INTEL_IGC_VERSION}/intel-igc-opencl-2_${INTEL_IGC_VERSION}+${INTEL_IGC_BUILD}_amd64.deb" && \
curl -fsSLO --retry 5 --retry-all-errors "https://github.com/intel/compute-runtime/releases/download/${INTEL_NEO_VERSION}/intel-opencl-icd_${INTEL_NEO_VERSION}-0_amd64.deb" && \
curl -fsSLO --retry 5 --retry-all-errors "https://github.com/intel/intel-graphics-compiler/releases/download/igc-${INTEL_IGC_LEGACY_VERSION}/intel-igc-core_${INTEL_IGC_LEGACY_VERSION}_amd64.deb" && \
curl -fsSLO --retry 5 --retry-all-errors "https://github.com/intel/intel-graphics-compiler/releases/download/igc-${INTEL_IGC_LEGACY_VERSION}/intel-igc-opencl_${INTEL_IGC_LEGACY_VERSION}_amd64.deb" && \
curl -fsSLO --retry 5 --retry-all-errors "https://github.com/intel/compute-runtime/releases/download/${INTEL_NEO_LEGACY_VERSION}/intel-opencl-icd-legacy1_${INTEL_NEO_LEGACY_VERSION}_amd64.deb" && \
apt-get update && \
apt-get install -y --no-install-recommends ./*.deb && \
cd / && \
rm -rf "${runtime_dir}" /var/lib/apt/lists/*; \
fi
RUN mkdir -p /tmp/silo-transcode /var/lib/silo/artwork /var/lib/silo/compat/jellyfin-web
COPY --from=jellyfin_web_node /usr/local/bin/node /usr/local/bin/node
COPY --from=jellyfin_web_node /usr/local/lib/node_modules/npm /usr/local/lib/node_modules/npm
RUN ln -sf ../lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm && \
ln -sf ../lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx
# Node.js verifies TLS against its own bundled CA list, which Debian's
# ca-certificates updates do not reach. Use the system store instead, so a CA
# that Debian removes stops being trusted by npm as well.
ENV NODE_OPTIONS=--use-openssl-ca
LABEL io.silo.intel-qsv-runtime="${INTEL_QSV_RUNTIME}"
COPY --from=build /silo /usr/local/bin/silo
# Not run here: a Mac copies it out to run a transcode node with VideoToolbox.
COPY --from=node_darwin /silo-darwin-arm64 /usr/share/silo/nodes/silo-darwin-arm64
EXPOSE 8080 8096 13378 8094/udp
# Silo runs database migrations before its HTTP listener starts, and an
# upgrade on a large library can migrate for many minutes. The start period
# covers the default 20-minute migration budget (SILO_MIGRATE_TIMEOUT) so a
# migrating server is not reported unhealthy and restarted mid-migration; the
# first passing check still marks it healthy at once. A deployment that raises
# SILO_MIGRATE_TIMEOUT should raise the start period to match.
HEALTHCHECK --interval=15s --timeout=5s --start-period=20m --retries=3 \
CMD curl -f http://localhost:${PORT:-8080}/api/v1/health || exit 1
ENTRYPOINT ["silo"]