refactor: cra build path (#2117)
* refactor: cra build path The `authelia-scripts` helper currently performs steps to move files around in different stages of development and CI/CD. We now utilise the `BUILD_PATH` environment variable to adjust the output directory for the web frontend from the default of `./web/build/` simplifying the helper somewhat. Additionally we no longer build the Go binary in the unit test stage of our CI/CD as this is not necessary. * fix: build output directory in coverage dockerfilepull/2114/head^2
parent
41f1162651
commit
756aee507f
|
@ -33,7 +33,7 @@ steps:
|
||||||
if: build.branch !~ /^(v[0-9]+\.[0-9]+\.[0-9]+)$\$/
|
if: build.branch !~ /^(v[0-9]+\.[0-9]+\.[0-9]+)$\$/
|
||||||
|
|
||||||
- label: ":hammer_and_wrench: Unit Test"
|
- label: ":hammer_and_wrench: Unit Test"
|
||||||
command: "authelia-scripts --log-level debug ci"
|
command: "authelia-scripts --log-level debug ci --buildkite"
|
||||||
agents:
|
agents:
|
||||||
build: "unit-test"
|
build: "unit-test"
|
||||||
artifact_paths:
|
artifact_paths:
|
||||||
|
|
|
@ -26,7 +26,7 @@ go mod download
|
||||||
COPY / ./
|
COPY / ./
|
||||||
|
|
||||||
# Prepare static files to be embedded in Go binary
|
# Prepare static files to be embedded in Go binary
|
||||||
COPY --from=builder-frontend /node/src/app/build internal/server/public_html
|
COPY --from=builder-frontend /node/src/internal/server/public_html internal/server/public_html
|
||||||
|
|
||||||
ARG LDFLAGS_EXTRA
|
ARG LDFLAGS_EXTRA
|
||||||
RUN \
|
RUN \
|
||||||
|
|
|
@ -41,18 +41,6 @@ func buildFrontend() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd = utils.CommandWithStdout("rm", "-rf", "internal/server/public_html")
|
|
||||||
|
|
||||||
err = cmd.Run()
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
err = os.Rename("web/build", "internal/server/public_html")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildSwagger() {
|
func buildSwagger() {
|
||||||
|
@ -128,7 +116,13 @@ func Build(cobraCmd *cobra.Command, args []string) {
|
||||||
log.Debug("Building swagger-ui frontend...")
|
log.Debug("Building swagger-ui frontend...")
|
||||||
buildSwagger()
|
buildSwagger()
|
||||||
|
|
||||||
|
buildkite, _ := cobraCmd.Flags().GetBool("buildkite")
|
||||||
|
if buildkite {
|
||||||
|
log.Debug("Buildkite job detected, skipping Authelia Go binary build")
|
||||||
|
} else {
|
||||||
log.Debug("Building Authelia Go binary...")
|
log.Debug("Building Authelia Go binary...")
|
||||||
buildAutheliaBinary(xflags)
|
buildAutheliaBinary(xflags)
|
||||||
|
}
|
||||||
|
|
||||||
cleanAssets()
|
cleanAssets()
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,9 +11,16 @@ import (
|
||||||
func RunCI(cmd *cobra.Command, args []string) {
|
func RunCI(cmd *cobra.Command, args []string) {
|
||||||
log.Info("=====> Build stage <=====")
|
log.Info("=====> Build stage <=====")
|
||||||
|
|
||||||
|
buildkite, _ := cmd.Flags().GetBool("buildkite")
|
||||||
|
if buildkite {
|
||||||
|
if err := utils.CommandWithStdout("authelia-scripts", "--log-level", "debug", "--buildkite", "build").Run(); err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if err := utils.CommandWithStdout("authelia-scripts", "--log-level", "debug", "build").Run(); err != nil {
|
if err := utils.CommandWithStdout("authelia-scripts", "--log-level", "debug", "build").Run(); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
log.Info("=====> Unit testing stage <=====")
|
log.Info("=====> Unit testing stage <=====")
|
||||||
|
|
||||||
|
|
|
@ -52,14 +52,7 @@ func dockerBuildOfficialImage(arch string) error {
|
||||||
dockerfile = fmt.Sprintf("%s.%s", dockerfile, arch)
|
dockerfile = fmt.Sprintf("%s.%s", dockerfile, arch)
|
||||||
}
|
}
|
||||||
|
|
||||||
if arch == "arm32v7" {
|
if arch == "arm32v7" || arch == "arm64v8" {
|
||||||
if buildkiteQEMU != stringTrue {
|
|
||||||
err := utils.CommandWithStdout("docker", "run", "--rm", "--privileged", "multiarch/qemu-user-static", "--reset", "-p", "yes").Run()
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if arch == "arm64v8" {
|
|
||||||
if buildkiteQEMU != stringTrue {
|
if buildkiteQEMU != stringTrue {
|
||||||
err := utils.CommandWithStdout("docker", "run", "--rm", "--privileged", "multiarch/qemu-user-static", "--reset", "-p", "yes").Run()
|
err := utils.CommandWithStdout("docker", "run", "--rm", "--privileged", "multiarch/qemu-user-static", "--reset", "-p", "yes").Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
"github.com/authelia/authelia/internal/utils"
|
"github.com/authelia/authelia/internal/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var buildkite bool
|
||||||
var logLevel string
|
var logLevel string
|
||||||
|
|
||||||
// AutheliaCommandDefinition is the definition of one authelia-scripts command.
|
// AutheliaCommandDefinition is the definition of one authelia-scripts command.
|
||||||
|
@ -137,6 +138,7 @@ func main() {
|
||||||
|
|
||||||
cobraCommands = append(cobraCommands, commands.HashPasswordCmd, commands.CertificatesCmd, commands.RSACmd, xflagsCmd)
|
cobraCommands = append(cobraCommands, commands.HashPasswordCmd, commands.CertificatesCmd, commands.RSACmd, xflagsCmd)
|
||||||
|
|
||||||
|
rootCmd.PersistentFlags().BoolVar(&buildkite, "buildkite", false, "Set CI flag for Buildkite")
|
||||||
rootCmd.PersistentFlags().StringVar(&logLevel, "log-level", "info", "Set the log level for the command")
|
rootCmd.PersistentFlags().StringVar(&logLevel, "log-level", "info", "Set the log level for the command")
|
||||||
rootCmd.AddCommand(cobraCommands...)
|
rootCmd.AddCommand(cobraCommands...)
|
||||||
cobra.OnInitialize(initConfig)
|
cobra.OnInitialize(initConfig)
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
BUILD_PATH=../internal/server/public_html
|
||||||
PUBLIC_URL={{.Base}}
|
PUBLIC_URL={{.Base}}
|
||||||
REACT_APP_REMEMBER_ME={{.RememberMe}}
|
REACT_APP_REMEMBER_ME={{.RememberMe}}
|
||||||
REACT_APP_RESET_PASSWORD={{.ResetPassword}}
|
REACT_APP_RESET_PASSWORD={{.ResetPassword}}
|
||||||
|
|
Loading…
Reference in New Issue