Expose config to docker volume (#73)
* expose config to docker volume * fix dockerfile
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,11 +1,8 @@
|
|||||||
.parcel-cache
|
|
||||||
dist
|
dist
|
||||||
package-lock.json
|
package-lock.json
|
||||||
pnpm-lock.yaml
|
pnpm-lock.yaml
|
||||||
.pnpm-debug.log
|
.pnpm-debug.log
|
||||||
node_modules
|
node_modules
|
||||||
src/server/core/*.exe
|
|
||||||
src/server/core/yt-dlp
|
|
||||||
.env
|
.env
|
||||||
*.mp4
|
*.mp4
|
||||||
*.ytdl
|
*.ytdl
|
||||||
@@ -16,3 +13,4 @@ downloads
|
|||||||
build/
|
build/
|
||||||
yt-dlp-webui
|
yt-dlp-webui
|
||||||
session.dat
|
session.dat
|
||||||
|
config.yml
|
||||||
|
|||||||
16
Dockerfile
16
Dockerfile
@@ -1,25 +1,27 @@
|
|||||||
FROM golang:1.20-alpine AS build
|
FROM golang:1.20-alpine AS build
|
||||||
# folder structure
|
|
||||||
WORKDIR /usr/src/yt-dlp-webui
|
WORKDIR /usr/src/yt-dlp-webui
|
||||||
# install core dependencies
|
|
||||||
RUN apk update && \
|
RUN apk update && \
|
||||||
apk add nodejs npm go
|
apk add nodejs npm go
|
||||||
# copia la salsa
|
|
||||||
COPY . .
|
COPY . .
|
||||||
# build frontend
|
|
||||||
WORKDIR /usr/src/yt-dlp-webui/frontend
|
WORKDIR /usr/src/yt-dlp-webui/frontend
|
||||||
RUN npm install
|
RUN npm install
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
# build backend + incubator
|
|
||||||
WORKDIR /usr/src/yt-dlp-webui
|
WORKDIR /usr/src/yt-dlp-webui
|
||||||
RUN CGO_ENABLED=0 GOOS=linux go build -o yt-dlp-webui
|
RUN CGO_ENABLED=0 GOOS=linux go build -o yt-dlp-webui
|
||||||
|
|
||||||
# but here yes :)
|
|
||||||
FROM alpine:edge
|
FROM alpine:edge
|
||||||
|
|
||||||
WORKDIR /downloads
|
WORKDIR /downloads
|
||||||
VOLUME /downloads
|
VOLUME /downloads
|
||||||
|
|
||||||
|
WORKDIR /config
|
||||||
|
VOLUME /config
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
RUN apk update && \
|
RUN apk update && \
|
||||||
@@ -30,4 +32,4 @@ COPY --from=build /usr/src/yt-dlp-webui/yt-dlp-webui /app
|
|||||||
ENV JWT_SECRET=secret
|
ENV JWT_SECRET=secret
|
||||||
|
|
||||||
EXPOSE 3033
|
EXPOSE 3033
|
||||||
ENTRYPOINT [ "./yt-dlp-webui" , "--out", "/downloads" ]
|
ENTRYPOINT [ "./yt-dlp-webui" , "--out", "/downloads", "--conf", "/config/config.yml" ]
|
||||||
|
|||||||
8
main.go
8
main.go
@@ -8,6 +8,7 @@ import (
|
|||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
"github.com/marcopeocchi/yt-dlp-web-ui/server"
|
"github.com/marcopeocchi/yt-dlp-web-ui/server"
|
||||||
|
"github.com/marcopeocchi/yt-dlp-web-ui/server/cli"
|
||||||
"github.com/marcopeocchi/yt-dlp-web-ui/server/config"
|
"github.com/marcopeocchi/yt-dlp-web-ui/server/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -29,7 +30,7 @@ func init() {
|
|||||||
flag.IntVar(&port, "port", 3033, "Port where server will listen at")
|
flag.IntVar(&port, "port", 3033, "Port where server will listen at")
|
||||||
flag.IntVar(&queueSize, "qs", runtime.NumCPU(), "Download queue size")
|
flag.IntVar(&queueSize, "qs", runtime.NumCPU(), "Download queue size")
|
||||||
|
|
||||||
flag.StringVar(&configFile, "conf", "", "Config file path")
|
flag.StringVar(&configFile, "conf", "./config.yml", "Config file path")
|
||||||
flag.StringVar(&downloadPath, "out", ".", "Where files will be saved")
|
flag.StringVar(&downloadPath, "out", ".", "Where files will be saved")
|
||||||
flag.StringVar(&downloaderPath, "driver", "yt-dlp", "yt-dlp executable path")
|
flag.StringVar(&downloaderPath, "driver", "yt-dlp", "yt-dlp executable path")
|
||||||
|
|
||||||
@@ -56,8 +57,9 @@ func main() {
|
|||||||
c.RequireAuth(requireAuth)
|
c.RequireAuth(requireAuth)
|
||||||
c.RPCSecret(rpcSecret)
|
c.RPCSecret(rpcSecret)
|
||||||
|
|
||||||
if configFile != "" {
|
// if config file is found it will be merged with the current config struct
|
||||||
c.LoadFromFile(configFile)
|
if _, err := c.TryLoadFromFile(configFile); err != nil {
|
||||||
|
log.Println(cli.BgRed, "config", cli.Reset, "no config file found")
|
||||||
}
|
}
|
||||||
|
|
||||||
server.RunBlocking(port, frontend)
|
server.RunBlocking(port, frontend)
|
||||||
|
|||||||
@@ -22,13 +22,15 @@ type config struct {
|
|||||||
cfg serverConfig
|
cfg serverConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *config) LoadFromFile(filename string) (serverConfig, error) {
|
func (c *config) TryLoadFromFile(filename string) (serverConfig, error) {
|
||||||
bytes, err := os.ReadFile(filename)
|
fd, err := os.Open(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return serverConfig{}, err
|
return serverConfig{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
yaml.Unmarshal(bytes, &c.cfg)
|
if err := yaml.NewDecoder(fd).Decode(&c.cfg); err != nil {
|
||||||
|
return serverConfig{}, err
|
||||||
|
}
|
||||||
|
|
||||||
return c.cfg, nil
|
return c.cfg, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user