diff --git a/Dockerfile b/Dockerfile index 4cdeafd..8f3f74b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,26 +1,19 @@ -FROM golang:1.18 as builder - -# Build the normal executable -RUN mkdir /build -COPY . /build -WORKDIR /build -RUN CGO_ENABLED=0 go build -a -v -mod vendor -ldflags "-s -w" -o sensibleHub . - - -# Now for the image we actually run the server in -FROM python:3-alpine - -# Install ffmpeg -RUN apk add ca-certificates ffmpeg -ENV PATH="/bin:${PATH}" - -RUN apk add --no-cache --virtual .pynacl_deps build-base python3-dev libffi-dev - -# Install youtube-dl -RUN pip install yt-dlp - -RUN apk del .pynacl_deps - -# Copy main executable -COPY --from=builder /build/sensibleHub . -ENTRYPOINT [ "./sensibleHub", "-config", "/config/config.json" ] +FROM golang:1.18 as builder + +# Build the normal executable +RUN mkdir /build +COPY . /build +WORKDIR /build +RUN CGO_ENABLED=0 go build -a -v -mod vendor -ldflags "-s -w" -o sensibleHub . + + +# Now for the image we actually run the server in +FROM alpine:latest +RUN apk add ca-certificates ffmpeg python3 +# Copy main executable +COPY --from=builder /build/sensibleHub . +# Download yt-dlp +RUN wget -qO /bin/yt-dlp https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp && chmod +x /bin/yt-dlp +ENV PATH="/bin:${PATH}" +ENV RUNNING_IN_DOCKER=true +ENTRYPOINT [ "./sensibleHub", "-config", "/config/config.json" ] diff --git a/README.md b/README.md index ae3ed6f..5c9cf70 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,8 @@ If you prefer using Docker, you can run the following in a directory that contai docker run -v"$(pwd):/config" -v"$(pwd)/data:/data" -p 128:128 -p 1280:1280 ghcr.io/xarantolus/sensiblehub:master +The volume mounted at `/config` must contain a `config.json` file. To change the exposed ports, you can modify the first port (before the `:`) in the command to another port. If you didn't change the configuration file `128` is the default HTTP port, `1280` is used for FTP. +
If no recent build is available, you can also build for yourself. diff --git a/store/config/config.go b/store/config/config.go index 9fa5fa6..509db56 100644 --- a/store/config/config.go +++ b/store/config/config.go @@ -1,6 +1,7 @@ package config import ( + "log" "os" "strings" @@ -53,18 +54,26 @@ func Parse(path string) (c Config, err error) { return } - // Set default paths/names if none are set - c.Alternatives.FFmpeg = strings.TrimSpace(c.Alternatives.FFmpeg) - if c.Alternatives.FFmpeg == "" { + rid, ok := os.LookupEnv("RUNNING_IN_DOCKER") + if ok && strings.ToLower(rid) == "true" { c.Alternatives.FFmpeg = "ffmpeg" - } - c.Alternatives.FFprobe = strings.TrimSpace(c.Alternatives.FFprobe) - if c.Alternatives.FFprobe == "" { c.Alternatives.FFprobe = "ffprobe" - } - c.Alternatives.YoutubeDL = strings.TrimSpace(c.Alternatives.YoutubeDL) - if c.Alternatives.YoutubeDL == "" { - c.Alternatives.YoutubeDL = "youtube-dl" + c.Alternatives.YoutubeDL = "yt-dlp" + log.Println("[Info] Running in Docker, using local binaries. This means that the \"alternatives\" config part is ignored!") + } else { + // Set default paths/names if none are set + c.Alternatives.FFmpeg = strings.TrimSpace(c.Alternatives.FFmpeg) + if c.Alternatives.FFmpeg == "" { + c.Alternatives.FFmpeg = "ffmpeg" + } + c.Alternatives.FFprobe = strings.TrimSpace(c.Alternatives.FFprobe) + if c.Alternatives.FFprobe == "" { + c.Alternatives.FFprobe = "ffprobe" + } + c.Alternatives.YoutubeDL = strings.TrimSpace(c.Alternatives.YoutubeDL) + if c.Alternatives.YoutubeDL == "" { + c.Alternatives.YoutubeDL = "youtube-dl" + } } return