mirror of
https://github.com/caddyserver/xcaddy.git
synced 2025-01-22 16:46:55 +01:00
Add XCADDY_SKIP_BUILD option (#41)
* feat: add XCADDY_NO_BUILD to not run go build * Rename XCADDY_NO_BUILD to XCADDY_SKIP_BUILD * fix rebase
This commit is contained in:
parent
e7b19b13a2
commit
5734acdd58
3 changed files with 12 additions and 1 deletions
|
@ -124,8 +124,9 @@ Because the subcommands and flags are constrained to benefit rapid plugin protot
|
|||
|
||||
- `CADDY_VERSION` sets the version of Caddy to build.
|
||||
- `XCADDY_RACE_DETECTOR=1` enables the Go race detector in the build.
|
||||
- `XCADDY_SKIP_CLEANUP=1` causes xcaddy to leave build artifacts on disk after exiting.
|
||||
- `XCADDY_SETCAP=1` will run `sudo setcap cap_net_bind_service=+ep` on the temporary binary before running it when in dev mode.
|
||||
- `XCADDY_SKIP_BUILD=1` causes xcaddy to not compile the program, it is used in conjunction with build tools such as [GoReleaser](https://goreleaser.com). Implies `XCADDY_SKIP_CLEANUP=1`.
|
||||
- `XCADDY_SKIP_CLEANUP=1` causes xcaddy to leave build artifacts on disk after exiting.
|
||||
|
||||
---
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ type Builder struct {
|
|||
TimeoutBuild time.Duration `json:"timeout_build,omitempty"`
|
||||
RaceDetector bool `json:"race_detector,omitempty"`
|
||||
SkipCleanup bool `json:"skip_cleanup,omitempty"`
|
||||
SkipBuild bool `json:"skip_build,omitempty"`
|
||||
}
|
||||
|
||||
// Build builds Caddy at the configured version with the
|
||||
|
@ -77,6 +78,12 @@ func (b Builder) Build(ctx context.Context, outputFile string) error {
|
|||
}
|
||||
defer buildEnv.Close()
|
||||
|
||||
if b.SkipBuild {
|
||||
log.Printf("[INFO] Skipping build as requested")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// prepare the environment for the go command; for
|
||||
// the most part we want it to inherit our current
|
||||
// environment, with a few customizations
|
||||
|
|
|
@ -32,6 +32,7 @@ import (
|
|||
var (
|
||||
caddyVersion = os.Getenv("CADDY_VERSION")
|
||||
raceDetector = os.Getenv("XCADDY_RACE_DETECTOR") == "1"
|
||||
skipBuild = os.Getenv("XCADDY_SKIP_BUILD") == "1"
|
||||
skipCleanup = os.Getenv("XCADDY_SKIP_CLEANUP") == "1"
|
||||
)
|
||||
|
||||
|
@ -111,6 +112,7 @@ func runBuild(ctx context.Context, args []string) error {
|
|||
Plugins: plugins,
|
||||
Replacements: replacements,
|
||||
RaceDetector: raceDetector,
|
||||
SkipBuild: skipBuild,
|
||||
SkipCleanup: skipCleanup,
|
||||
}
|
||||
err := builder.Build(ctx, output)
|
||||
|
@ -216,6 +218,7 @@ func runDev(ctx context.Context, args []string) error {
|
|||
},
|
||||
Replacements: replacements,
|
||||
RaceDetector: raceDetector,
|
||||
SkipBuild: skipBuild,
|
||||
SkipCleanup: skipCleanup,
|
||||
}
|
||||
err = builder.Build(ctx, binOutput)
|
||||
|
|
Loading…
Reference in a new issue