Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
146 lines (116 loc) · 5.82 KB
/
Copy pathDockerfile
File metadata and controls
146 lines (116 loc) · 5.82 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
FROM node:24.18.1-slim AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
FROM base AS builder
WORKDIR /build
# Build toolchain for native addons that lack prebuilt binaries on this platform
# (e.g. yencode, used by the native usenet engine, has no linux/arm64 prebuild and
# must be compiled with node-gyp → needs Python + a C/C++ toolchain). These tools
# live only in the builder/runtime stages; the final distroless image just copies
# the already-compiled .node binaries, so it stays clean.
RUN apt-get update \
&& apt-get install -y --no-install-recommends python3 make g++ \
&& rm -rf /var/lib/apt/lists/*
# Copy LICENSE file.
COPY LICENSE ./
# Copy the relevant package.json and package-lock.json files.
COPY package*.json ./
COPY packages/server/package*.json ./packages/server/
COPY packages/core/package*.json ./packages/core/
COPY packages/frontend/package*.json ./packages/frontend/
COPY packages/ui/package*.json ./packages/ui/
COPY packages/web/package*.json ./packages/web/
COPY packages/crypto/package*.json ./packages/crypto/
COPY pnpm-workspace.yaml ./pnpm-workspace.yaml
COPY pnpm-lock.yaml ./pnpm-lock.yaml
COPY patches ./patches
# Install dependencies.
RUN pnpm install --frozen-lockfile
# Copy source files.
COPY tsconfig.*json ./
COPY packages/server ./packages/server
COPY packages/core ./packages/core
COPY packages/frontend ./packages/frontend
COPY packages/ui ./packages/ui
COPY packages/web ./packages/web
COPY packages/crypto ./packages/crypto
COPY scripts ./scripts
COPY resources ./resources
# Build the project.
RUN pnpm run build
# Remove development dependencies.
RUN rm -rf node_modules
RUN rm -rf packages/core/node_modules
RUN rm -rf packages/server/node_modules
RUN rm -rf packages/frontend/node_modules
RUN rm -rf packages/ui/node_modules
RUN rm -rf packages/web/node_modules
RUN pnpm install --prod --frozen-lockfile
FROM builder AS runtime
WORKDIR /runtime
# Copy the built files from the builder.
# The package.json files must be copied as well for NPM workspace symlinks between local packages to work.
COPY --from=builder /build/package*.json /build/LICENSE ./
COPY --from=builder /build/pnpm-workspace.yaml ./pnpm-workspace.yaml
COPY --from=builder /build/pnpm-lock.yaml ./pnpm-lock.yaml
COPY --from=builder /build/patches ./patches
COPY --from=builder /build/packages/core/package.*json ./packages/core/
COPY --from=builder /build/packages/server/package.*json ./packages/server/
# Loader + built binary; core's node_modules symlink into packages/ resolves it.
COPY --from=builder /build/packages/crypto ./packages/crypto
COPY --from=builder /build/packages/core/dist ./packages/core/dist
COPY --from=builder /build/packages/frontend/dist ./packages/frontend/dist
COPY --from=builder /build/packages/web/dist ./packages/web/dist
COPY --from=builder /build/packages/server/dist ./packages/server/dist
COPY --from=builder /build/packages/server/src/static ./packages/server/dist/static
COPY --from=builder /build/resources ./resources
COPY --from=builder /build/scripts ./scripts
COPY --from=builder /build/node_modules ./node_modules
COPY --from=builder /build/packages/core/node_modules ./packages/core/node_modules
COPY --from=builder /build/packages/server/node_modules ./packages/server/node_modules
FROM debian:12-slim AS mimalloc
RUN apt-get update \
&& apt-get install -y --no-install-recommends libmimalloc2.0 \
&& rm -rf /var/lib/apt/lists/* \
&& cp /usr/lib/*/libmimalloc.so.2 /usr/local/lib/libmimalloc.so.2
# zlib is linked statically: the runtime image has no libz.
FROM debian:12-slim AS ffprobe
ARG FFMPEG_VERSION=8.1.3
ARG FFMPEG_SHA256=7138d28c96d9d3e3af4ee3d8cad72741f8ffb40da90c1112235dea3ecd3178a3
RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates curl xz-utils gcc libc6-dev make zlib1g-dev \
&& rm -rf /var/lib/apt/lists/* \
&& rm /usr/lib/*/libz.so
WORKDIR /src
RUN curl -fsSL -o ffmpeg.tar.xz "https://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.xz" \
&& echo "${FFMPEG_SHA256} ffmpeg.tar.xz" | sha256sum -c - \
&& tar -xJf ffmpeg.tar.xz --strip-components=1 \
&& ./configure \
--disable-everything --disable-autodetect --disable-doc --disable-debug \
--disable-programs --enable-ffprobe \
--disable-avdevice --disable-avfilter --disable-swscale --disable-swresample \
--disable-x86asm --enable-zlib \
--enable-protocol=file,http,tcp \
--enable-demuxer=asf,avi,flv,matroska,mov,mpegps,mpegts,ogg \
--enable-parser=aac,aac_latm,ac3,av1,dca,dvbsub,dvdsub,flac,h264,hevc,mlp,mpeg4video,mpegaudio,mpegvideo,opus,vc1,vorbis,vp8,vp9 \
--enable-decoder=aac,aac_latm,ac3,alac,dca,eac3,flac,mlp,mp2,mp3,opus,truehd,vorbis,pcm_bluray,pcm_dvd,pcm_s16le,pcm_s24le,h264,hevc,mpeg2video,mpeg4,vc1,vp8,vp9,ass,ssa,subrip,srt,webvtt,movtext,pgssub,dvdsub,dvbsub \
&& make -j"$(nproc)" ffprobe \
&& strip ffprobe
FROM gcr.io/distroless/nodejs24-debian13 AS production
LABEL org.opencontainers.image.title="AIOStreams"
LABEL org.opencontainers.image.source="https://github.com/Viren070/AIOStreams"
LABEL org.opencontainers.image.description="AIOStreams consolidates multiple Stremio addons and debrid services - including its own suite of built-in addons - into a single, highly customisable super-addon."
LABEL org.opencontainers.image.licenses="AGPL-3.0-only"
WORKDIR /app
COPY --from=busybox:1.36.0-uclibc /bin/wget /bin/wget
COPY --from=busybox:1.36.0-uclibc /bin/sh /bin/sh
COPY --from=mimalloc /usr/local/lib/libmimalloc.so.2 /usr/local/lib/libmimalloc.so.2
ENV LD_PRELOAD=/usr/local/lib/libmimalloc.so.2
COPY --from=ffprobe /src/ffprobe /usr/local/bin/ffprobe
ENV NODE_OPTIONS="--max-semi-space-size=8 --expose-gc"
COPY --from=runtime /runtime /app
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
CMD ["/nodejs/bin/node", "/app/scripts/healthcheck.js"]
EXPOSE ${PORT:-3000}
CMD ["/app/packages/server/dist/server.js"]