2026-03-28 11:29:42 +01:00
|
|
|
# ---- Build stage ----
|
2026-03-30 14:30:20 +02:00
|
|
|
FROM golang:1.25-alpine AS builder
|
2026-03-28 11:29:42 +01:00
|
|
|
|
|
|
|
|
RUN apk add --no-cache git ca-certificates
|
|
|
|
|
|
2026-03-30 14:30:20 +02:00
|
|
|
WORKDIR /src
|
2026-03-28 11:29:42 +01:00
|
|
|
|
|
|
|
|
# Copy go.mod/go.sum first for layer caching
|
2026-03-30 14:30:20 +02:00
|
|
|
COPY go.mod go.sum ./
|
2026-03-28 11:29:42 +01:00
|
|
|
RUN go mod download
|
|
|
|
|
|
2026-03-30 14:30:20 +02:00
|
|
|
# Copy source
|
|
|
|
|
COPY . .
|
2026-03-28 11:29:42 +01:00
|
|
|
|
2026-03-30 14:30:20 +02:00
|
|
|
ARG VERSION=dev
|
|
|
|
|
RUN CGO_ENABLED=0 go build -ldflags="-s -w -X github.com/torrentclaw/unarr/internal/cmd.Version=${VERSION}" -trimpath -o /unarr ./cmd/unarr/
|
2026-03-28 11:29:42 +01:00
|
|
|
|
|
|
|
|
# ---- Runtime stage ----
|
2026-03-31 11:39:45 +02:00
|
|
|
FROM alpine:3.22
|
2026-03-28 11:29:42 +01:00
|
|
|
|
2026-05-06 11:26:01 +02:00
|
|
|
# Use Alpine's native musl ffmpeg + ffprobe instead of the johnvansickle /
|
|
|
|
|
# BtbN static glibc builds — those need a glibc shim on Alpine and the
|
|
|
|
|
# vector-math symbols the GPL builds reference are not satisfiable by
|
2026-05-26 20:39:57 +02:00
|
|
|
# gcompat. Alpine ships ffmpeg ~7.x which is fine for the HLS transcoding
|
|
|
|
|
# pipeline (libx264 + libfdk-aac alternatives included).
|
2026-03-31 10:20:30 +02:00
|
|
|
RUN apk upgrade --no-cache && \
|
2026-05-26 20:39:57 +02:00
|
|
|
apk add --no-cache ca-certificates tzdata ffmpeg wget
|
|
|
|
|
|
|
|
|
|
# Bundle cloudflared so `unarr funnel on` (default: on, see config defaults)
|
|
|
|
|
# Just Works on a headless container with no first-run network round-trip.
|
|
|
|
|
# TARGETARCH is set automatically by Docker buildx during cross-builds.
|
|
|
|
|
ARG TARGETARCH=amd64
|
|
|
|
|
RUN case "$TARGETARCH" in \
|
|
|
|
|
amd64) CF_ARCH=amd64 ;; \
|
|
|
|
|
arm64) CF_ARCH=arm64 ;; \
|
|
|
|
|
arm) CF_ARCH=armhf ;; \
|
|
|
|
|
*) echo "unsupported TARGETARCH=$TARGETARCH" >&2; exit 1 ;; \
|
|
|
|
|
esac && \
|
|
|
|
|
wget -qO /usr/local/bin/cloudflared "https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-$CF_ARCH" && \
|
|
|
|
|
chmod +x /usr/local/bin/cloudflared
|
2026-03-28 11:29:42 +01:00
|
|
|
|
|
|
|
|
# Non-root user (UID 1000 matches typical host user for volume permissions)
|
|
|
|
|
RUN addgroup -g 1000 unarr && adduser -u 1000 -G unarr -D -h /home/unarr unarr
|
|
|
|
|
|
|
|
|
|
# Default directories
|
|
|
|
|
RUN mkdir -p /config /downloads /data && \
|
|
|
|
|
chown -R unarr:unarr /config /downloads /data
|
|
|
|
|
|
|
|
|
|
USER unarr
|
|
|
|
|
|
|
|
|
|
COPY --from=builder /unarr /usr/local/bin/unarr
|
|
|
|
|
|
|
|
|
|
# Environment: point config/data to container paths
|
|
|
|
|
ENV UNARR_CONFIG_DIR=/config
|
|
|
|
|
ENV UNARR_DOWNLOAD_DIR=/downloads
|
|
|
|
|
ENV XDG_DATA_HOME=/data
|
|
|
|
|
|
|
|
|
|
VOLUME ["/config", "/downloads", "/data"]
|
|
|
|
|
|
|
|
|
|
ENTRYPOINT ["unarr"]
|
|
|
|
|
CMD ["start"]
|