49 lines
1.6 KiB
Docker
49 lines
1.6 KiB
Docker
# =========
|
|
# Builder
|
|
# =========
|
|
FROM rust:bookworm as builder
|
|
WORKDIR /builder
|
|
|
|
COPY migrations ./migrations
|
|
COPY src ./src
|
|
COPY Cargo.toml ./
|
|
|
|
RUN apt-get update && apt-get install -y cmake
|
|
RUN cargo build --release
|
|
|
|
# ==========
|
|
# Packages
|
|
# ==========
|
|
FROM debian:bookworm-slim as packages
|
|
WORKDIR /packages
|
|
|
|
ARG TARGETPLATFORM
|
|
|
|
RUN apt-get update && apt-get install -y python3 curl tar xz-utils && \
|
|
# Download the platform-independent yt-dlp binary
|
|
curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp > yt-dlp && \
|
|
# Make yt-dlp executable
|
|
chmod +x yt-dlp && \
|
|
# Install ffmpeg for media conversions
|
|
if [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
|
|
curl -L https://github.com/yt-dlp/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linuxarm64-gpl.tar.xz > ffmpeg.tar.xz && \
|
|
tar -xJf ffmpeg.tar.xz --wildcards */bin/ffmpeg --transform='s/^.*\///' && rm ffmpeg.tar.xz; \
|
|
elif [ "$TARGETPLATFORM" = "linux/x86_64" ] || [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
|
|
curl -L https://github.com/yt-dlp/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linux64-gpl.tar.xz > ffmpeg.tar.xz && \
|
|
tar -xJf ffmpeg.tar.xz --wildcards */bin/ffmpeg --transform='s/^.*\///' && rm ffmpeg.tar.xz; \
|
|
fi
|
|
|
|
# =========
|
|
# Runtime
|
|
# =========
|
|
FROM debian:bookworm-slim as runtime
|
|
WORKDIR /siren
|
|
USER root
|
|
|
|
COPY --from=builder /builder/target/release/siren /usr/local/bin/siren
|
|
COPY --from=packages /packages /usr/bin
|
|
|
|
RUN apt-get update && apt-get install -y libc6 libc6-dev libopus-dev libpq5 libpq-dev python3-pip ffmpeg
|
|
|
|
CMD ["siren"]
|