authelia/cmd/authelia-scripts/cmd_build.go
James Elliott 8aade7f40e
[MISC] Update durations to notation format and housekeeping (#824)
* added regulation validator
* made regulations find_time and ban_time values duration notation strings
* added DefaultRegulationConfiguration for the validator
* made session expiration and inactivity values duration notation strings
* TOTP period does not need to be converted because adjustment should be discouraged
* moved TOTP defaults to DefaultTOTPConfiguration and removed the consts
* arranged the root config validator in configuration file order
* adjusted tests for the changes
* moved duration notation docs to root of configuration
* added references to duration notation where applicable
* project wide gofmt and goimports:
* run gofmt
* run goimports -local github.com/authelia/authelia -w on all files
* Make jwt_secret error uniform and add tests
* now at 100% coverage for internal/configuration/validator/configuration.go
2020-04-05 22:37:21 +10:00

66 lines
1.2 KiB
Go

package main
import (
"os"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/authelia/authelia/internal/utils"
)
func buildAutheliaBinary() {
cmd := utils.CommandWithStdout("go", "build", "-o", "../../"+OutputDir+"/authelia")
cmd.Dir = "cmd/authelia"
cmd.Env = append(os.Environ(),
"GOOS=linux", "GOARCH=amd64", "CGO_ENABLED=1")
err := cmd.Run()
if err != nil {
panic(err)
}
}
func buildFrontend() {
// Install npm dependencies
cmd := utils.CommandWithStdout("yarn", "install")
cmd.Dir = "web"
if err := cmd.Run(); err != nil {
log.Fatal(err)
}
// Then build the frontend
cmd = utils.CommandWithStdout("yarn", "build")
cmd.Dir = "web"
if err := cmd.Run(); err != nil {
log.Fatal(err)
}
if err := os.Rename("web/build", OutputDir+"/public_html"); err != nil {
log.Fatal(err)
}
}
// Build build Authelia
func Build(cobraCmd *cobra.Command, args []string) {
log.Info("Building Authelia...")
Clean(cobraCmd, args)
log.Debug("Creating `" + OutputDir + "` directory")
err := os.MkdirAll(OutputDir, os.ModePerm)
if err != nil {
panic(err)
}
log.Debug("Building Authelia Go binary...")
buildAutheliaBinary()
log.Debug("Building Authelia frontend...")
buildFrontend()
}