Start of docker support
This commit is contained in:
parent
ee7b8565cc
commit
14c79a7ff2
@ -10,6 +10,7 @@ All notable changes to this project will be documented in this file.
|
||||
- Show version in web UI
|
||||
- Fixes and improvements to capturing output info and showing it in the UI
|
||||
- Improve index page (show URL of queued downloads instead of nothing)
|
||||
- Add docker support
|
||||
|
||||
## [v0.5.5] - 2022-04-09
|
||||
|
||||
|
47
Dockerfile
Normal file
47
Dockerfile
Normal file
@ -0,0 +1,47 @@
|
||||
# Start from golang base image
|
||||
FROM golang:1.18.2-alpine3.15 as builder
|
||||
|
||||
# Install git. (alpine image does not have git in it)
|
||||
RUN apk update && apk add --no-cache git curl
|
||||
|
||||
# Set current working directory
|
||||
WORKDIR /app
|
||||
|
||||
RUN curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o /app/yt-dlp
|
||||
RUN chmod a+x /app/yt-dlp
|
||||
|
||||
# Note here: To avoid downloading dependencies every time we
|
||||
# build image. Here, we are caching all the dependencies by
|
||||
# first copying go.mod and go.sum files and downloading them,
|
||||
# to be used every time we build the image if the dependencies
|
||||
# are not changed.
|
||||
|
||||
# Copy go mod and sum files
|
||||
COPY go.mod ./
|
||||
COPY go.sum ./
|
||||
|
||||
# Download all dependencies.
|
||||
RUN go mod download
|
||||
|
||||
# Now, copy the source code
|
||||
COPY . .
|
||||
|
||||
# Note here: CGO_ENABLED is disabled for cross system compilation
|
||||
# It is also a common best practise.
|
||||
|
||||
# Build the application.
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./bin/gropple .
|
||||
|
||||
# Finally our multi-stage to build a small image
|
||||
# Start a new stage from scratch
|
||||
FROM alpine:3.15.4
|
||||
|
||||
# Copy the Pre-built binary file
|
||||
COPY --from=builder /app/bin/gropple .
|
||||
COPY --from=builder /app/yt-dlp /bin/
|
||||
|
||||
# Install things we need to support yt-dlp
|
||||
RUN apk update && apk add --no-cache python3 ffmpeg
|
||||
|
||||
# Run executable
|
||||
CMD ["./gropple", "--config-path", "/config/gropple.json"]
|
@ -61,13 +61,13 @@ func (cs *ConfigService) LoadTestConfig() {
|
||||
|
||||
func (cs *ConfigService) LoadDefaultConfig() {
|
||||
defaultConfig := Config{}
|
||||
stdProfile := DownloadProfile{Name: "standard video", Command: "youtube-dl", Args: []string{
|
||||
stdProfile := DownloadProfile{Name: "standard video", Command: "yt-dlp", Args: []string{
|
||||
"--newline",
|
||||
"--write-info-json",
|
||||
"-f",
|
||||
"bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best",
|
||||
}}
|
||||
mp3Profile := DownloadProfile{Name: "standard mp3", Command: "youtube-dl", Args: []string{
|
||||
mp3Profile := DownloadProfile{Name: "standard mp3", Command: "yt-dlp", Args: []string{
|
||||
"--newline",
|
||||
"--write-info-json",
|
||||
"--extract-audio",
|
||||
@ -79,7 +79,7 @@ func (cs *ConfigService) LoadDefaultConfig() {
|
||||
|
||||
defaultConfig.Server.Port = 6123
|
||||
defaultConfig.Server.Address = "http://localhost:6123"
|
||||
defaultConfig.Server.DownloadPath = "./"
|
||||
defaultConfig.Server.DownloadPath = "/downloads"
|
||||
|
||||
defaultConfig.UI.PopupWidth = 500
|
||||
defaultConfig.UI.PopupHeight = 500
|
||||
|
12
main.go
12
main.go
@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"embed"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"io"
|
||||
@ -43,8 +44,17 @@ type errorResponse struct {
|
||||
func main() {
|
||||
log.Printf("Starting gropple %s - https://github.com/tardisx/gropple", versionInfo.GetInfo().CurrentVersion)
|
||||
|
||||
var configPath string
|
||||
flag.StringVar(&configPath, "config-path", "", "path to config file")
|
||||
flag.Parse()
|
||||
|
||||
configService = &config.ConfigService{}
|
||||
configService.DetermineConfigDir()
|
||||
if configPath != "" {
|
||||
configService.ConfigPath = configPath
|
||||
} else {
|
||||
configService.DetermineConfigDir()
|
||||
}
|
||||
|
||||
exists, err := configService.ConfigFileExists()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
Loading…
x
Reference in New Issue
Block a user