FROM golang:1.26-alpine AS build
# CalVer, injected at build so no file needs bumping by hand: docker build --build-arg VERSION=…
ARG VERSION=dev
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 go build -ldflags "-X main.version=${VERSION}" -o /levyraati .

FROM alpine:3.24
# yt-dlp rots against YouTube. Alpine's active branch tracks it closely (3.24 carries the current
# release), so a rebuild is the update — and this avoids python3 + pip in the image entirely.
RUN apk add --no-cache ffmpeg yt-dlp ca-certificates
COPY --from=build /levyraati /usr/local/bin/levyraati
ENV STORAGE_DIR=/storage
EXPOSE 8080
ENTRYPOINT ["levyraati"]
