Download browser during docker build
All checks were successful
Build / build (push) Successful in 2m52s

Closes #1
This commit is contained in:
Sebastiaan de Schaetzen 2025-02-10 13:14:27 +01:00
parent 97e7a8b8fc
commit acc5bcdcfc
2 changed files with 17 additions and 4 deletions

View File

@ -15,4 +15,5 @@ COPY migrations ./migrations
COPY *.go ./
RUN go build -o /vivaplusdl
CMD ["/vivaplusdl"]
RUN /vivaplusdl --install
CMD ["/vivaplusdl", "--no-install"]

18
main.go
View File

@ -2,6 +2,7 @@ package main
import (
"encoding/base64"
"flag"
"github.com/playwright-community/playwright-go"
"log"
"os"
@ -10,12 +11,23 @@ import (
)
func main() {
var err error
var noInstall = flag.Bool("no-install", false, "skip browser installation")
var onlyInstall = flag.Bool("install", false, "install the required browser and do nothing else")
flag.Parse()
options := &playwright.RunOptions{
Browsers: []string{"firefox"},
}
err := playwright.Install(options)
if err != nil {
log.Panicf("error installing playwright: %v", err)
if !*noInstall {
err = playwright.Install(options)
if err != nil {
log.Panicf("error installing playwright: %v", err)
}
}
if *onlyInstall {
return
}
db := openDatabase()