-
-
Notifications
You must be signed in to change notification settings - Fork 62
Expand file tree
/
Copy pathDockerfile.dev
More file actions
103 lines (98 loc) · 5.25 KB
/
Copy pathDockerfile.dev
File metadata and controls
103 lines (98 loc) · 5.25 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
# syntax=docker/dockerfile:1.7
# 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:22-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 `tsc -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/
RUN pnpm run build
# Stage 2: Prepare Go build workspace
FROM golang:1.26 AS build-base
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/
# Apply the local SDK replacement before downloading modules. Copy its module
# metadata first so SDK source edits do not invalidate the dependency layer.
COPY --from=silo_plugin_sdk go.mod go.sum /tmp/silo-plugin-sdk/
RUN test -f /tmp/silo-plugin-sdk/go.mod
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
go mod edit -replace=github.com/Silo-Server/silo-plugin-sdk=/tmp/silo-plugin-sdk && \
go mod download
COPY --from=silo_plugin_sdk pkg/ /tmp/silo-plugin-sdk/pkg/
COPY web/embed.go web/embed.go
COPY --from=frontend /app/web/dist web/dist
COPY cmd/ cmd/
COPY internal/ internal/
COPY migrations/ migrations/
# See Dockerfile: the settings contract is an embedded Go package outside
# internal/, so the build fails without it.
COPY contracts/ contracts/
# Stage 3: Build Go binary for dev using a local plugin SDK checkout passed via
# BuildKit named context `silo_plugin_sdk`.
FROM build-base AS build
ARG BUILD_REVISION
ARG BUILD_DIRTY=false
ARG BUILD_NUMBER
ARG BUILD_DATE
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
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/
# Stage 4: Runtime
FROM debian:trixie-slim
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
RUN apt-get update && \
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 && \
apt-get update && \
apt-get install -y --no-install-recommends jellyfin-ffmpeg7 git libvips42 fonts-noto-core fonts-noto-cjk && \
apt-get purge -y gnupg && apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/*
# Keep the development image's tone-map runtime identical to the release image.
RUN if [ "${TARGETARCH}" = "amd64" ]; then \
runtime_dir="$(mktemp -d)" && \
cd "${runtime_dir}" && \
curl -fsSLO "https://github.com/intel/compute-runtime/releases/download/${INTEL_NEO_VERSION}/libigdgmm12_${INTEL_GMMLIB_VERSION}_amd64.deb" && \
curl -fsSLO "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 "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 "https://github.com/intel/compute-runtime/releases/download/${INTEL_NEO_VERSION}/intel-opencl-icd_${INTEL_NEO_VERSION}-0_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/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
COPY --from=build /silo /usr/local/bin/silo
EXPOSE 8080 8096 13378
HEALTHCHECK --interval=15s --timeout=5s --start-period=10s --retries=3 \
CMD curl -f http://localhost:${PORT:-8080}/api/v1/health || exit 1
ENTRYPOINT ["silo"]