2019-10-29 20:54:47 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
func buildAutheliaBinary() {
|
2019-11-01 20:15:58 +00:00
|
|
|
cmd := CommandWithStdout("go", "build", "-o", "../../"+OutputDir+"/authelia")
|
|
|
|
cmd.Dir = "cmd/authelia"
|
2019-10-29 20:54:47 +00:00
|
|
|
cmd.Env = append(os.Environ(),
|
|
|
|
"GOOS=linux", "GOARCH=amd64", "CGO_ENABLED=1")
|
|
|
|
|
|
|
|
err := cmd.Run()
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func buildFrontend() {
|
|
|
|
cmd := CommandWithStdout("npm", "run", "build")
|
|
|
|
cmd.Dir = "client"
|
|
|
|
err := cmd.Run()
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = os.Rename("client/build", OutputDir+"/public_html")
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Build build Authelia
|
|
|
|
func Build(cobraCmd *cobra.Command, args []string) {
|
|
|
|
Clean(cobraCmd, args)
|
|
|
|
|
|
|
|
fmt.Println("Creating `" + OutputDir + "` directory")
|
|
|
|
err := os.MkdirAll(OutputDir, os.ModePerm)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Println("Building Authelia Go binary...")
|
|
|
|
buildAutheliaBinary()
|
|
|
|
|
|
|
|
fmt.Println("Building Authelia frontend...")
|
|
|
|
buildFrontend()
|
|
|
|
}
|