Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
xarantolus committed Sep 8, 2022
2 parents e238225 + 0652e1b commit bdbf352
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 36 deletions.
45 changes: 19 additions & 26 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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" ]
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<details>
<summary>If no recent build is available, you can also build for yourself.</summary>

Expand Down
29 changes: 19 additions & 10 deletions store/config/config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package config

import (
"log"
"os"
"strings"

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit bdbf352

Please # to comment.