Giter Site home page Giter Site logo

xcaddy's Introduction

xcaddy - Custom Caddy Builder

This command line tool and associated Go package makes it easy to make custom builds of the Caddy Web Server.

It is used heavily by Caddy plugin developers as well as anyone who wishes to make custom caddy binaries (with or without plugins).

Stay updated, be aware of changes, and please submit feedback! Thanks!

Requirements

Install

You can download binaries that are already compiled for your platform from the Release tab.

You may also build xcaddy from source:

go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest

For Debian, Ubuntu, and Raspbian, an xcaddy package is available from our Cloudsmith repo:

sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/xcaddy/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-xcaddy-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/xcaddy/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-xcaddy.list
sudo apt update
sudo apt install xcaddy

⚠️ Pro tip

If you find yourself fighting xcaddy in relation to your custom or proprietary build or development process, it might be easier to just build Caddy manually!

Caddy's main.go file, the main entry point to the application, has instructions in the comments explaining how to build Caddy essentially the same way xcaddy does it. But when you use the go command directly, you have more control over the whole thing and it may save you a lot of trouble.

The manual build procedure is very easy: just copy the main.go into a new folder, initialize a Go module, plug in your plugins (add an import for each one) and then run go build. Of course, you may wish to customize the go.mod file to your liking (specific dependency versions, replacements, etc).

Command usage

The xcaddy command has two primary uses:

  1. Compile custom caddy binaries
  2. A replacement for go run while developing Caddy plugins

The xcaddy command will use the latest version of Caddy by default. You can customize this for all invocations by setting the CADDY_VERSION environment variable.

As usual with go command, the xcaddy command will pass the GOOS, GOARCH, and GOARM environment variables through for cross-compilation.

Note that xcaddy will ignore the vendor/ folder with -mod=readonly.

Custom builds

Syntax:

$ xcaddy build [<caddy_version>]
    [--output <file>]
    [--with <module[@version][=replacement]>...]
    [--replace <module[@version]=replacement>...]
    [--embed <[alias]:path/to/dir>...]
  • <caddy_version> is the core Caddy version to build; defaults to CADDY_VERSION env variable or latest.
    This can be the keyword latest, which will use the latest stable tag, or any git ref such as:

    • A tag like v2.0.1
    • A branch like master
    • A commit like a58f240d3ecbb59285303746406cab50217f8d24
  • --output changes the output file.

  • --with can be used multiple times to add plugins by specifying the Go module name and optionally its version, similar to go get. Module name is required, but specific version and/or local replacement are optional.

  • --replace is like --with, but does not add a blank import to the code; it only writes a replace directive to go.mod, which is useful when developing on Caddy's dependencies (ones that are not Caddy modules). Try this if you got an error when using --with, like cannot find module providing package.

  • --embed can be used multiple times to embed directories into the built Caddy executable. The directory can be prefixed with a custom alias and a colon : to use it with the root directive and sub-directive.

Examples

$ xcaddy build \
    --with github.com/caddyserver/ntlm-transport

$ xcaddy build v2.0.1 \
    --with github.com/caddyserver/[email protected]

$ xcaddy build master \
    --with github.com/caddyserver/ntlm-transport

$ xcaddy build a58f240d3ecbb59285303746406cab50217f8d24 \
    --with github.com/caddyserver/ntlm-transport

$ xcaddy build \
    --with github.com/caddyserver/ntlm-transport=../../my-fork

$ xcaddy build \
    --with github.com/caddyserver/[email protected]=../../my-fork

You can even replace Caddy core using the --with flag:

$ xcaddy build \
    --with github.com/caddyserver/caddy/v2=../../my-caddy-fork
    
$ xcaddy build \
    --with github.com/caddyserver/caddy/v2=github.com/my-user/caddy/v2@some-branch

This allows you to hack on Caddy core (and optionally plug in extra modules at the same time!) with relative ease.


You may embed directories into the Caddy executable:

$ xcaddy build --embed foo:./sites/foo --embed bar:./sites/bar
$ cat Caddyfile
foo.localhost {
	root * /foo
	file_server {
		fs embedded
	}
}

bar.localhost {
	root * /bar
	file_server {
		fs embedded
	}
}

This allows you to serve 2 sites from 2 different embedded directories, which are referenced by aliases, from a single Caddy executable.


If you need to work on Caddy's dependencies, you can use the --replace flag to replace it with a local copy of that dependency (or your fork on github etc if you need):

$ xcaddy build some-branch-on-caddy \
    --replace golang.org/x/net=../net

For plugin development

If you run xcaddy from within the folder of the Caddy plugin you're working on without the build subcommand, it will build Caddy with your current module and run it, as if you manually plugged it in and invoked go run.

The binary will be built and run from the current directory, then cleaned up.

The current working directory must be inside an initialized Go module.

Syntax:

$ xcaddy <args...>
  • <args...> are passed through to the caddy command.

For example:

$ xcaddy list-modules
$ xcaddy run
$ xcaddy run --config caddy.json

The race detector can be enabled by setting XCADDY_RACE_DETECTOR=1. The DWARF debug info can be enabled by setting XCADDY_DEBUG=1.

Getting xcaddy's version

$ xcaddy version

Library usage

builder := xcaddy.Builder{
	CaddyVersion: "v2.0.0",
	Plugins: []xcaddy.Dependency{
		{
			ModulePath: "github.com/caddyserver/ntlm-transport",
			Version:    "v0.1.1",
		},
	},
}
err := builder.Build(context.Background(), "./caddy")

Versions can be anything compatible with go get.

Environment variables

Because the subcommands and flags are constrained to benefit rapid plugin prototyping, xcaddy does read some environment variables to take cues for its behavior and/or configuration when there is no room for flags.

  • CADDY_VERSION sets the version of Caddy to build.
  • XCADDY_RACE_DETECTOR=1 enables the Go race detector in the build.
  • XCADDY_DEBUG=1 enables the DWARF debug information in the build.
  • XCADDY_SETCAP=1 will run sudo setcap cap_net_bind_service=+ep on the resulting binary. By default, the sudo command will be used if it is found; set XCADDY_SUDO=0 to avoid using sudo if necessary.
  • XCADDY_SKIP_BUILD=1 causes xcaddy to not compile the program, it is used in conjunction with build tools such as GoReleaser. Implies XCADDY_SKIP_CLEANUP=1.
  • XCADDY_SKIP_CLEANUP=1 causes xcaddy to leave build artifacts on disk after exiting.
  • XCADDY_WHICH_GO sets the go command to use when for example more then 1 version of go is installed.
  • XCADDY_GO_BUILD_FLAGS overrides default build arguments. Supports Unix-style shell quoting, for example: XCADDY_GO_BUILD_FLAGS="-ldflags '-w -s'". The provided flags are applied to go commands: build, clean, get, install, list, run, and test
  • XCADDY_GO_MOD_FLAGS overrides default go mod arguments. Supports Unix-style shell quoting.

© 2020 Matthew Holt

xcaddy's People

Contributors

akeskimo avatar amarevite avatar ansrivas avatar caledoniaproject avatar chisaato avatar coolaj86 avatar dependabot[bot] avatar dunglas avatar emilylange avatar francislavoie avatar ggicci avatar jaysonsantos avatar jpughcs avatar kmpm avatar lenovouser avatar mengzhuo avatar mholt avatar mohammed90 avatar neo2308 avatar simnalamburt avatar weidideng avatar wolfogre avatar ydylla avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xcaddy's Issues

xcaddy: command not found when building caddy

Following these indications: https://caddyserver.com/docs/install#build-from-source
in Ubuntu 18.04.4 Desktop I installed xcaddy

go get -u github.com/caddyserver/xcaddy/cmd/xcaddy
go: downloading github.com/caddyserver/xcaddy v0.1.2
go: found github.com/caddyserver/xcaddy/cmd/xcaddy in github.com/caddyserver/xcaddy v0.1.2
go: downloading github.com/Masterminds/semver v1.4.2
go: downloading github.com/Masterminds/semver/v3 v3.1.0
go: github.com/Masterminds/semver/v3 upgrade => v3.1.0

And tried to build caddy:

(base) marco@pc01:~/golangMatters/caddy/cmd/caddy$ xcaddy build v2.0.0-rc.3 \
> --with github.com/caddyserver/nginx-adapter
xcaddy: command not found

How to solve the problem?
Marco

add --version flag on cli for xcaddy itself

so I can easier tell what version of xcaddy I am running can you please add a --version flag. I mean the version of xcaddy not caddy2.

xcaddy --version

Even better if it doesn't impact (i.e. <1000ms) compile time have it always check and report if it needs to update and offer to go get -u right there.

The issue of the url address

Hi, recently I've tried to use xcaddy to compile the caddy with cloudflare dns. However some error occured. I just found that the url probably has something wrong. For example, https://github.com/caddyserver/caddy/blob/master/go.mod where the url in the first line cannot be reached correctly. I am not a guy good at coding, so I not sure if what I said is right, would you please help me to have a look? Thanks.

version after build fails

After building xcaddy attempts to run the new build with version command and fails. There is nothing wrong with permissions of that binary on my system. I I assume fork/exec is some child process starter for Go? Therein lies the permission problem.

/opt/caddy2/amd64 version
2020/05/06 08:23:53 [FATAL] fork/exec /opt/caddy2/amd64: permission denied

BTW my script runs the version command afterwards fine. Is there really any reason that xcaddy needs to do this? My suggestion is to remove it if it's going to be problematic (point of confusion) for some users.

Build fails under go1.16

go version

go version go1.16rc1 linux/amd64

From go1.16 changelog:

Build commands like go build and go test no longer modify go.mod and go.sum by default. Instead, they report an error if a module requirement or checksum needs to be added or updated (as if the -mod=readonly flag were used). Module requirements and sums may be adjusted with go mod tidy or go get.

xcaddy build

2021/02/05 10:29:01 [INFO] Temporary folder: /tmp/buildenv_2021-02-05-1029.946899145
2021/02/05 10:29:01 [INFO] Writing main module: /tmp/buildenv_2021-02-05-1029.946899145/main.go
2021/02/05 10:29:01 [INFO] Initializing Go module
2021/02/05 10:29:01 [INFO] exec (timeout=10s): /usr/bin/go mod init caddy 
go: creating new go.mod: module caddy
go: to add module requirements and sums:
	go mod tidy
2021/02/05 10:29:01 [INFO] Pinning versions
2021/02/05 10:29:01 [INFO] exec (timeout=0s): /usr/bin/go get -d -v github.com/caddyserver/caddy/v2 
go get: added github.com/caddyserver/caddy/v2 v2.3.0
2021/02/05 10:29:02 [INFO] Build environment ready
2021/02/05 10:29:02 [INFO] Building Caddy
2021/02/05 10:29:02 [INFO] exec (timeout=0s): /usr/bin/go build -o /home/dionysius/Документы/Исходники/go/gitlab.com/activecdn/caddy -ldflags -w -s -trimpath 
/home/dionysius/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/templates/tplcontext.go:30:2: missing go.sum entry for module providing package github.com/Masterminds/sprig/v3 (imported by github.com/caddyserver/caddy/v2/modules/caddyhttp/templates); to add:
	go get github.com/caddyserver/caddy/v2/modules/caddyhttp/[email protected]
/home/dionysius/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/templates/tplcontext.go:31:2: missing go.sum entry for module providing package github.com/alecthomas/chroma/formatters/html (imported by github.com/caddyserver/caddy/v2/modules/caddyhttp/templates); to add:
	go get github.com/caddyserver/caddy/v2/modules/caddyhttp/[email protected]
/home/dionysius/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/caddyconfig/httpcaddyfile/serveroptions.go:25:2: missing go.sum entry for module providing package github.com/dustin/go-humanize (imported by github.com/caddyserver/caddy/v2/modules/logging); to add:
	go get github.com/caddyserver/caddy/v2/modules/[email protected]
/home/dionysius/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddypki/acmeserver/acmeserver.go:29:2: missing go.sum entry for module providing package github.com/go-chi/chi (imported by github.com/caddyserver/caddy/v2/modules/caddypki/acmeserver); to add:
	go get github.com/caddyserver/caddy/v2/modules/caddypki/[email protected]
/home/dionysius/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/celmatcher.go:29:2: missing go.sum entry for module providing package github.com/google/cel-go/cel (imported by github.com/caddyserver/caddy/v2/modules/caddyhttp); to add:
	go get github.com/caddyserver/caddy/v2/modules/[email protected]
/home/dionysius/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/celmatcher.go:30:2: missing go.sum entry for module providing package github.com/google/cel-go/checker/decls (imported by github.com/caddyserver/caddy/v2/modules/caddyhttp); to add:
	go get github.com/caddyserver/caddy/v2/modules/[email protected]
/home/dionysius/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/celmatcher.go:31:2: missing go.sum entry for module providing package github.com/google/cel-go/common/types (imported by github.com/caddyserver/caddy/v2/modules/caddyhttp); to add:
	go get github.com/caddyserver/caddy/v2/modules/[email protected]
/home/dionysius/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/celmatcher.go:32:2: missing go.sum entry for module providing package github.com/google/cel-go/common/types/ref (imported by github.com/caddyserver/caddy/v2/modules/caddyhttp); to add:
	go get github.com/caddyserver/caddy/v2/modules/[email protected]
/home/dionysius/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/celmatcher.go:33:2: missing go.sum entry for module providing package github.com/google/cel-go/common/types/traits (imported by github.com/caddyserver/caddy/v2/modules/caddyhttp); to add:
	go get github.com/caddyserver/caddy/v2/modules/[email protected]
/home/dionysius/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/celmatcher.go:34:2: missing go.sum entry for module providing package github.com/google/cel-go/ext (imported by github.com/caddyserver/caddy/v2/modules/caddyhttp); to add:
	go get github.com/caddyserver/caddy/v2/modules/[email protected]
/home/dionysius/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/celmatcher.go:35:2: missing go.sum entry for module providing package github.com/google/cel-go/interpreter/functions (imported by github.com/caddyserver/caddy/v2/modules/caddyhttp); to add:
	go get github.com/caddyserver/caddy/v2/modules/[email protected]
/home/dionysius/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/logging/encoders.go:25:2: missing go.sum entry for module providing package github.com/jsternberg/zap-logfmt (imported by github.com/caddyserver/caddy/v2/modules/logging); to add:
	go get github.com/caddyserver/caddy/v2/modules/[email protected]
/home/dionysius/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/encode/gzip/gzip.go:25:2: missing go.sum entry for module providing package github.com/klauspost/compress/gzip (imported by github.com/caddyserver/caddy/v2/modules/caddyhttp/encode/gzip); to add:
	go get github.com/caddyserver/caddy/v2/modules/caddyhttp/encode/[email protected]
/home/dionysius/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/encode/zstd/zstd.go:21:2: missing go.sum entry for module providing package github.com/klauspost/compress/zstd (imported by github.com/caddyserver/caddy/v2/modules/caddyhttp/encode/zstd); to add:
	go get github.com/caddyserver/caddy/v2/modules/caddyhttp/encode/[email protected]
/home/dionysius/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddytls/values.go:23:2: missing go.sum entry for module providing package github.com/klauspost/cpuid/v2 (imported by github.com/caddyserver/caddy/v2/modules/caddytls); to add:
	go get github.com/caddyserver/caddy/v2/modules/[email protected]
/home/dionysius/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/app.go:28:2: missing go.sum entry for module providing package github.com/lucas-clemente/quic-go/http3 (imported by github.com/caddyserver/caddy/v2/modules/caddyhttp); to add:
	go get github.com/caddyserver/caddy/v2/modules/[email protected]
/home/dionysius/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/templates/frontmatter.go:9:2: missing go.sum entry for module providing package github.com/naoina/toml (imported by github.com/caddyserver/caddy/v2/modules/caddyhttp/templates); to add:
	go get github.com/caddyserver/caddy/v2/modules/caddyhttp/[email protected]
/home/dionysius/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddypki/acmeserver/acmeserver.go:30:2: missing go.sum entry for module providing package github.com/smallstep/certificates/acme (imported by github.com/caddyserver/caddy/v2/modules/caddypki/acmeserver); to add:
	go get github.com/caddyserver/caddy/v2/modules/caddypki/[email protected]
/home/dionysius/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddypki/acmeserver/acmeserver.go:31:2: missing go.sum entry for module providing package github.com/smallstep/certificates/acme/api (imported by github.com/caddyserver/caddy/v2/modules/caddypki/acmeserver); to add:
	go get github.com/caddyserver/caddy/v2/modules/caddypki/[email protected]
/home/dionysius/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddypki/ca.go:28:2: missing go.sum entry for module providing package github.com/smallstep/certificates/authority (imported by github.com/caddyserver/caddy/v2/modules/caddypki); to add:
	go get github.com/caddyserver/caddy/v2/modules/[email protected]
/home/dionysius/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddytls/internalissuer.go:29:2: missing go.sum entry for module providing package github.com/smallstep/certificates/authority/provisioner (imported by github.com/caddyserver/caddy/v2/modules/caddypki/acmeserver); to add:
	go get github.com/caddyserver/caddy/v2/modules/caddypki/[email protected]
/home/dionysius/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddypki/ca.go:29:2: missing go.sum entry for module providing package github.com/smallstep/certificates/db (imported by github.com/caddyserver/caddy/v2/modules/caddypki); to add:
	go get github.com/caddyserver/caddy/v2/modules/[email protected]
/home/dionysius/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddypki/certificates.go:21:2: missing go.sum entry for module providing package github.com/smallstep/cli/crypto/x509util (imported by github.com/caddyserver/caddy/v2/modules/caddypki); to add:
	go get github.com/caddyserver/caddy/v2/modules/[email protected]
/home/dionysius/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddypki/acmeserver/acmeserver.go:35:2: missing go.sum entry for module providing package github.com/smallstep/nosql (imported by github.com/caddyserver/caddy/v2/modules/caddypki/acmeserver); to add:
	go get github.com/caddyserver/caddy/v2/modules/caddypki/[email protected]
/home/dionysius/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddypki/ca.go:30:2: missing go.sum entry for module providing package github.com/smallstep/truststore (imported by github.com/caddyserver/caddy/v2/modules/caddypki); to add:
	go get github.com/caddyserver/caddy/v2/modules/[email protected]
/home/dionysius/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/templates/tplcontext.go:34:2: missing go.sum entry for module providing package github.com/yuin/goldmark (imported by github.com/caddyserver/caddy/v2/modules/caddyhttp/templates); to add:
	go get github.com/caddyserver/caddy/v2/modules/caddyhttp/[email protected]
/home/dionysius/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/templates/tplcontext.go:35:2: missing go.sum entry for module providing package github.com/yuin/goldmark-highlighting (imported by github.com/caddyserver/caddy/v2/modules/caddyhttp/templates); to add:
	go get github.com/caddyserver/caddy/v2/modules/caddyhttp/[email protected]
/home/dionysius/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/templates/tplcontext.go:36:2: missing go.sum entry for module providing package github.com/yuin/goldmark/extension (imported by github.com/caddyserver/caddy/v2/modules/caddyhttp/templates); to add:
	go get github.com/caddyserver/caddy/v2/modules/caddyhttp/[email protected]
/home/dionysius/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/templates/tplcontext.go:37:2: missing go.sum entry for module providing package github.com/yuin/goldmark/parser (imported by github.com/caddyserver/caddy/v2/modules/caddyhttp/templates); to add:
	go get github.com/caddyserver/caddy/v2/modules/caddyhttp/[email protected]
/home/dionysius/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/templates/tplcontext.go:38:2: missing go.sum entry for module providing package github.com/yuin/goldmark/renderer/html (imported by github.com/caddyserver/caddy/v2/modules/caddyhttp/templates); to add:
	go get github.com/caddyserver/caddy/v2/modules/caddyhttp/[email protected]
/home/dionysius/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/celmatcher.go:36:2: missing go.sum entry for module providing package google.golang.org/genproto/googleapis/api/expr/v1alpha1 (imported by github.com/caddyserver/caddy/v2/modules/caddyhttp); to add:
	go get github.com/caddyserver/caddy/v2/modules/[email protected]
/home/dionysius/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/logging/filewriter.go:28:2: missing go.sum entry for module providing package gopkg.in/natefinch/lumberjack.v2 (imported by github.com/caddyserver/caddy/v2/modules/logging); to add:
	go get github.com/caddyserver/caddy/v2/modules/[email protected]
/home/dionysius/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/templates/frontmatter.go:10:2: missing go.sum entry for module providing package gopkg.in/yaml.v2 (imported by github.com/caddyserver/caddy/v2/modules/caddyhttp/templates); to add:
	go get github.com/caddyserver/caddy/v2/modules/caddyhttp/[email protected]
2021/02/05 10:29:02 [INFO] Cleaning up temporary folder: /tmp/buildenv_2021-02-05-1029.946899145
2021/02/05 10:29:02 [FATAL] exit status 1

-bash: xcaddy: command not found

Hi,

I hope this is not a terrible question, I did try my best to solve the problem, but it just doesn't work.

I first installed go 1.14.2 following this page: Getting Started. I did remember to add /usr/local/go/bin to $PATH. Everything was fine and this test succeeded.

Then I set $GO111MODULE to on. And I ran go get -u github.com/caddyserver/xcaddy/cmd/xcaddy as instructed. I tried to run this command almost everywhere: my home directory, I cloned caddy and run this command. But whatever I do, there is no such command called xcaddy.

[ERROR] exec [go list -m -json all]

Hi,

When I run

xcaddy alpine --with github.com/caddy-dns/duckdns

the build fails and I got the following error:

go list -m: not using modules
[ERROR] exec [go list -m -json all]: exit status 1:

go version go1.17.3 linux/arm64

can't build caddy, variable mismatch

Using go 1.15, manually installed to /usr/local/go I get:

/home/user/go/pkg/mod/github.com/smallstep/[email protected]/authority/provisioner/jwk.go:155:24: assignment mismatch: 3 variables but x509util.SplitSANs returns 4 values  
 
/home/user/go/pkg/mod/github.com/smallstep/[email protected]/authority/provisioner/x5c.go:197:24: assignment mismatch: 3 variables but x509util.SplitSANs returns 4 values                                          

2020/08/31 13:23:25 [INFO] Cleaning up temporary folder: /tmp/buildenv_2020-08-31-1323.298003067                              

2020/08/31 13:23:25 [FATAL] exit status 2

/home/user/go/pkg/mod/github.com/smallstep/[email protected]/authority/provisioner/jwk.go:155:24: assignment mismatch: 3 variables but x509util.SplitSANs returns 4 values                                         

 /home/user/go/pkg/mod/github.com/smallstep/[email protected]/authority/provisioner/x5c.go:197:24: assignment mismatch: 3 variables but x509util.SplitSANs returns 4 values                                          

2020/08/31 13:23:25 [INFO] Cleaning up temporary folder: /tmp/buildenv_2020-08-31-1323.298003067                              

2020/08/31 13:23:25 [FATAL] exit status 2

The cmd was xcaddy build --with github.com/caddy-dns/cloudflare

Allow building a debug version of the output

Since xcaddy build command passed -ldflag "-w -s" flags to go build command by default, which turns off DWARF debug information. The output can't be utlized in a debug tool.

It will be helpful if we were given a chance to remove these flags.

For my use case, I'm developing a Caddy module. And I'm using xcaddy to build the test release. I really hope I can build a debug version of caddy with my module under development. So that I can debug it in VSCode.

feature: handling replace clauses in plugins passed with --with

@mholt , by design the replace directives are not being considered.

For example the replace go.mod:

module github.com/greenpau/caddy-git

go 1.16

require (
        github.com/caddyserver/caddy/v2 v2.4.6
        github.com/go-git/go-git/v5 v5.4.2
        github.com/google/go-cmp v0.5.6
        go.uber.org/zap v1.20.0
)

replace github.com/go-git/go-git/v5 v5.4.2 => /home/greenpau/dev/go/src/github.com/go-git/go-git

The replace in plugin's go.mod will not be accounted for when compiling in xcaddy.

What do you think about parsing go.mod files in the plugin's passed with --with for the presence of replace clauses and adding them to the build?

xcaddy build: fatal error: runtime: out of memory

Following this guide, I'm attempting to install caddy on ubuntu server 18.04.

The build fails with fatal error: runtime: out of memory

This is the build output when running xcaddy build.

2021/03/11 10:21:30 [INFO] Temporary folder: /tmp/buildenv_2021-03-11-1021.749880544
2021/03/11 10:21:30 [INFO] Writing main module: /tmp/buildenv_2021-03-11-1021.749880544/main.go
2021/03/11 10:21:30 [INFO] Initializing Go module
2021/03/11 10:21:30 [INFO] exec (timeout=10s): /usr/local/go/bin/go mod init caddy
go: creating new go.mod: module caddy
go: to add module requirements and sums:
        go mod tidy
2021/03/11 10:21:30 [INFO] Pinning versions
2021/03/11 10:21:30 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -d -v github.com/caddyserver/caddy/v2
go get: added github.com/caddyserver/caddy/v2 v2.3.0
2021/03/11 10:21:36 [INFO] Build environment ready
2021/03/11 10:21:36 [INFO] Building Caddy
2021/03/11 10:21:36 [INFO] exec (timeout=0s): /usr/local/go/bin/go mod tidy
2021/03/11 10:21:39 [INFO] exec (timeout=0s): /usr/local/go/bin/go build -o /home/test_user/caddy/caddy -ldflags -w -s -trimpath
# github.com/yuin/goldmark/util
fatal error: runtime: out of memory

runtime stack:
runtime.throw(0xcac687, 0x16)
        /usr/local/go/src/runtime/panic.go:1117 +0x72
runtime.sysMap(0xc010000000, 0x4000000, 0x11e7b90)
        /usr/local/go/src/runtime/mem_linux.go:169 +0xc6
runtime.(*mheap).sysAlloc(0x11c8bc0, 0x400000, 0x42bcf7, 0x11c8bc8)
        /usr/local/go/src/runtime/malloc.go:729 +0x1e5
runtime.(*mheap).grow(0x11c8bc0, 0x20, 0x0)
        /usr/local/go/src/runtime/mheap.go:1346 +0x85
runtime.(*mheap).allocSpan(0x11c8bc0, 0x20, 0x460000, 0x7fcaf6837928)
        /usr/local/go/src/runtime/mheap.go:1173 +0x609
runtime.(*mheap).alloc.func1()
        /usr/local/go/src/runtime/mheap.go:910 +0x59
runtime.systemstack(0x46d334)
        /usr/local/go/src/runtime/asm_amd64.s:379 +0x66
runtime.mstart()
        /usr/local/go/src/runtime/proc.go:1246

goroutine 1 [running]:
runtime.systemstack_switch()
        /usr/local/go/src/runtime/asm_amd64.s:339 fp=0xc00aa33468 sp=0xc00aa33460 pc=0x46d460
runtime.(*mheap).alloc(0x11c8bc0, 0x20, 0x200100, 0x203003)
        /usr/local/go/src/runtime/mheap.go:904 +0x85 fp=0xc00aa334b8 sp=0xc00aa33468 pc=0x4279a5
runtime.(*mcache).allocLarge(0x7fcb1d9fd108, 0x3e590, 0x30001, 0xc8e5e0)
        /usr/local/go/src/runtime/mcache.go:224 +0x97 fp=0xc00aa33510 sp=0xc00aa334b8 pc=0x418017
runtime.mallocgc(0x3e590, 0xc8e5e0, 0xcc8b01, 0x1)
        /usr/local/go/src/runtime/malloc.go:1078 +0x925 fp=0xc00aa33598 sp=0xc00aa33510 pc=0x40de65
runtime.makeslice(0xc8e5e0, 0x7cb2, 0x7cb2, 0xc0051070e8)
        /usr/local/go/src/runtime/slice.go:98 +0x6c fp=0xc00aa335c8 sp=0xc00aa33598 pc=0x44faec
cmd/compile/internal/ssa.fuseBlockPlain(0xc005106dc0, 0xc0029c0d00)
        /usr/local/go/src/cmd/compile/internal/ssa/fuse.go:209 +0x4bf fp=0xc00aa33668 sp=0xc00aa335c8 pc=0x688ebf
cmd/compile/internal/ssa.fuse(0xc0018ce2c0, 0x118469aa82505)
        /usr/local/go/src/cmd/compile/internal/ssa/fuse.go:40 +0xb3 fp=0xc00aa336a0 sp=0xc00aa33668 pc=0x6880f3
cmd/compile/internal/ssa.fuseEarly(0xc0018ce2c0)
        /usr/local/go/src/cmd/compile/internal/ssa/fuse.go:12 +0x30 fp=0xc00aa336c0 sp=0xc00aa336a0 pc=0x687fb0
cmd/compile/internal/ssa.Compile(0xc0018ce2c0)
        /usr/local/go/src/cmd/compile/internal/ssa/compile.go:96 +0x98d fp=0xc00aa37388 sp=0xc00aa336c0 pc=0x66086d
cmd/compile/internal/gc.buildssa(0xc000f358c0, 0x0, 0x0)
        /usr/local/go/src/cmd/compile/internal/gc/ssa.go:470 +0x11ba fp=0xc00aa375b0 sp=0xc00aa37388 pc=0xb0bc5a
cmd/compile/internal/gc.compileSSA(0xc000f358c0, 0x0)
        /usr/local/go/src/cmd/compile/internal/gc/pgen.go:319 +0x5d fp=0xc00aa37690 sp=0xc00aa375b0 pc=0xad733d
cmd/compile/internal/gc.compile(0xc000f358c0)
        /usr/local/go/src/cmd/compile/internal/gc/pgen.go:277 +0x39e fp=0xc00aa37708 sp=0xc00aa37690 pc=0xad711e
cmd/compile/internal/gc.funccompile(0xc000f358c0)
        /usr/local/go/src/cmd/compile/internal/gc/pgen.go:220 +0xc5 fp=0xc00aa37760 sp=0xc00aa37708 pc=0xad6c65
cmd/compile/internal/gc.Main(0xcc7d28)
        /usr/local/go/src/cmd/compile/internal/gc/main.go:762 +0x3525 fp=0xc00aa37f10 sp=0xc00aa37760 pc=0xaabbe5
main.main()
        /usr/local/go/src/cmd/compile/main.go:52 +0xb1 fp=0xc00aa37f88 sp=0xc00aa37f10 pc=0xbf90d1
runtime.main()
        /usr/local/go/src/runtime/proc.go:225 +0x256 fp=0xc00aa37fe0 sp=0xc00aa37f88 pc=0x439d76
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1371 +0x1 fp=0xc00aa37fe8 sp=0xc00aa37fe0 pc=0x46f161
2021/03/11 10:21:46 [INFO] Cleaning up temporary folder: /tmp/buildenv_2021-03-11-1021.749880544
2021/03/11 10:21:46 [FATAL] exit status 2

xcaddy mentions a version of a module that doesn't exist?

UPDATE: Resolved. I don't know the cause of the version bumping behaviour but assume it's unrelated to Caddy and to do with Go get functionality.

I was able to get a successful build of the module by overriding problematic dependencies versions with newer ones or referencing git commits (not mentioned on xcaddy README as possible). That should probably be added to the README for troubleshooting :)


Recently the Souin Caddy plugin was updated and was meant to fix a verifying module: checksum mismatch error, but when I attempted to build that module again (without a version in --with) I got the same build failure.

No new tagged release was made on the project, I tried building the older tagged commit, but it failed as expected.

It's not documented in this projects README, but prior issues have mentioned referencing a specific commit instead, so I tried that:

ARG CADDY_VERSION=2.4.3
FROM caddy:${CADDY_VERSION}-builder AS builder
ARG SOUIN_VERSION=@ed8b9e9fd2d4

RUN xcaddy build \
    --with github.com/darkweak/souin/plugins/caddy${SOUIN_VERSION}

FROM caddy:${CADDY_VERSION}-alpine

COPY --from=builder /usr/bin/caddy /usr/bin/caddy

This fails with the same error and checksum mismatch values, presumably because the plugins go.mod continues to reference the darkweak/[email protected] dependency that triggered the mismatch errors experienced?

go get: added github.com/caddyserver/caddy/v2 v2.4.3                                                                                                                                                                        
2021/08/17 23:40:45 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -d -v github.com/darkweak/souin/plugins/caddy@ed8b9e9fd2d46fd1db317b72ccc1fdaa811abf03                                                               
go: downloading github.com/darkweak/souin/plugins/caddy v0.0.0-20210817165413-ed8b9e9fd2d4                                                                                                                                  
go: downloading github.com/darkweak/souin v1.5.3-0.20210817165413-ed8b9e9fd2d4                                                                                                                                              
go: downloading github.com/darkweak/souin v1.5.2                                                                                                                                                                            
github.com/darkweak/souin/plugins/caddy: github.com/darkweak/[email protected]: verifying module: checksum mismatch                                                                                                              
    downloaded: h1:7Hm4N7WS7GDk4KANPg3LGk0m2AGfIrIX1DHkytWVATw=
    sum.golang.org: h1:WS/Q+qq7c+dIIw/abYYtWMpfj1ucjhfvaabW5Q+K6tc=

SECURITY ERROR                                                                                                                                                                                                              
This download does NOT match the one reported by the checksum server.                                                                                                                                                       
The bits may have been replaced on the origin server, or an attacker may                                                                                                                                                    
have intercepted the download attempt. 

The odd Caddy versioning I have seen and I assume is related to this reason (and nothing to do with xcaddy but how Go get works?), but why is the souin package mentioned twice, once with the non-existent (atm) v1.5.3-* tag, then the existing v1.5.2 tag (specified in the go.mod):

go: downloading github.com/darkweak/souin/plugins/caddy v0.0.0-20210817165413-ed8b9e9fd2d4                                                                                                                                  
go: downloading github.com/darkweak/souin v1.5.3-0.20210817165413-ed8b9e9fd2d4      

Is this something Go get is doing "bumping" a fake version because I provided a git commit hash after the commit of the latest tagged release? It then overrides that with the pinned version in go.mod causing the mismatch?

Or is this an issue on the maintainers end that they can fix? (related issue on their repo)

can't build linux arm

get this error when trying to build for arm64 or armv7
/usr/local/go/src/vendor/golang.org/x/crypto/poly1305/sum_noasm.go:10:7: undefined: newMAC

2020/10/25 17:59:15 [INFO] Temporary folder: /tmp/buildenv_2020-10-25-1759.651426086
2020/10/25 17:59:15 [INFO] Writing main module: /tmp/buildenv_2020-10-25-1759.651426086/main.go
2020/10/25 17:59:15 [INFO] Initializing Go module
2020/10/25 17:59:15 [INFO] exec (timeout=10s): /usr/local/go/bin/go mod init caddy

go: creating new go.mod: module caddy
2020/10/25 17:59:15 [INFO] Pinning versions
2020/10/25 17:59:15 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -d -v github.com/caddyserver/caddy/v2
go: github.com/caddyserver/caddy/v2 upgrade => v2.2.1
2020/10/25 17:59:17 [INFO] Build environment ready
2020/10/25 17:59:17 [INFO] Building Caddy
2020/10/25 17:59:17 [INFO] exec (timeout=0s): /usr/local/go/bin/go build -o /opt/caddy/build/bin/linux-arm64 -ldflags -w -s -trimpath
# vendor/golang.org/x/crypto/poly1305
/usr/local/go/src/vendor/golang.org/x/crypto/poly1305/sum_noasm.go:10:7: undefined: newMAC
2020/10/25 17:59:19 [INFO] Cleaning up temporary folder: /tmp/buildenv_2020-10-25-1759.651426086
2020/10/25 17:59:19 [FATAL] exit status 2

using
GOOS=linux GOARCH=arm64 /opt/caddy/build/bin/xcaddy build --output /opt/caddy/build/bin/linux-arm64

GOOS=linux GOARCH=arm GOARM=7 /opt/caddy/build/bin/xcaddy build --output /opt/caddy/build/bin/linux-arm-7

no problem buiding for linux amd64

using very latest xcaddy, latest golang on amd64 machine

am I missing some cross compile tool chain??

cannot build module with cloudflare

go version go1.15 linux/amd64

# github.com/smallstep/certificates/authority/provisioner
/root/go/pkg/mod/github.com/smallstep/[email protected]/authority/provisioner/jwk.go:155:24: assignment mismatch: 3 variables but x509util.SplitSANs returns 4 values
/root/go/pkg/mod/github.com/smallstep/[email protected]/authority/provisioner/x5c.go:197:24: assignment mismatch: 3 variables but x509util.SplitSANs returns 4 values
2020/08/16 09:18:03 [INFO] Cleaning up temporary folder: /tmp/buildenv_2020-08-16-0917.888096838
2020/08/16 09:18:03 [FATAL] exit status 2

xcaddy build --with module=$(pwd) fails if 'go.mod' includes 'replace' directive

Hi,

module <mod>

// Required Go version
go 1.16

replace (
        github.com/qri-io/jsonschema => github.com/qri-io/jsonschema v0.2.2-0.20210831022256-780655b2ba0e
        <my_mod> => <mod_on_gitlab_private_repo>.git <ver>
)

require (
        github.com/caddyserver/caddy/v2 v2.4.5
        go.uber.org/zap v1.19.0
        <my_mod> <ver>
)

I am trying to build caddy with builtin own customized plugin with:

xcaddy build --with mod=$(pwd)

but command returns:

(...)
get "golang.org/x/term": found meta tag vcs.metaImport{Prefix:"golang.org/x/term", VCS:"git", RepoRoot:"https://go.googlesource.com/term"} at //golang.org/x/term?go-get=1
get "google.golang.org/protobuf": found meta tag vcs.metaImport{Prefix:"google.golang.org/protobuf", VCS:"git", RepoRoot:"https://go.googlesource.com/protobuf"} at //google.golang.org/protobuf?go-get=1
go get: added github.com/caddyserver/caddy/v2 v2.4.5
2021/10/21 10:35:48 [INFO] Build environment ready
2021/10/21 10:35:48 [INFO] Building Caddy
2021/10/21 10:35:48 [INFO] exec (timeout=0s): /usr/bin/go mod tidy
go: found a in a v0.0.0-00010101000000-000000000000
go: [email protected] requires
        <my_mod>@<ver>: unrecognized import path "<my_mod>": parse <my_mod>?go-get=1: no go-import meta tags ()
2021/10/21 10:35:49 [INFO] Cleaning up temporary folder: /tmp/buildenv_2021-10-21-1035.826449881
2021/10/21 10:35:49 [FATAL] exit status 1

However when I am developing, simply issuing command:

xcaddy run --config Caddyfile

works perfectly. My plugin is loaded and everything is up and running.

Thanks

Next steps and production aspirations

Hello!

Great tool! Extending caddy has tremendous value for my use case.

I'm discovering caddy and xcaddy so I'm having a hard time picturing how much work is left to make it ready? Are you looking for contributors? How risky would it be for me to use it in production now?

Many thanks for your great work on this!

Is it supposed to build and install caddy?

buntu@s1-4-bhs5:~$ xcaddy build \
> --with github.com/dunglas/mercure/caddy
2021/03/04 09:36:54 [INFO] Temporary folder: /tmp/buildenv_2021-03-04-0936.961939135
2021/03/04 09:36:54 [INFO] Writing main module: /tmp/buildenv_2021-03-04-0936.961939135/main.go
2021/03/04 09:36:54 [INFO] Initializing Go module
2021/03/04 09:36:54 [INFO] exec (timeout=10s): /usr/local/go/bin/go mod init caddy 
go: creating new go.mod: module caddy
go: to add module requirements and sums:
        go mod tidy
2021/03/04 09:36:54 [INFO] Pinning versions
2021/03/04 09:36:54 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -d -v github.com/caddyserver/caddy/v2 
go get: added github.com/caddyserver/caddy/v2 v2.3.0
2021/03/04 09:36:58 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -d -v github.com/dunglas/mercure/caddy 
go get: added github.com/dunglas/mercure/caddy v0.0.0-20210301202656-c5ccf9423bf5
2021/03/04 09:37:05 [INFO] Build environment ready
2021/03/04 09:37:05 [INFO] Building Caddy
2021/03/04 09:37:05 [INFO] exec (timeout=0s): /usr/local/go/bin/go mod tidy 
2021/03/04 09:37:05 [INFO] exec (timeout=0s): /usr/local/go/bin/go build -o /home/ubuntu/caddy -ldflags -w -s -trimpath 
2021/03/04 09:37:07 [INFO] Build complete: ./caddy
2021/03/04 09:37:07 [INFO] Cleaning up temporary folder: /tmp/buildenv_2021-03-04-0936.961939135
ubuntu@s1-4-bhs5:~$ which caddy
ubuntu@s1-4-bhs5:~$ whereis caddy
caddy:
ubuntu@s1-4-bhs5:~$ which xcaddy
/home/ubuntu/go_lang_builds/bin/xcaddy
ubuntu@s1-4-bhs5:~$ whereis xcaddy
xcaddy: /home/ubuntu/go_lang_builds/bin/xcaddy

ubuntu@s1-4-bhs5:~$ caddy vesrions
caddy: command not found


No caddy. What for this tool if you have to download binary manually anyway?

auto upgrade caddy version

I try to build caddy 2.3.0 but xcaddy auto upgraded to v2.4.0-beta.1

xcaddy build v2.3.0
--with github.com/RussellLuo/caddy-ext/ratelimit
--with github.com/abiosoft/caddy-hmac
--with github.com/caddy-dns/cloudflare
--with github.com/caddyserver/jsonc-adapter
--with github.com/casbin/caddy-authz/v2
--with github.com/greenpau/caddy-auth-jwt
--with github.com/greenpau/caddy-auth-portal
--with github.com/kirsch33/realip
--with github.com/sjtug/caddy2-filter
2021/03/30 13:16:16 [INFO] Temporary folder: /tmp/buildenv_2021-03-30-1316.375702467
2021/03/30 13:16:16 [INFO] Writing main module: /tmp/buildenv_2021-03-30-1316.375702467/main.go
2021/03/30 13:16:16 [INFO] Initializing Go module
2021/03/30 13:16:16 [INFO] exec (timeout=10s): /usr/local/bin/go mod init caddy
go: creating new go.mod: module caddy
go: to add module requirements and sums:
go mod tidy
2021/03/30 13:16:16 [INFO] Pinning versions
2021/03/30 13:16:16 [INFO] exec (timeout=0s): /usr/local/bin/go get -d -v github.com/caddyserver/caddy/[email protected]
go get: added github.com/caddyserver/caddy/v2 v2.3.0
2021/03/30 13:16:20 [INFO] exec (timeout=0s): /usr/local/bin/go get -d -v github.com/RussellLuo/caddy-ext/ratelimit
go get: added github.com/RussellLuo/caddy-ext/ratelimit v0.0.0-20210216051744-6266d94e5ad9
2021/03/30 13:16:24 [INFO] exec (timeout=0s): /usr/local/bin/go get -d -v github.com/abiosoft/caddy-hmac
go get: added github.com/abiosoft/caddy-hmac v0.0.0-20200528051232-71b2c4bbf374
2021/03/30 13:16:25 [INFO] exec (timeout=0s): /usr/local/bin/go get -d -v github.com/caddy-dns/cloudflare
go get: added github.com/caddy-dns/cloudflare v0.0.0-20210312233109-9d3a8971aaa8
go get: upgraded github.com/caddyserver/caddy/v2 v2.3.0 => v2.4.0-beta.1
2021/03/30 13:16:26 [INFO] exec (timeout=0s): /usr/local/bin/go get -d -v github.com/caddyserver/jsonc-adapter
go get: added github.com/caddyserver/jsonc-adapter v0.0.0-20200325004025-825ee096306c
2021/03/30 13:16:27 [INFO] exec (timeout=0s): /usr/local/bin/go get -d -v github.com/casbin/caddy-authz/v2
go get: added github.com/casbin/caddy-authz/v2 v2.0.0
2021/03/30 13:16:29 [INFO] exec (timeout=0s): /usr/local/bin/go get -d -v github.com/greenpau/caddy-auth-jwt
go get: added github.com/greenpau/caddy-auth-jwt v1.2.7
2021/03/30 13:16:30 [INFO] exec (timeout=0s): /usr/local/bin/go get -d -v github.com/greenpau/caddy-auth-portal
go get: added github.com/greenpau/caddy-auth-portal v1.4.6
2021/03/30 13:16:32 [INFO] exec (timeout=0s): /usr/local/bin/go get -d -v github.com/kirsch33/realip
go get: added github.com/kirsch33/realip v1.5.2
2021/03/30 13:16:33 [INFO] exec (timeout=0s): /usr/local/bin/go get -d -v github.com/sjtug/caddy2-filter
go get: added github.com/sjtug/caddy2-filter v0.0.0-20210315003910-95ab1651d436
2021/03/30 13:16:34 [INFO] Build environment ready
2021/03/30 13:16:34 [INFO] Building Caddy
2021/03/30 13:16:34 [INFO] exec (timeout=0s): /usr/local/bin/go mod tidy
go: finding module for package github.com/go-redis/redis
go: found github.com/go-redis/redis in github.com/go-redis/redis v6.15.9+incompatible
2021/03/30 13:16:35 [INFO] exec (timeout=0s): /usr/local/bin/go build -o /root/go/bin/caddy -ldflags -w -s -trimpath
2021/03/30 13:16:38 [INFO] Build complete: ./caddy
2021/03/30 13:16:38 [INFO] Cleaning up temporary folder: /tmp/buildenv_2021-03-30-1316.375702467

Can't use after installing - flag provided but not defined: -m

Hi,

I installed xcaddy in Ubuntu 18.04:
maya@ubuntu-server:~$ sudo apt install xcaddy password for maya: package lists... Done dependency tree `` Reading state information... Done xcaddy is already the newest version (0.1.9). The following package was automatically installed and is no longer required: libnginx-mod-http-geoip Use 'sudo apt autoremove' to remove it. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
I have Go installed:
maya@ubuntu-server:~$ go version go version go1.10.4 linux/amd64
And I have Caddy installed:
maya@ubuntu-server:~$ caddy version v2.4.1 h1:kAJ0JB5Xk5gPdTH/27S5cyoMGqD5lBAe9yZ8zTjVJa0=
But every command I try results in the following error:
maya@ubuntu-server:~$ xcaddy list-modules flag provided but not defined: -m usage: list [-e] [-f format] [-json] [build flags] [packages] Run 'go help list' for details. 2021/06/03 06:44:04 [ERROR] exec [go list -m]: exit status 2:

Please help,
Thanks!

How to build caddy from a different branch/repository?

How can we build caddy from a different branch/repository?

We can specify a CADDY_VERSION environment variable, but the module path seems to be hardcoded at:

Is there a way to override that module path? or somehow override go get to fetch that module from somewhere else?

404

can't find
github.com/caddyserver/caddy/v2

image

xcaddy build fails

sorry if this is the wrong place to post, but been trying to build with xcaddy for a few days with no luck

build always fails with this error

root@ooju:~# xcaddy build --with github.com/caddy-dns/cloudflare
2022/03/09 18:46:24 [INFO] Temporary folder: /tmp/buildenv_2022-03-09-1846.3291500057
2022/03/09 18:46:24 [INFO] Writing main module: /tmp/buildenv_2022-03-09-1846.3291500057/main.go
2022/03/09 18:46:24 [INFO] Initializing Go module
2022/03/09 18:46:24 [INFO] exec (timeout=10s): /usr/local/go/bin/go mod init caddy 
go: creating new go.mod: module caddy
2022/03/09 18:46:24 [INFO] Pinning versions
2022/03/09 18:46:24 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -d -v github.com/caddyserver/caddy/v2 
2022/03/09 18:46:25 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -d -v github.com/caddy-dns/cloudflare 
go: finding github.com/caddy-dns/cloudflare latest
2022/03/09 18:46:27 [INFO] Build environment ready
2022/03/09 18:46:27 [INFO] Building Caddy
2022/03/09 18:46:27 [INFO] exec (timeout=0s): /usr/local/go/bin/go mod tidy 
2022/03/09 18:46:28 [INFO] exec (timeout=0s): /usr/local/go/bin/go build -o /root/caddy -ldflags -w -s -trimpath 
flag provided but not defined: -trimpath
usage: go build [-o output] [-i] [build flags] [packages]
Run 'go help build' for details.
2022/03/09 18:46:28 [INFO] Cleaning up temporary folder: /tmp/buildenv_2022-03-09-1846.3291500057
2022/03/09 18:46:28 [FATAL] exit status 2

Add option to disable version check after build

Readme indicates that GOOS, GOARCH, and GOARM can be set, probably for cross-compilation scenarios.

But at the end of the build, there is a check that tries to execute the build output: https://github.com/caddyserver/xcaddy/blob/master/cmd/xcaddy/main.go#L131

Which might be incompatible with current architecture when doing cross-compilation.
For example, I'm on Linux building Caddy for Windows, or I'm on amd64 building for ARM.

I would like to suggest either removing the check, or having a parameter to disable it.

Build Caddy statically without CGO

Hello,

When trying to build Caddy statically (with CGO_ENABLED=0 and without gcc), using:

docker run -it --rm -w /tmp/caddy golang:1.14-alpine3.11
apk add git
export CGO_ENABLED=0
export GO111MODULE=on
go get github.com/caddyserver/xcaddy/cmd/xcaddy@master
xcaddy build v2.0.0

I obtain the errors:

2020/05/22 13:55:03 [INFO] Temporary folder: /tmp/buildenv_2020-05-22-1355.280615980
2020/05/22 13:55:03 [INFO] Writing main module: /tmp/buildenv_2020-05-22-1355.280615980/main.go
2020/05/22 13:55:03 [INFO] Initializing Go module
2020/05/22 13:55:03 [INFO] exec (timeout=10s): /usr/local/go/bin/go mod init caddy
go: creating new go.mod: module caddy
2020/05/22 13:55:03 [INFO] Pinning versions
2020/05/22 13:55:03 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -d -v github.com/caddyserver/caddy/[email protected] 
2020/05/22 13:55:04 [INFO] Build environment ready
2020/05/22 13:55:04 [INFO] Building Caddy
2020/05/22 13:55:04 [INFO] exec (timeout=0s): /usr/local/go/bin/go build -o /tmp/caddy/caddy -ldflags -w -s -trimpath 
# runtime/cgo
exec: "gcc": executable file not found in $PATH
2020/05/22 13:55:04 [INFO] Cleaning up temporary folder: /tmp/buildenv_2020-05-22-1355.280615980
2020/05/22 13:55:04 [FATAL] exit status 2

Any idea how I can solve that? Or is this related to xcaddy? Or one of the dependencies?

Thanks!

Github module paths should be case insensitive

I copy/pasted the Github URL which isn't always lowercase. There is no mention of this limitation on the README, is it intentional and stated elsewhere?

go get: added github.com/caddyserver/caddy/v2 v2.4.3
2021/08/13 11:22:07 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -d -v github.com/Darkweak/Souin/plugins/caddy
go: downloading github.com/Darkweak/Souin/plugins/caddy v0.0.0-20210811115113-01e06b75a576
go get: github.com/Darkweak/Souin/plugins/caddy@none updating to
        github.com/Darkweak/Souin/plugins/[email protected]: parsing go.mod:
        module declares its path as: github.com/darkweak/souin/plugins/caddy
                but was required as: github.com/Darkweak/Souin/plugins/caddy

xcaddy plugin build fails with caddy version greater than v2.4.3

I have a private caddy plugin, which works fine with caddy version v2.4.3 & below. I can build the binary with this version

xcaddy build v2.4.3  --output reverse-proxy --with github.com/sharadregoti/sharad-reverse-proxy=.
2021/09/28 13:05:08 [INFO] Resolved relative replacement github.com/sharadregoti/sharad-reverse-proxy=. to /home/sharad/unotech/microservices/sharad-reverse-proxy
2021/09/28 13:05:08 [INFO] Temporary folder: /tmp/buildenv_2021-09-28-1305.848602894
2021/09/28 13:05:08 [INFO] Writing main module: /tmp/buildenv_2021-09-28-1305.848602894/main.go
2021/09/28 13:05:08 [INFO] Initializing Go module
2021/09/28 13:05:08 [INFO] exec (timeout=10s): /usr/local/go/bin/go mod init caddy
go: creating new go.mod: module caddy
go: to add module requirements and sums:
        go mod tidy
2021/09/28 13:05:08 [INFO] Replace github.com/sharadregoti/sharad-reverse-proxy => /home/sharad/unotech/microservices/sharad-reverse-proxy
2021/09/28 13:05:08 [INFO] exec (timeout=10s): /usr/local/go/bin/go mod edit -replace github.com/sharadregoti/sharad-reverse-proxy=/home/sharad/unotech/microservices/sharad-reverse-proxy
2021/09/28 13:05:08 [INFO] Pinning versions
2021/09/28 13:05:08 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -d -v github.com/caddyserver/caddy/[email protected]
go get: added github.com/beorn7/perks v1.0.1
go get: added github.com/caddyserver/caddy/v2 v2.4.3
go get: added github.com/caddyserver/certmagic v0.14.0
go get: added github.com/cespare/xxhash/v2 v2.1.1
go get: added github.com/golang/protobuf v1.5.2
go get: added github.com/google/uuid v1.2.0
go get: added github.com/klauspost/cpuid/v2 v2.0.6
go get: added github.com/libdns/libdns v0.2.1
go get: added github.com/matttproud/golang_protobuf_extensions v1.0.1
go get: added github.com/mholt/acmez v0.1.3
go get: added github.com/miekg/dns v1.1.42
go get: added github.com/prometheus/client_golang v1.10.1-0.20210603120351-253906201bda
go get: added github.com/prometheus/client_model v0.2.0
go get: added github.com/prometheus/common v0.26.0
go get: added github.com/prometheus/procfs v0.6.0
go get: added go.uber.org/atomic v1.7.0
go get: added go.uber.org/multierr v1.6.0
go get: added go.uber.org/zap v1.17.0
go get: added golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a
go get: added golang.org/x/net v0.0.0-20210525063256-abc453219eb5
go get: added golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40
go get: added golang.org/x/term v0.0.0-20210503060354-a79de5458b56
go get: added golang.org/x/text v0.3.6
go get: added google.golang.org/protobuf v1.26.0
2021/09/28 13:05:10 [INFO] Build environment ready
2021/09/28 13:05:10 [INFO] Building Caddy
2021/09/28 13:05:10 [INFO] exec (timeout=0s): /usr/local/go/bin/go mod tidy
go: found github.com/sharadregoti/sharad-reverse-proxy in github.com/sharadregoti/sharad-reverse-proxy v0.0.0-00010101000000-000000000000
2021/09/28 13:05:10 [INFO] exec (timeout=0s): /usr/local/go/bin/go build -o /home/sharad/unotech/microservices/sharad-reverse-proxy/reverse-proxy -ldflags -w -s -trimpath
2021/09/28 13:05:12 [INFO] Build complete: reverse-proxy
2021/09/28 13:05:12 [INFO] Cleaning up temporary folder: /tmp/buildenv_2021-09-28-1305.848602894

But when I try to build the plugin with caddy version v2.4.4, i get the below error

xcaddy build v2.4.4  --output reverse-proxy --with github.com/sharadregoti/sharad-reverse-proxy=.
2021/09/28 13:07:46 [INFO] Resolved relative replacement github.com/sharadregoti/sharad-reverse-proxy=. to /home/sharad/unotech/microservices/sharad-reverse-proxy
2021/09/28 13:07:46 [INFO] Temporary folder: /tmp/buildenv_2021-09-28-1307.736279814
2021/09/28 13:07:46 [INFO] Writing main module: /tmp/buildenv_2021-09-28-1307.736279814/main.go
2021/09/28 13:07:46 [INFO] Initializing Go module
2021/09/28 13:07:46 [INFO] exec (timeout=10s): /usr/local/go/bin/go mod init caddy
go: creating new go.mod: module caddy
go: to add module requirements and sums:
        go mod tidy
2021/09/28 13:07:46 [INFO] Replace github.com/sharadregoti/sharad-reverse-proxy => /home/sharad/unotech/microservices/sharad-reverse-proxy
2021/09/28 13:07:46 [INFO] exec (timeout=10s): /usr/local/go/bin/go mod edit -replace github.com/sharadregoti/sharad-reverse-proxy=/home/sharad/unotech/microservices/sharad-reverse-proxy
2021/09/28 13:07:46 [INFO] Pinning versions
2021/09/28 13:07:47 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -d -v github.com/caddyserver/caddy/[email protected]
go get: added github.com/beorn7/perks v1.0.1
go get: added github.com/caddyserver/caddy/v2 v2.4.4
go get: added github.com/caddyserver/certmagic v0.14.4
go get: added github.com/cespare/xxhash/v2 v2.1.1
go get: added github.com/golang/protobuf v1.5.2
go get: added github.com/google/uuid v1.3.0
go get: added github.com/klauspost/cpuid/v2 v2.0.9
go get: added github.com/libdns/libdns v0.2.1
go get: added github.com/matttproud/golang_protobuf_extensions v1.0.1
go get: added github.com/mholt/acmez v1.0.0
go get: added github.com/miekg/dns v1.1.42
go get: added github.com/prometheus/client_golang v1.11.0
go get: added github.com/prometheus/client_model v0.2.0
go get: added github.com/prometheus/common v0.26.0
go get: added github.com/prometheus/procfs v0.6.0
go get: added go.uber.org/atomic v1.7.0
go get: added go.uber.org/multierr v1.6.0
go get: added go.uber.org/zap v1.19.0
go get: added golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e
go get: added golang.org/x/net v0.0.0-20210614182718-04defd469f4e
go get: added golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c
go get: added golang.org/x/term v0.0.0-20210503060354-a79de5458b56
go get: added golang.org/x/text v0.3.6
go get: added google.golang.org/protobuf v1.27.1
2021/09/28 13:07:48 [INFO] Build environment ready
2021/09/28 13:07:48 [INFO] Building Caddy
2021/09/28 13:07:48 [INFO] exec (timeout=0s): /usr/local/go/bin/go mod tidy
go: found github.com/sharadregoti/sharad-reverse-proxy in github.com/sharadregoti/sharad-reverse-proxy v0.0.0-00010101000000-000000000000
go: finding module for package go.opentelemetry.io/otel/label
caddy imports
        github.com/sharadregoti/sharad-reverse-proxy imports
        github.com/sharadregoti/sharad-reverse-proxy/modules imports
        github.com/sharadregoti/sharad-reverse-proxy/modules/admin imports
        github.com/sharadregoti/sharad-reverse-proxy/managers/store imports
        github.com/go-redis/redis/v8 imports
        go.opentelemetry.io/otel/label: module go.opentelemetry.io/otel@latest found (v1.0.0), but does not contain package go.opentelemetry.io/otel/label
2021/09/28 13:07:53 [INFO] Cleaning up temporary folder: /tmp/buildenv_2021-09-28-1307.736279814
2021/09/28 13:07:53 [FATAL] exit status 1

Same with caddy version 2.4.5

`xcaddy build` fails with runtime error

I saw you changed the interface, so I tried updating the Homebrew formula to the new builder version. Unfortunately the build fails now:

$ go run cmd/xcaddy/main.go build v2.0.0-beta.20 --output /usr/local/Cellar/caddy/2.0.0-beta.20/bin/caddy
go: downloading github.com/Masterminds/semver/v3 v3.0.3
panic: runtime error: index out of range [3] with length 3

goroutine 1 [running]:
main.runBuild(0xc0000100c0, 0x3, 0x3, 0xc000016178, 0x0)
	/private/tmp/caddy--caddy-builder-20200326-4177-6b8ole/builder-1cc8e08c16745777e12ac5d7d0cd44535b0bb35e/cmd/xcaddy/main.go:72 +0x7ff
main.main()
	/private/tmp/caddy--caddy-builder-20200326-4177-6b8ole/builder-1cc8e08c16745777e12ac5d7d0cd44535b0bb35e/cmd/xcaddy/main.go:32 +0x13e
exit status 2

Do you know why?

Go errors when updating Caddy to latest version: [FATAL] exit status 1

Hi, tried to update Caddy 2 a few times recently and every time it fails. Here's the log and the command I use to update:

2021/09/28 02:16:35 [INFO] Temporary folder: /tmp/buildenv_2021-09-28-0216.045682969
2021/09/28 02:16:35 [INFO] Writing main module: /tmp/buildenv_2021-09-28-0216.045682969/main.go
2021/09/28 02:16:35 [INFO] Initializing Go module
2021/09/28 02:16:35 [INFO] exec (timeout=10s): /usr/local/go/bin/go mod init caddy
go: creating new go.mod: module caddy
go: to add module requirements and sums:
        go mod tidy
2021/09/28 02:16:35 [INFO] Pinning versions
2021/09/28 02:16:35 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -d -v github.com/caddyserver/caddy/v2
go get: added github.com/beorn7/perks v1.0.1
go get: added github.com/caddyserver/caddy/v2 v2.4.5
go get: added github.com/caddyserver/certmagic v0.14.5
go get: added github.com/cespare/xxhash/v2 v2.1.1
go get: added github.com/golang/protobuf v1.5.2
go get: added github.com/google/uuid v1.3.0
go get: added github.com/klauspost/cpuid/v2 v2.0.9
go get: added github.com/libdns/libdns v0.2.1
go get: added github.com/matttproud/golang_protobuf_extensions v1.0.1
go get: added github.com/mholt/acmez v1.0.0
go get: added github.com/miekg/dns v1.1.42
go get: added github.com/prometheus/client_golang v1.11.0
go get: added github.com/prometheus/client_model v0.2.0
go get: added github.com/prometheus/common v0.26.0
go get: added github.com/prometheus/procfs v0.6.0
go get: added go.uber.org/atomic v1.7.0
go get: added go.uber.org/multierr v1.6.0
go get: added go.uber.org/zap v1.19.0
go get: added golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e
go get: added golang.org/x/net v0.0.0-20210614182718-04defd469f4e
go get: added golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c
go get: added golang.org/x/term v0.0.0-20210503060354-a79de5458b56
go get: added golang.org/x/text v0.3.6
go get: added google.golang.org/protobuf v1.27.1
2021/09/28 02:16:36 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -d -v github.com/caddy-dns/cloudflare
go get: added github.com/caddy-dns/cloudflare v0.0.0-20210607183747-91cf700356a1
go get: added github.com/libdns/cloudflare v0.1.0
2021/09/28 02:16:37 [INFO] Build environment ready
2021/09/28 02:16:37 [INFO] Building Caddy
2021/09/28 02:16:37 [INFO] exec (timeout=0s): /usr/local/go/bin/go build -o /root/caddy -ldflags -w -s -trimpath
/root/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/templates/tplcontext.go:30:2: missing go.sum entry for module providing package github.com/Masterminds/sprig/v3 (imported by github.com/caddyserver/caddy/v2/modules/caddyhttp/templates); to add:
        go get github.com/caddyserver/caddy/v2/modules/caddyhttp/[email protected]
/root/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/templates/tplcontext.go:31:2: missing go.sum entry for module providing package github.com/alecthomas/chroma/formatters/html (imported by github.com/caddyserver/caddy/v2/modules/caddyhttp/templates); to add:
        go get github.com/caddyserver/caddy/v2/modules/caddyhttp/[email protected]
/root/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/caddyconfig/httpcaddyfile/serveroptions.go:25:2: missing go.sum entry for module providing package github.com/dustin/go-humanize (imported by github.com/caddyserver/caddy/v2/modules/logging); to add:
        go get github.com/caddyserver/caddy/v2/modules/[email protected]
/root/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddypki/acmeserver/acmeserver.go:29:2: missing go.sum entry for module providing package github.com/go-chi/chi (imported by github.com/caddyserver/caddy/v2/modules/caddypki/acmeserver); to add:
        go get github.com/caddyserver/caddy/v2/modules/caddypki/[email protected]
/root/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/celmatcher.go:29:2: missing go.sum entry for module providing package github.com/google/cel-go/cel (imported by github.com/caddyserver/caddy/v2/modules/caddyhttp); to add:
        go get github.com/caddyserver/caddy/v2/modules/[email protected]
/root/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/celmatcher.go:30:2: missing go.sum entry for module providing package github.com/google/cel-go/checker/decls (imported by github.com/caddyserver/caddy/v2/modules/caddyhttp); to add:
        go get github.com/caddyserver/caddy/v2/modules/[email protected]
/root/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/celmatcher.go:31:2: missing go.sum entry for module providing package github.com/google/cel-go/common/types (imported by github.com/caddyserver/caddy/v2/modules/caddyhttp); to add:
        go get github.com/caddyserver/caddy/v2/modules/[email protected]
/root/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/celmatcher.go:32:2: missing go.sum entry for module providing package github.com/google/cel-go/common/types/ref (imported by github.com/caddyserver/caddy/v2/modules/caddyhttp); to add:
        go get github.com/caddyserver/caddy/v2/modules/[email protected]
/root/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/celmatcher.go:33:2: missing go.sum entry for module providing package github.com/google/cel-go/common/types/traits (imported by github.com/caddyserver/caddy/v2/modules/caddyhttp); to add:
        go get github.com/caddyserver/caddy/v2/modules/[email protected]
/root/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/celmatcher.go:34:2: missing go.sum entry for module providing package github.com/google/cel-go/ext (imported by github.com/caddyserver/caddy/v2/modules/caddyhttp); to add:
        go get github.com/caddyserver/caddy/v2/modules/[email protected]
/root/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/celmatcher.go:35:2: missing go.sum entry for module providing package github.com/google/cel-go/interpreter/functions (imported by github.com/caddyserver/caddy/v2/modules/caddyhttp); to add:
        go get github.com/caddyserver/caddy/v2/modules/[email protected]
/root/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/encode/gzip/gzip.go:24:2: missing go.sum entry for module providing package github.com/klauspost/compress/gzip (imported by github.com/caddyserver/caddy/v2/modules/caddyhttp/encode/gzip); to add:
        go get github.com/caddyserver/caddy/v2/modules/caddyhttp/encode/[email protected]
/root/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/encode/zstd/zstd.go:21:2: missing go.sum entry for module providing package github.com/klauspost/compress/zstd (imported by github.com/caddyserver/caddy/v2/modules/caddyhttp/encode/zstd); to add:
        go get github.com/caddyserver/caddy/v2/modules/caddyhttp/encode/[email protected]
/root/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/app.go:28:2: missing go.sum entry for module providing package github.com/lucas-clemente/quic-go/http3 (imported by github.com/caddyserver/caddy/v2/modules/caddyhttp); to add:
        go get github.com/caddyserver/caddy/v2/modules/[email protected]
/root/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/templates/frontmatter.go:9:2: missing go.sum entry for module providing package github.com/naoina/toml (imported by github.com/caddyserver/caddy/v2/modules/caddyhttp/templates); to add:
        go get github.com/caddyserver/caddy/v2/modules/caddyhttp/[email protected]
/root/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddypki/acmeserver/acmeserver.go:30:2: missing go.sum entry for module providing package github.com/smallstep/certificates/acme (imported by github.com/caddyserver/caddy/v2/modules/caddypki/acmeserver); to add:
        go get github.com/caddyserver/caddy/v2/modules/caddypki/[email protected]
/root/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddypki/acmeserver/acmeserver.go:31:2: missing go.sum entry for module providing package github.com/smallstep/certificates/acme/api (imported by github.com/caddyserver/caddy/v2/modules/caddypki/acmeserver); to add:
        go get github.com/caddyserver/caddy/v2/modules/caddypki/[email protected]
/root/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddypki/acmeserver/acmeserver.go:32:2: missing go.sum entry for module providing package github.com/smallstep/certificates/acme/db/nosql (imported by github.com/caddyserver/caddy/v2/modules/caddypki/acmeserver); to add:
        go get github.com/caddyserver/caddy/v2/modules/caddypki/[email protected]
/root/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddypki/ca.go:28:2: missing go.sum entry for module providing package github.com/smallstep/certificates/authority (imported by github.com/caddyserver/caddy/v2/modules/caddypki); to add:
        go get github.com/caddyserver/caddy/v2/modules/[email protected]
/root/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddytls/internalissuer.go:29:2: missing go.sum entry for module providing package github.com/smallstep/certificates/authority/provisioner (imported by github.com/caddyserver/caddy/v2/modules/caddypki/acmeserver); to add:
        go get github.com/caddyserver/caddy/v2/modules/caddypki/[email protected]
/root/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddypki/ca.go:29:2: missing go.sum entry for module providing package github.com/smallstep/certificates/db (imported by github.com/caddyserver/caddy/v2/modules/caddypki); to add:
        go get github.com/caddyserver/caddy/v2/modules/[email protected]
/root/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddypki/certificates.go:21:2: missing go.sum entry for module providing package github.com/smallstep/cli/crypto/x509util (imported by github.com/caddyserver/caddy/v2/modules/caddypki); to add:
        go get github.com/caddyserver/caddy/v2/modules/[email protected]
/root/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddypki/acmeserver/acmeserver.go:36:2: missing go.sum entry for module providing package github.com/smallstep/nosql (imported by github.com/caddyserver/caddy/v2/modules/caddypki/acmeserver); to add:
        go get github.com/caddyserver/caddy/v2/modules/caddypki/[email protected]
/root/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddypki/ca.go:30:2: missing go.sum entry for module providing package github.com/smallstep/truststore (imported by github.com/caddyserver/caddy/v2/modules/caddypki); to add:
        go get github.com/caddyserver/caddy/v2/modules/[email protected]
/root/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/templates/tplcontext.go:34:2: missing go.sum entry for module providing package github.com/yuin/goldmark (imported by github.com/caddyserver/caddy/v2/modules/caddyhttp/templates); to add:
        go get github.com/caddyserver/caddy/v2/modules/caddyhttp/[email protected]
/root/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/templates/tplcontext.go:35:2: missing go.sum entry for module providing package github.com/yuin/goldmark-highlighting (imported by github.com/caddyserver/caddy/v2/modules/caddyhttp/templates); to add:
        go get github.com/caddyserver/caddy/v2/modules/caddyhttp/[email protected]
/root/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/templates/tplcontext.go:36:2: missing go.sum entry for module providing package github.com/yuin/goldmark/extension (imported by github.com/caddyserver/caddy/v2/modules/caddyhttp/templates); to add:
        go get github.com/caddyserver/caddy/v2/modules/caddyhttp/[email protected]
/root/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/templates/tplcontext.go:37:2: missing go.sum entry for module providing package github.com/yuin/goldmark/parser (imported by github.com/caddyserver/caddy/v2/modules/caddyhttp/templates); to add:
        go get github.com/caddyserver/caddy/v2/modules/caddyhttp/[email protected]
/root/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/templates/tplcontext.go:38:2: missing go.sum entry for module providing package github.com/yuin/goldmark/renderer/html (imported by github.com/caddyserver/caddy/v2/modules/caddyhttp/templates); to add:
        go get github.com/caddyserver/caddy/v2/modules/caddyhttp/[email protected]
/root/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/celmatcher.go:36:2: missing go.sum entry for module providing package google.golang.org/genproto/googleapis/api/expr/v1alpha1 (imported by github.com/caddyserver/caddy/v2/modules/caddyhttp); to add:
        go get github.com/caddyserver/caddy/v2/modules/[email protected]
/root/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/logging/filewriter.go:28:2: missing go.sum entry for module providing package gopkg.in/natefinch/lumberjack.v2 (imported by github.com/caddyserver/caddy/v2/modules/logging); to add:
        go get github.com/caddyserver/caddy/v2/modules/[email protected]
/root/go/pkg/mod/github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/templates/frontmatter.go:10:2: missing go.sum entry for module providing package gopkg.in/yaml.v2 (imported by github.com/caddyserver/caddy/v2/modules/caddyhttp/templates); to add:
        go get github.com/caddyserver/caddy/v2/modules/caddyhttp/[email protected]
2021/09/28 02:16:37 [INFO] Cleaning up temporary folder: /tmp/buildenv_2021-09-28-0216.045682969
2021/09/28 02:16:37 [FATAL] exit status 1

Xcaddy build fails with cloudflare plugin

I have tried to use xcaddy to build wiht the cloudflare plugin using the following command:

xcaddy build --with github.com/caddy-dns/cloudflare latest
2020/08/10 07:22:46 [INFO] Temporary folder: /tmp/buildenv_2020-08-10-0722.666572298
2020/08/10 07:22:46 [INFO] Writing main module: /tmp/buildenv_2020-08-10-0722.666572298/main.go
2020/08/10 07:22:46 [INFO] Initializing Go module
2020/08/10 07:22:46 [INFO] exec (timeout=10s): /usr/local/go/bin/go mod init caddy 
go: creating new go.mod: module caddy
2020/08/10 07:22:46 [INFO] Pinning versions
2020/08/10 07:22:46 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -d -v github.com/caddyserver/caddy/v2@latest 
go: github.com/caddyserver/caddy/v2 latest => v2.1.1
2020/08/10 07:22:47 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -d -v github.com/caddy-dns/cloudflare 
go: github.com/caddy-dns/cloudflare upgrade => v0.0.0-20200807233547-c4ab2c801158
2020/08/10 07:22:47 [INFO] Build environment ready
2020/08/10 07:22:47 [INFO] Building Caddy
2020/08/10 07:22:47 [INFO] exec (timeout=0s): /usr/local/go/bin/go build -o /go/bin/caddy -ldflags -w -s -trimpath 
# github.com/smallstep/certificates/authority/provisioner
/go/pkg/mod/github.com/smallstep/[email protected]/authority/provisioner/jwk.go:155:24: assignment mismatch: 3 variables but x509util.SplitSANs returns 4 values
/go/pkg/mod/github.com/smallstep/[email protected]/authority/provisioner/x5c.go:197:24: assignment mismatch: 3 variables but x509util.SplitSANs returns 4 values
2020/08/10 07:22:48 [INFO] Cleaning up temporary folder: /tmp/buildenv_2020-08-10-0722.666572298
2020/08/10 07:22:48 [FATAL] exit status 2

xcaddy development mode fails if 'go.mod' includes 'replace' directive

How to reproduce this issue:

Clone https://github.com/simnalamburt/xcaddybug and try to build with xcaddy.

// main.go
package xcaddybug
import "example.com/stringutil"
import "github.com/caddyserver/caddy/v2"

func init() {
	caddy.RegisterModule(Example{})
}
type Example struct {}
func (Example) CaddyModule() caddy.ModuleInfo {
	return caddy.ModuleInfo{
		ID:  caddy.ModuleID(stringutil.Reverse("elpmaxe.oof")),
		New: func() caddy.Module { return new(Example) },
	}
}
// go.mod
module github.com/simnalamburt/xcaddybug
go 1.17
replace example.com v0.0.1 => golang.org/x/example v0.0.0-20210811190340-787a929d5a0d
require (
	example.com v0.0.1
	github.com/caddyserver/caddy/v2 v2.4.3
)

Error message:

2021/08/29 22:55:01 [INFO] Resolved relative replacement example.com=>golang.org/x/example v0.0.0-20210811190340-787a929d5a0d to /home/simnalamburt/workspace/xcaddybug/golang.org/x/example v0.0.0-20210811190340-787a929d5a0d
2021/08/29 22:55:01 [INFO] Temporary folder: /tmp/buildenv_2021-08-29-2255.2607006221
2021/08/29 22:55:01 [INFO] Writing main module: /tmp/buildenv_2021-08-29-2255.2607006221/main.go
2021/08/29 22:55:01 [INFO] Initializing Go module
2021/08/29 22:55:01 [INFO] exec (timeout=10s): /usr/sbin/go mod init caddy
go: creating new go.mod: module caddy
go: to add module requirements and sums:
        go mod tidy
2021/08/29 22:55:01 [INFO] Replace github.com/simnalamburt/xcaddybug => /home/simnalamburt/workspace/xcaddybug
2021/08/29 22:55:01 [INFO] exec (timeout=10s): /usr/sbin/go mod edit -replace github.com/simnalamburt/xcaddybug=/home/simnalamburt/workspace/xcaddybug
2021/08/29 22:55:01 [INFO] Replace example.com => /home/simnalamburt/workspace/xcaddybug/golang.org/x/example v0.0.0-20210811190340-787a929d5a0d
2021/08/29 22:55:01 [INFO] exec (timeout=10s): /usr/sbin/go mod edit -replace example.com=/home/simnalamburt/workspace/xcaddybug/golang.org/x/[email protected]
2021/08/29 22:55:01 [INFO] Pinning versions
2021/08/29 22:55:01 [INFO] exec (timeout=0s): /usr/sbin/go get -d -v github.com/caddyserver/caddy/v2
go: errors parsing go.mod:
/tmp/buildenv_2021-08-29-2255.2607006221/go.mod:7: replacement module directory path "/home/simnalamburt/workspace/xcaddybug/golang.org/x/example" cannot have version
2021/08/29 22:55:01 [ERROR] exit status 1

References

Can't do module replacement with github forks

So I want to have a replacement like:

replace github.com/mholt/caddy-dynamicdns => github.com/francislavoie/caddy-dynamicdns caddyfile

So I try this:

xcaddy build --with github.com/mholt/caddy-dynamicdns=github.com/francislavoie/caddy-dynamicdns@caddyfile

But it does this:

...
2021/02/21 07:25:03 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -d -v github.com/mholt/caddy-dynamicdns=github.com/francislavoie/caddy-dynamicdns@caddyfile
go get github.com/mholt/caddy-dynamicdns=github.com/francislavoie/caddy-dynamicdns@caddyfile: malformed module path "github.com/mholt/caddy-dynamicdns=github.com/francislavoie/caddy-dynamicdns": invalid char '='

This obviously isn't quite right, cause it never did the go mod edit -replace.

Next I tried without @caddyfile (my branch), and I get this:

2021/02/21 07:29:24 [INFO] Resolved relative replacement github.com/mholt/caddy-dynamicdns=github.com/francislavoie/caddy-dynamicdns to /root/github.com/francislavoie/caddy-dynamicdns
...
2021/02/21 07:29:24 [INFO] Replace github.com/mholt/caddy-dynamicdns => /root/github.com/francislavoie/caddy-dynamicdns
2021/02/21 07:29:24 [INFO] exec (timeout=10s): /usr/local/go/bin/go mod edit -replace github.com/mholt/caddy-dynamicdns=/root/github.com/francislavoie/caddy-dynamicdns
...
caddy imports
        github.com/mholt/caddy-dynamicdns: github.com/mholt/[email protected]: replacement directory /root/github.com/francislavoie/caddy-dynamicdns does not exist

So xcaddy thinks that path is relative but it's not, it's a git repo.

I think to detect if it's relative, we should look if there's a . in front, so if you want to refer to something in the current dir then you do ./blah in the replacement. That should allow github module paths to work.

The workaround obviously for now is to git clone the relevant repo then use a relative path on that, but it would be nice so that people can easily test branches/PRs for plugins without cloning.

Am I doing it wrong? - [FATAL] exit status 2 - xcaddy build v2.4.6 --with github.com/caddy-dns/cloudflare

I am sorry for pasting just a log here, but I cannot catch for anything meaningful (to not bother you).

  • I installed go 17.3 and latest xcaddy.

xcaddy version - v0.2.0 h1:PLtoEQ5LjjYQNyHEnFM+rWP9HYfxQejlYkBKE0M9vso=
ubuntu 20.0.4 aarch64 - up to date.
go 1.17.3

The moment I try to build it with

xcaddy build v2.4.6 --with github.com/caddy-dns/cloudflare@latest

I get fatal.

ubuntu@ip-172-31-17-201:~/go/bin$ sudo tar -C /usr/local -xzf go1.17.3.linux-arm64.tar.gz
ubuntu@ip-172-31-17-201:~/go/bin$ xcaddy build v2.4.6 --with github.com/caddy-dns/cloudflare@latest
2021/12/03 10:50:12 [INFO] Temporary folder: /tmp/buildenv_2021-12-03-1050.1397751167
2021/12/03 10:50:12 [INFO] Writing main module: /tmp/buildenv_2021-12-03-1050.1397751167/main.go
2021/12/03 10:50:12 [INFO] Initializing Go module
2021/12/03 10:50:12 [INFO] exec (timeout=10s): /usr/local/go/bin/go mod init caddy 
go: creating new go.mod: module caddy
go: to add module requirements and sums:
	go mod tidy
2021/12/03 10:50:12 [INFO] Pinning versions
2021/12/03 10:50:12 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -d -v github.com/caddyserver/caddy/[email protected] 
go get: added github.com/beorn7/perks v1.0.1
go get: added github.com/caddyserver/caddy/v2 v2.4.6
go get: added github.com/caddyserver/certmagic v0.15.2
go get: added github.com/cespare/xxhash/v2 v2.1.1
go get: added github.com/golang/protobuf v1.5.2
go get: added github.com/google/uuid v1.3.0
go get: added github.com/klauspost/cpuid/v2 v2.0.9
go get: added github.com/libdns/libdns v0.2.1
go get: added github.com/matttproud/golang_protobuf_extensions v1.0.1
go get: added github.com/mholt/acmez v1.0.1
go get: added github.com/miekg/dns v1.1.43
go get: added github.com/prometheus/client_golang v1.11.0
go get: added github.com/prometheus/client_model v0.2.0
go get: added github.com/prometheus/common v0.26.0
go get: added github.com/prometheus/procfs v0.6.0
go get: added go.uber.org/atomic v1.7.0
go get: added go.uber.org/multierr v1.6.0
go get: added go.uber.org/zap v1.19.0
go get: added golang.org/x/crypto v0.0.0-20210915214749-c084706c2272
go get: added golang.org/x/net v0.0.0-20210913180222-943fd674d43e
go get: added golang.org/x/sys v0.0.0-20210915083310-ed5796bab164
go get: added golang.org/x/term v0.0.0-20210503060354-a79de5458b56
go get: added golang.org/x/text v0.3.7
go get: added google.golang.org/protobuf v1.27.1
2021/12/03 10:50:14 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -d -v github.com/caddy-dns/cloudflare@latest 
go get: added github.com/caddy-dns/cloudflare v0.0.0-20210607183747-91cf700356a1
go get: added github.com/libdns/cloudflare v0.1.0
2021/12/03 10:50:14 [INFO] Build environment ready
2021/12/03 10:50:14 [INFO] Building Caddy
2021/12/03 10:50:14 [INFO] exec (timeout=0s): /usr/local/go/bin/go mod tidy 
2021/12/03 10:50:15 [INFO] exec (timeout=0s): /usr/local/go/bin/go build -o /home/ubuntu/go/bin/caddy -ldflags -w -s -trimpath 
# runtime/internal/sys
/usr/local/go/src/runtime/internal/sys/stubs.go:9:7: PtrSize redeclared in this block
	/usr/local/go/src/runtime/internal/sys/arch.go:24:38: previous declaration
/usr/local/go/src/runtime/internal/sys/stubs.go:10:24: undefined: Uintreg
/usr/local/go/src/runtime/internal/sys/stubs.go:16:7: StackGuardMultiplier redeclared in this block
	/usr/local/go/src/runtime/internal/sys/arch.go:27:74: previous declaration
2021/12/03 10:50:15 [INFO] Cleaning up temporary folder: /tmp/buildenv_2021-12-03-1050.1397751167
2021/12/03 10:50:15 [FATAL] exit status 2

Caddy v2.2.3 h1:xxMaF/Nb3B5VhXkQREvjGUdfDgseMmc5IyhUktYO7gM= is already installed on the same machine. Could that be an issue?

malformed module path

Having a heck of a time trying to get Cloudflare DNS authentication installed.

root@host:~# xcaddy build --with "https://github.com/caddy-dns/cloudflare"
2020/07/04 21:40:38 [INFO] Temporary folder: /tmp/buildenv_2020-07-04-2140.394588638
2020/07/04 21:40:38 [INFO] Writing main module: /tmp/buildenv_2020-07-04-2140.394588638/main.go
2020/07/04 21:40:38 [INFO] Initializing Go module
2020/07/04 21:40:38 [INFO] exec (timeout=10s): /usr/local/go/bin/go mod init caddy
go: creating new go.mod: module caddy
2020/07/04 21:40:38 [INFO] Pinning versions
2020/07/04 21:40:38 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -d -v github.com/caddyserver/caddy/v2
go: github.com/caddyserver/caddy/v2 upgrade => v2.1.1
2020/07/04 21:40:39 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -d -v https://github.com/caddy-dns/cloudflare
go get https:/github.com/caddy-dns/cloudflare: malformed module path "https:/github.com/caddy-dns/cloudflare": invalid char ':'
2020/07/04 21:40:39 [FATAL] exit status 1

You'll notice there's a / missing in https:/github.com/caddy-dns/cloudflare in the last line. I inspected the module and there are no malformed paths as far as I could tell.

Can't build basic main.go from upstream

This one comes from.... https://github.com/caddyserver/caddy/blob/master/cmd/caddy/main.go:

❯ cat main.go
package main

import (
	caddycmd "github.com/caddyserver/caddy/v2/cmd"

	// plug in Caddy modules here
	_ "github.com/caddyserver/caddy/v2/modules/standard"
)

func main() {
	caddycmd.Main()
}
❯ xcaddy build
2020/05/07 10:23:39 [INFO] Temporary folder: /tmp/buildenv_2020-05-07-1023.089339309
2020/05/07 10:23:39 [INFO] Writing main module: /tmp/buildenv_2020-05-07-1023.089339309/main.go
2020/05/07 10:23:39 [INFO] Initializing Go module
2020/05/07 10:23:39 [INFO] exec (timeout=10s): /usr/bin/go mod init caddy 
go: creating new go.mod: module caddy
2020/05/07 10:23:39 [INFO] Pinning versions
2020/05/07 10:23:39 [INFO] exec (timeout=5m0s): /usr/bin/go get -d -v github.com/caddyserver/caddy/v2 
2020/05/07 10:23:40 [INFO] Build environment ready
2020/05/07 10:23:40 [INFO] Building Caddy
2020/05/07 10:23:40 [INFO] exec (timeout=5m0s): /usr/bin/go build -o /home/fzipi/go/src/github.com/fzipi/caddy-modsec/caddy -ldflags -w -s -trimpath 
# github.com/caddyserver/certmagic
/home/fzipi/go/pkg/mod/github.com/caddyserver/[email protected]/handshake.go:201:18: hello.SupportsCertificate undefined (type *tls.ClientHelloInfo has no field or method SupportsCertificate)
2020/05/07 10:23:42 [INFO] Cleaning up temporary folder: /tmp/buildenv_2020-05-07-1023.089339309
2020/05/07 10:23:42 [FATAL] exit status 2

I reckon this is surely from upstream.

Add --help flag

I was reading how to compile a new local caddy module into a caddy docker image: https://hub.docker.com/_/caddy?tab=description. The examples on that page don't mention the local syntax as described in this repo's README. My first thought was to docker run caddy:2-builder xcaddy --help or docker run caddy:2-builder xcaddy help to learn the syntax. However those commands yield:

go list -m: not using modules
2020/11/15 18:29:25 [ERROR] exec [go list -m]: exit status 1:

It would be useful to have a help flag or subcommand to also show the helpful incantations as described in the README.

xcaddy build v2.3.0 --with Unable to obtain the specified version

Adding the --with component will invalidate the specified version. Can you help solve this problem?

1. Instruction one

[root@centos-s-2vcpu-4gb-sfo3-03 caddy]# xcaddy build v2.3.0 \

--with github.com/caddyserver/forwardproxy \
--with github.com/caddy-dns/cloudflare

2021/04/21 09:53:24 [INFO] Temporary folder: /tmp/buildenv_2021-04-21-0953.136560700
2021/04/21 09:53:24 [INFO] Writing main module: /tmp/buildenv_2021-04-21-0953.136560700/main.go
2021/04/21 09:53:24 [INFO] Initializing Go module
2021/04/21 09:53:24 [INFO] exec (timeout=10s): /usr/bin/go mod init caddy
go: creating new go.mod: module caddy
2021/04/21 09:53:24 [INFO] Pinning versions
2021/04/21 09:53:24 [INFO] exec (timeout=0s): /usr/bin/go get -d -v github.com/caddyserver/caddy/[email protected]
2021/04/21 09:53:25 [INFO] exec (timeout=0s): /usr/bin/go get -d -v github.com/caddyserver/forwardproxy
go: github.com/caddyserver/forwardproxy upgrade => v0.0.0-20201205091008-b3a96fb34dbe
2021/04/21 09:53:26 [INFO] exec (timeout=0s): /usr/bin/go get -d -v github.com/caddy-dns/cloudflare
go: github.com/caddy-dns/cloudflare upgrade => v0.0.0-20210401224357-964e47d3890e
2021/04/21 09:53:26 [INFO] Build environment ready
2021/04/21 09:53:26 [INFO] Building Caddy
2021/04/21 09:53:26 [INFO] exec (timeout=0s): /usr/bin/go mod tidy
2021/04/21 09:53:27 [INFO] exec (timeout=0s): /usr/bin/go build -o /etc/caddy/caddy -ldflags -w -s -trimpath
2021/04/21 09:53:30 [INFO] Build complete: ./caddy
2021/04/21 09:53:30 [INFO] Cleaning up temporary folder: /tmp/buildenv_2021-04-21-0953.136560700
[root@centos-s-2vcpu-4gb-sfo3-03 caddy]# ./caddy version
v2.4.0-beta.2 h1:DUaK4qtL3T0/gAm0fVVkHgcMN04r4zGpfPUZWHRR8QU=

2. 1. Instruction two
[root@centos-s-2vcpu-4gb-sfo3-03 caddy]# xcaddy build v2.3.0
2021/04/21 09:54:21 [INFO] Temporary folder: /tmp/buildenv_2021-04-21-0954.549121710
2021/04/21 09:54:21 [INFO] Writing main module: /tmp/buildenv_2021-04-21-0954.549121710/main.go
2021/04/21 09:54:21 [INFO] Initializing Go module
2021/04/21 09:54:21 [INFO] exec (timeout=10s): /usr/bin/go mod init caddy
go: creating new go.mod: module caddy
2021/04/21 09:54:21 [INFO] Pinning versions
2021/04/21 09:54:21 [INFO] exec (timeout=0s): /usr/bin/go get -d -v github.com/caddyserver/caddy/[email protected]
2021/04/21 09:54:22 [INFO] Build environment ready
2021/04/21 09:54:22 [INFO] Building Caddy
2021/04/21 09:54:22 [INFO] exec (timeout=0s): /usr/bin/go mod tidy
2021/04/21 09:54:23 [INFO] exec (timeout=0s): /usr/bin/go build -o /etc/caddy/caddy -ldflags -w -s -trimpath
2021/04/21 09:54:26 [INFO] Build complete: ./caddy
2021/04/21 09:54:26 [INFO] Cleaning up temporary folder: /tmp/buildenv_2021-04-21-0954.549121710
[root@centos-s-2vcpu-4gb-sfo3-03 caddy]# ./caddy version
v2.3.0 h1:fnrqJLa3G5vfxcxmOH/+kJOcunPLhSBnjgIvjXV/QTA=

How to set timeouts?

Hi there,

First of all many thanks for this tool, it's really useful!

I have a little problem when running it however on a slow machine (Github actions actually) where the context exceeds the timeout. Is there a way to set the timeout? It seems to come from this context.

Thank you in advance.

plugin is not listed

I was trying to make a caddy plugin from the tutorial mentioned in the docs [https://caddyserver.com/docs/extending-caddy].
Weirdly xcaddy list-modules does not detect my plugin
This is the plugin

package caddyjwt

import "github.com/caddyserver/caddy/v2"

func init() {
	caddy.RegisterModule(Gizmo{})
}

// Gizmo is an example; put your own type here.
type Gizmo struct {
}

// CaddyModule returns the Caddy module information.
func (Gizmo) CaddyModule() caddy.ModuleInfo {
	return caddy.ModuleInfo{
		ID:  "zoo.gizmo",
		New: func() caddy.Module { return new(Gizmo) },
	}
}

The log on stdout

2020/10/19 21:27:18 [INFO] Temporary folder: /tmp/buildenv_2020-10-19-2127.273871167
2020/10/19 21:27:18 [INFO] Writing main module: /tmp/buildenv_2020-10-19-2127.273871167/main.go
2020/10/19 21:27:18 [INFO] Initializing Go module
2020/10/19 21:27:18 [INFO] exec (timeout=10s): /usr/local/go/bin/go mod init caddy 
go: creating new go.mod: module caddy
2020/10/19 21:27:18 [INFO] Replace caddyjwt => /home/rohan/go/src/caddyjwt
2020/10/19 21:27:18 [INFO] exec (timeout=10s): /usr/local/go/bin/go mod edit -replace caddyjwt=/home/rohan/go/src/caddyjwt 
2020/10/19 21:27:18 [INFO] Pinning versions
2020/10/19 21:27:18 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -d -v github.com/caddyserver/caddy/v2 
go: github.com/caddyserver/caddy/v2 upgrade => v2.2.1
2020/10/19 21:27:19 [INFO] Build environment ready
2020/10/19 21:27:19 [INFO] Building Caddy
2020/10/19 21:27:19 [INFO] exec (timeout=0s): /usr/local/go/bin/go build -o /home/rohan/go/src/caddyjwt/caddy -ldflags -w -s -trimpath 
go: found caddyjwt in caddyjwt v0.0.0-00010101000000-000000000000
2020/10/19 21:27:22 [INFO] Build complete: caddy
2020/10/19 21:27:22 [INFO] Cleaning up temporary folder: /tmp/buildenv_2020-10-19-2127.273871167
2020/10/19 21:27:22 [INFO] Running [caddy list-modules]

admin.api.load
admin.api.metrics
caddy.adapters.caddyfile
caddy.listeners.tls
caddy.logging.encoders.console
caddy.logging.encoders.filter
caddy.logging.encoders.filter.delete
caddy.logging.encoders.filter.ip_mask
caddy.logging.encoders.json
caddy.logging.encoders.logfmt
caddy.logging.encoders.single_field
caddy.logging.writers.discard
caddy.logging.writers.file
caddy.logging.writers.net
caddy.logging.writers.stderr
caddy.logging.writers.stdout
caddy.storage.file_system
http
http.authentication.hashes.bcrypt
http.authentication.hashes.scrypt
http.authentication.providers.http_basic
http.encoders.gzip
http.encoders.zstd
http.handlers.acme_server
http.handlers.authentication
http.handlers.encode
http.handlers.error
http.handlers.file_server
http.handlers.headers
http.handlers.map
http.handlers.metrics
http.handlers.push
http.handlers.request_body
http.handlers.reverse_proxy
http.handlers.rewrite
http.handlers.static_response
http.handlers.subroute
http.handlers.templates
http.handlers.vars
http.matchers.expression
http.matchers.file
http.matchers.header
http.matchers.header_regexp
http.matchers.host
http.matchers.method
http.matchers.not
http.matchers.path
http.matchers.path_regexp
http.matchers.protocol
http.matchers.query
http.matchers.remote_ip
http.matchers.vars
http.matchers.vars_regexp
http.reverse_proxy.selection_policies.first
http.reverse_proxy.selection_policies.header
http.reverse_proxy.selection_policies.ip_hash
http.reverse_proxy.selection_policies.least_conn
http.reverse_proxy.selection_policies.random
http.reverse_proxy.selection_policies.random_choose
http.reverse_proxy.selection_policies.round_robin
http.reverse_proxy.selection_policies.uri_hash
http.reverse_proxy.transport.fastcgi
http.reverse_proxy.transport.http
pki
tls
tls.certificates.automate
tls.certificates.load_files
tls.certificates.load_folders
tls.certificates.load_pem
tls.handshake_match.sni
tls.issuance.acme
tls.issuance.internal
tls.issuance.zerossl
tls.stek.distributed
tls.stek.standard

Fails to build on Windows

I initially ran xcaddy build --output bin/caddy.exe --with github.com/caddyserver/nginx-adapter
and it immediately throws an exception with a stack trace and blocks my terminal.

I've also tried with various other plugins, and all have the same result.

go version: go1.16.2 windows/amd64

I realize this isn't a lot of information, I'm not very familiar with Go; if you can direct me to how to further debug this, I'd be happy to.

Stack Trace
Exception 0xc0000005 0x0 0x7ffa55310fff 0x209cbd10000
PC=0x209cbd10000

runtime: unknown pc 0x209cbd10000
stack: frame={sp:0x81fcdfe650, fp:0x0} stack=[0x0,0x81fcdffd30)
00000081fcdfe550:  00000081fcdfe598  00000081fcdfe5c0
00000081fcdfe560:  00000081fcdfe588  00000081fcdfe580
00000081fcdfe570:  00000081fcdfe584  00000209a6990fc0
00000081fcdfe580:  0000000000000000  0000000000000000
00000081fcdfe590:  0000000000000000  0000000000000005
00000081fcdfe5a0:  00000081fcdfe6e8  00007ffa52acb3df
00000081fcdfe5b0:  00000209a67c3b40  00007ffa5514345e
00000081fcdfe5c0:  00007ffa551100e8  00000209a67f86f0
00000081fcdfe5d0:  00007ffa52acb3d9  00000081fcdfe620
00000081fcdfe5e0:  004f0044004e0049  0053005c00530057
00000081fcdfe5f0:  00000209a67c3b40  0000000000000000
00000081fcdfe600:  00000209a67dfc60  006c006400050005
00000081fcdfe610:  00007ffa52acb3d9  0000000000000000
00000081fcdfe620:  00007ffa00000000  00007ffa551100e8
00000081fcdfe630:  0000000000000000  0000000000000000
00000081fcdfe640:  0000000000000001  00007ffa55142513
00000081fcdfe650: <0000020900000001  0000000000000000
00000081fcdfe660:  0000000000000000  00000081fcdfe758
00000081fcdfe670:  0000000000000000  0000000000000000
00000081fcdfe680:  0000000000000000  0000000000000000
00000081fcdfe690:  00000209a67f86f0  00007ffa55261180
00000081fcdfe6a0:  00000209a67c3b40  00007ffa552637a0
00000081fcdfe6b0:  000000000000097d  00007ffa51ccccd8
00000081fcdfe6c0:  00007ffa51cca148  00007ffa552611a8
00000081fcdfe6d0:  00007ffa55273fcf  00007ffa51cc0000
00000081fcdfe6e0:  00007ffa55265d94  00007ffa55164c60
00000081fcdfe6f0:  0000000000000000  0000000000000000
00000081fcdfe700:  0000000000000000  0000000000000000
00000081fcdfe710:  00000209a67f3d80  0000000000000044
00000081fcdfe720:  0000000000000003  00007ffa5527a3f0
00000081fcdfe730:  0000000000000001  00000081fcdfea00
00000081fcdfe740:  00000209a67dfc60  00007ffa5516eb58
runtime: unknown pc 0x209cbd10000
stack: frame={sp:0x81fcdfe650, fp:0x0} stack=[0x0,0x81fcdffd30)
00000081fcdfe550:  00000081fcdfe598  00000081fcdfe5c0
00000081fcdfe560:  00000081fcdfe588  00000081fcdfe580
00000081fcdfe570:  00000081fcdfe584  00000209a6990fc0
00000081fcdfe580:  0000000000000000  0000000000000000
00000081fcdfe590:  0000000000000000  0000000000000005
00000081fcdfe5a0:  00000081fcdfe6e8  00007ffa52acb3df
00000081fcdfe5b0:  00000209a67c3b40  00007ffa5514345e
00000081fcdfe5c0:  00007ffa551100e8  00000209a67f86f0
00000081fcdfe5d0:  00007ffa52acb3d9  00000081fcdfe620
00000081fcdfe5e0:  004f0044004e0049  0053005c00530057
00000081fcdfe5f0:  00000209a67c3b40  0000000000000000
00000081fcdfe600:  00000209a67dfc60  006c006400050005
00000081fcdfe610:  00007ffa52acb3d9  0000000000000000
00000081fcdfe620:  00007ffa00000000  00007ffa551100e8
00000081fcdfe630:  0000000000000000  0000000000000000
00000081fcdfe640:  0000000000000001  00007ffa55142513
00000081fcdfe650: <0000020900000001  0000000000000000
00000081fcdfe660:  0000000000000000  00000081fcdfe758
00000081fcdfe670:  0000000000000000  0000000000000000
00000081fcdfe680:  0000000000000000  0000000000000000
00000081fcdfe690:  00000209a67f86f0  00007ffa55261180
00000081fcdfe6a0:  00000209a67c3b40  00007ffa552637a0
00000081fcdfe6b0:  000000000000097d  00007ffa51ccccd8
00000081fcdfe6c0:  00007ffa51cca148  00007ffa552611a8
00000081fcdfe6d0:  00007ffa55273fcf  00007ffa51cc0000
00000081fcdfe6e0:  00007ffa55265d94  00007ffa55164c60
00000081fcdfe6f0:  0000000000000000  0000000000000000
00000081fcdfe700:  0000000000000000  0000000000000000
00000081fcdfe710:  00000209a67f3d80  0000000000000044
00000081fcdfe720:  0000000000000003  00007ffa5527a3f0
00000081fcdfe730:  0000000000000001  00000081fcdfea00
00000081fcdfe740:  00000209a67dfc60  00007ffa5516eb58
rax     0x7ffa51ccd87c
rbx     0x7ffa51ccd87a
rcx     0x41
rdi     0xffffffffffbadd11
rsi     0x0
rbp     0x7ffa51e1a100
rsp     0x81fcdfe650
r8      0x0
r9      0x0
r10     0x0
r11     0x97c
r12     0xc000007a
r13     0x0
r14     0x7ffa51ccd87c
r15     0x7ffa55110000
rip     0x209cbd10000
rflags  0x10202
cs      0x33
fs      0x53
gs      0x2b

Building caddy times out on slower devices

Hey Matt, thanks a lot for creating caddy. I started playing with it today on my RPi and encountered an issue when building caddy with CloudFlare DNS module. Namely, the RPi took a little bit longer when building the project and after 5 minutes it timeout out when it was fetching the deps and after I restarted the build it failed again after 5 minutes when building the project. I had to remove the timeout condition, rebuild xcaddy and then rerun it to finally get the modified caddy build.

I assume the timeout was added for CI builds but for development purposes it's really unexpected. I propose the timeout has a flag/option/env to be set and let the default behavior be without timing out. What do you think about this?

Output Binary is Not working

Issue

I am using the command :

xcaddy build

The build is successful, but the out put binary outputs:

panic: qtls.ClientSessionState not compatible with tls.ClientSessionState

goroutine 1 [running]:
github.com/lucas-clemente/quic-go/internal/handshake.init.2()
	github.com/lucas-clemente/[email protected]/internal/handshake/unsafe.go:26 +0x205

Is there something im doing wrong? The binaries downloaded from the website work fine.

Some Extra Info

OS : Ubuntu 20.04
Go Version: go version go1.15.2 linux/amd6 (Snap Pack)

cloudflare dns is not getting added

go version : go version go1.15.2 linux/amd64

xcaddy build works for cloudflare

$ xcaddy build --with github.com/caddy-dns/cloudflare


2020/10/04 00:59:23 [INFO] Temporary folder: /tmp/buildenv_2020-10-04-0059.352150349
2020/10/04 00:59:23 [INFO] Writing main module: /tmp/buildenv_2020-10-04-0059.352150349/main.go
2020/10/04 00:59:23 [INFO] Initializing Go module
2020/10/04 00:59:23 [INFO] exec (timeout=10s): /usr/local/go/bin/go mod init caddy
go: creating new go.mod: module caddy
2020/10/04 00:59:23 [INFO] Pinning versions
2020/10/04 00:59:23 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -d -v github.com/caddyserver/caddy/v2
go: github.com/caddyserver/caddy/v2 upgrade => v2.2.0
2020/10/04 00:59:24 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -d -v github.com/caddy-dns/cloudflare
go: github.com/caddy-dns/cloudflare upgrade => v0.0.0-20200811180534-4494da72fa56
2020/10/04 00:59:24 [INFO] Build environment ready
2020/10/04 00:59:24 [INFO] Building Caddy
2020/10/04 00:59:24 [INFO] exec (timeout=0s): /usr/local/go/bin/go build -o /home/<user>/caddy -ldflags -w -s -trimpath
2020/10/04 00:59:25 [INFO] Build complete: caddy
2020/10/04 00:59:25 [INFO] Cleaning up temporary folder: /tmp/buildenv_2020-10-04-0059.352150349

the list modules command is not working and throws an error

$ xcaddy list-modules


go list -m: not using modules
2020/10/04 01:01:26 [ERROR] exec [go list -m]: exit status 1:

so the module doesn't get added when I add dns cloudflare {API} in Caddyfile

run: adapting config using caddyfile: parsing caddyfile tokens for 'tls': /etc/caddy/Caddyfile:35 - Error during parsing: getting DNS provider module named 'cloudflare': module not registered: dns.providers.cloudflare

-bash: xcaddy: command not found

I get that error too! When I ran cd /root/go/bin I see a file named xcaddy. But it gave me an error like "-bash: xcaddy: command not found" when I ran any command about xcaddy in $home/go/bin

xcaddy doesn't build specified version

I noticed xcaddy isn't building the specified version. If I specify, for instance, xcaddy build v2.3.0 --with github.com/caddy-dns/cloudflare, I will get v2.4.0-beta.1 instead.

Here's the full build log:

xnaas@xnaasSRV:~/caddy$ ./xcaddy build v2.3.0 --with github.com/caddy-dns/cloudflare
2021/03/06 15:09:06 [INFO] Temporary folder: /tmp/buildenv_2021-03-06-1509.072091571
2021/03/06 15:09:06 [INFO] Writing main module: /tmp/buildenv_2021-03-06-1509.072091571/main.go
2021/03/06 15:09:06 [INFO] Initializing Go module
2021/03/06 15:09:06 [INFO] exec (timeout=10s): /home/xnaas/.gvm/gos/go1.16/bin/go mod init caddy
go: creating new go.mod: module caddy
go: to add module requirements and sums:
        go mod tidy
2021/03/06 15:09:06 [INFO] Pinning versions
2021/03/06 15:09:06 [INFO] exec (timeout=0s): /home/xnaas/.gvm/gos/go1.16/bin/go get -d -v github.com/caddyserver/caddy/[email protected]
go: downloading github.com/caddyserver/caddy/v2 v2.3.0
go: downloading github.com/prometheus/client_golang v1.9.0
go: downloading github.com/caddyserver/certmagic v0.12.1-0.20201215190346-201f83a06067
go: downloading go.uber.org/zap v1.16.0
go: downloading golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de
go: downloading github.com/beorn7/perks v1.0.1
go: downloading github.com/cespare/xxhash v1.1.0
go: downloading github.com/cespare/xxhash/v2 v2.1.1
go: downloading github.com/golang/protobuf v1.4.3
go: downloading github.com/prometheus/client_model v0.2.0
go: downloading github.com/prometheus/common v0.15.0
go: downloading github.com/prometheus/procfs v0.2.0
go: downloading golang.org/x/sys v0.0.0-20201214210602-f9fddec55a1e
go: downloading go.uber.org/atomic v1.6.0
go: downloading go.uber.org/multierr v1.5.0
go: downloading google.golang.org/protobuf v1.24.0
go: downloading github.com/matttproud/golang_protobuf_extensions v1.0.1
go: downloading github.com/klauspost/cpuid v1.2.5
go: downloading github.com/libdns/libdns v0.1.0
go: downloading github.com/mholt/acmez v0.1.1
go: downloading github.com/miekg/dns v1.1.30
go: downloading golang.org/x/net v0.0.0-20201110031124-69a78807bb2b
go: downloading golang.org/x/text v0.3.3
go get: added github.com/caddyserver/caddy/v2 v2.3.0
2021/03/06 15:10:19 [INFO] exec (timeout=0s): /home/xnaas/.gvm/gos/go1.16/bin/go get -d -v github.com/caddy-dns/cloudflare
go: downloading github.com/caddy-dns/cloudflare v0.0.0-20210227191100-728f5b67d095
go: downloading github.com/libdns/cloudflare v0.1.0
go: downloading github.com/caddyserver/caddy/v2 v2.4.0-beta.1
go: downloading github.com/libdns/libdns v0.2.0
go: downloading github.com/caddyserver/certmagic v0.12.1-0.20210211020017-ebb8d8b435b4
go: downloading github.com/mholt/acmez v0.1.3
go get: added github.com/caddy-dns/cloudflare v0.0.0-20210227191100-728f5b67d095
go get: upgraded github.com/caddyserver/caddy/v2 v2.3.0 => v2.4.0-beta.1
2021/03/06 15:10:20 [INFO] Build environment ready
2021/03/06 15:10:20 [INFO] Building Caddy
2021/03/06 15:10:20 [INFO] exec (timeout=0s): /home/xnaas/.gvm/gos/go1.16/bin/go mod tidy
go: downloading github.com/go-chi/chi v4.1.2+incompatible
go: downloading github.com/smallstep/certificates v0.15.4
go: downloading github.com/smallstep/nosql v0.3.0
go: downloading github.com/smallstep/cli v0.15.2
go: downloading github.com/smallstep/truststore v0.9.6
go: downloading github.com/dustin/go-humanize v1.0.1-0.20200219035652-afde56e7acac
go: downloading github.com/klauspost/cpuid/v2 v2.0.1
go: downloading gopkg.in/natefinch/lumberjack.v2 v2.0.0
go: downloading github.com/google/cel-go v0.6.0
go: downloading github.com/lucas-clemente/quic-go v0.19.3
go: downloading google.golang.org/genproto v0.0.0-20200806141610-86f49bd18e98
go: downloading github.com/pkg/errors v0.9.1
go: downloading github.com/smallstep/assert v0.0.0-20200723003110-82e2b9b3b262
go: downloading github.com/stretchr/testify v1.5.1
go: downloading golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f
go: downloading honnef.co/go/tools v0.0.1-2019.2.3
go: downloading github.com/klauspost/compress v1.11.3
go: downloading github.com/Masterminds/sprig/v3 v3.1.0
go: downloading github.com/alecthomas/chroma v0.8.2
go: downloading github.com/naoina/toml v0.1.1
go: downloading github.com/yuin/goldmark v1.2.1
go: downloading github.com/yuin/goldmark-highlighting v0.0.0-20200307114337-60d527fdb691
go: downloading gopkg.in/yaml.v2 v2.3.0
go: downloading howett.net/plist v0.0.0-20181124034731-591f970eefbb
go: downloading go.step.sm/crypto v0.6.0
go: downloading gopkg.in/square/go-jose.v2 v2.5.1
go: downloading github.com/BurntSushi/toml v0.3.1
go: downloading github.com/dgraph-io/badger v1.5.3
go: downloading github.com/google/go-cmp v0.4.0
go: downloading go.etcd.io/bbolt v1.3.3
go: downloading github.com/dgraph-io/badger/v2 v2.0.1-rc1.0.20200413122845-09dd2e1a4195
go: downloading github.com/go-sql-driver/mysql v1.5.0
go: downloading go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee
go: downloading github.com/davecgh/go-spew v1.1.1
go: downloading github.com/pmezard/go-difflib v1.0.0
go: downloading github.com/Masterminds/goutils v1.1.0
go: downloading github.com/Masterminds/semver v1.4.2
go: downloading github.com/google/uuid v1.1.1
go: downloading github.com/huandu/xstrings v1.3.1
go: downloading github.com/imdario/mergo v0.3.8
go: downloading github.com/mitchellh/copystructure v1.0.0
go: downloading github.com/Masterminds/semver/v3 v3.1.0
go: downloading github.com/spf13/cast v1.3.1
go: downloading github.com/marten-seemann/qpack v0.2.1
go: downloading github.com/golang/mock v1.4.4
go: downloading github.com/onsi/ginkgo v1.14.0
go: downloading github.com/onsi/gomega v1.10.1
go: downloading golang.org/x/tools v0.0.0-20200106190116-7be0a674c9fc
go: downloading github.com/naoina/go-stringutil v0.1.0
go: downloading github.com/kylelemons/godebug v1.1.0
go: downloading golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e
go: downloading github.com/urfave/cli v1.22.2
go: downloading gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15
go: downloading github.com/rs/xid v1.2.1
go: downloading github.com/sirupsen/logrus v1.6.0
go: downloading github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38
go: downloading github.com/antlr/antlr4 v0.0.0-20200503195918-621b933c7a7f
go: downloading github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2
go: downloading github.com/dgraph-io/ristretto v0.0.2-0.20200115201040-8f368f2f2ab3
go: downloading github.com/cheekybits/genny v1.0.0
go: downloading github.com/marten-seemann/qtls v0.10.0
go: downloading github.com/marten-seemann/qtls-go1-15 v0.1.1
go: downloading github.com/mitchellh/reflectwalk v1.0.0
go: downloading github.com/dlclark/regexp2 v1.2.0
go: downloading github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e
go: downloading github.com/manifoldco/promptui v0.3.1
go: downloading github.com/konsorten/go-windows-terminal-sequences v1.0.3
go: downloading github.com/kr/pretty v0.1.0
go: downloading github.com/aws/aws-sdk-go v1.30.29
go: downloading cloud.google.com/go v0.51.0
go: downloading github.com/googleapis/gax-go v2.0.0+incompatible
go: downloading github.com/googleapis/gax-go/v2 v2.0.5
go: downloading google.golang.org/api v0.15.0
go: downloading google.golang.org/grpc v1.27.1
go: downloading golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543
go: downloading github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9
go: downloading github.com/cpuguy83/go-md2man v1.0.10
go: downloading github.com/cpuguy83/go-md2man/v2 v2.0.0
go: downloading github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721
go: downloading github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897
go: downloading github.com/sergi/go-diff v1.0.0
go: downloading github.com/golang/snappy v0.0.1
go: downloading github.com/DataDog/zstd v1.4.1
go: downloading github.com/nxadm/tail v1.4.4
go: downloading github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964
go: downloading github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1
go: downloading github.com/samfoo/ansi v0.0.0-20160124022901-b6bd2ded7189
go: downloading github.com/kr/text v0.1.0
go: downloading github.com/juju/ansiterm v0.0.0-20180109212912-720a0952cc2a
go: downloading github.com/russross/blackfriday v1.5.2
go: downloading github.com/mattn/go-isatty v0.0.12
go: downloading github.com/OneOfOne/xxhash v1.2.2
go: downloading github.com/spaolacci/murmur3 v1.1.0
go: downloading github.com/russross/blackfriday/v2 v2.0.1
go: downloading gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7
go: downloading github.com/chzyer/logex v1.1.10
go: downloading github.com/shurcooL/sanitized_anchor_name v1.0.0
go: downloading github.com/mattn/go-colorable v0.1.6
go: downloading golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6
go: downloading github.com/fsnotify/fsnotify v1.4.9
go: downloading github.com/lunixbochs/vtclean v1.0.0
go: downloading go.opencensus.io v0.22.2
go: downloading google.golang.org/appengine v1.6.5
go: downloading github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
go: downloading github.com/jmespath/go-jmespath v0.3.0
go: downloading github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7
2021/03/06 15:10:27 [INFO] exec (timeout=0s): /home/xnaas/.gvm/gos/go1.16/bin/go build -o /home/xnaas/caddy/caddy -ldflags -w -s -trimpath
2021/03/06 15:10:43 [INFO] Build complete: ./caddy
2021/03/06 15:10:43 [INFO] Cleaning up temporary folder: /tmp/buildenv_2021-03-06-1509.072091571

...and the result:

xnaas@xnaasSRV:~/caddy$ ./caddy version
v2.4.0-beta.1 h1:Ed/tIaN3p6z8M3pEiXWJL/T8JmCqV62FrSJCHKquW/I=

This Dockerfile builds like this:

Cloning into '.'...
Warning: Permanently added the RSA host key for IP address '140.82.112.3' to the list of known hosts.
Reset branch 'master'
Your branch is up-to-date with 'origin/master'.
Pulling cache layers for index.docker.io/xnaas/caddy:latest...
Done!
KernelVersion: 4.4.0-1060-aws
Components: [{u'Version': u'19.03.8', u'Name': u'Engine', u'Details': {u'KernelVersion': u'4.4.0-1060-aws', u'Os': u'linux', u'BuildTime': u'2020-03-11T01:24:30.000000000+00:00', u'ApiVersion': u'1.40', u'MinAPIVersion': u'1.12', u'GitCommit': u'afacb8b7f0', u'Arch': u'amd64', u'Experimental': u'false', u'GoVersion': u'go1.12.17'}}, {u'Version': u'1.2.13', u'Name': u'containerd', u'Details': {u'GitCommit': u'7ad184331fa3e55e52b890ea95e65ba581ae3429'}}, {u'Version': u'1.0.0-rc10', u'Name': u'runc', u'Details': {u'GitCommit': u'dc9208a3303feef5b3839f4323d9beb36df0a9dd'}}, {u'Version': u'0.18.0', u'Name': u'docker-init', u'Details': {u'GitCommit': u'fec3683'}}]
Arch: amd64
BuildTime: 2020-03-11T01:24:30.000000000+00:00
ApiVersion: 1.40
Platform: {u'Name': u'Docker Engine - Community'}
Version: 19.03.8
MinAPIVersion: 1.12
GitCommit: afacb8b7f0
Os: linux
GoVersion: go1.12.17
Starting build of index.docker.io/xnaas/caddy:latest...
Step 1/8 : FROM caddy:2-builder-alpine AS builder
---> f693e06b19da
Step 2/8 : RUN xcaddy build v2.3.0 --with github.com/caddy-dns/cloudflare
---> Running in 08bdf6993cbf
�[91m2021/02/28 06:02:43 [INFO] Temporary folder: /tmp/buildenv_2021-02-28-0602.668232625
2021/02/28 06:02:43 [INFO] Writing main module: /tmp/buildenv_2021-02-28-0602.668232625/main.go
2021/02/28 06:02:43 [INFO] Initializing Go module
2021/02/28 06:02:43 [INFO] exec (timeout=10s): /usr/local/go/bin/go mod init caddy
�[0m
�[91mgo: creating new go.mod: module caddy
�[0m
�[91m2021/02/28 06:02:43 [INFO] Pinning versions
2021/02/28 06:02:43 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -d -v github.com/caddyserver/caddy/[email protected]
�[0m
�[91mgo: downloading github.com/caddyserver/caddy/v2 v2.3.0
�[0m
�[91mgo: downloading github.com/prometheus/client_golang v1.9.0
�[0m
�[91mgo: downloading go.uber.org/zap v1.16.0
�[0m
�[91mgo: downloading golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de
�[0m
�[91mgo: downloading github.com/caddyserver/certmagic v0.12.1-0.20201215190346-201f83a06067
�[0m
�[91mgo: downloading github.com/libdns/libdns v0.1.0
�[0m
�[91mgo: downloading github.com/miekg/dns v1.1.30
�[0m
�[91mgo: downloading github.com/mholt/acmez v0.1.1
�[0m
�[91mgo: downloading github.com/klauspost/cpuid v1.2.5
�[0m
�[91mgo: downloading go.uber.org/atomic v1.6.0
�[0m
�[91mgo: downloading go.uber.org/multierr v1.5.0
�[0m
�[91mgo: downloading github.com/prometheus/common v0.15.0
�[0m
�[91mgo: downloading github.com/prometheus/client_model v0.2.0
�[0m
�[91mgo: downloading github.com/cespare/xxhash v1.1.0
�[0m
�[91mgo: downloading github.com/golang/protobuf v1.4.3
�[0m
�[91mgo: downloading github.com/prometheus/procfs v0.2.0
�[0m
�[91mgo: downloading golang.org/x/net v0.0.0-20201110031124-69a78807bb2b
�[0m
�[91mgo: downloading github.com/cespare/xxhash/v2 v2.1.1
�[0m
�[91mgo: downloading golang.org/x/sys v0.0.0-20201214210602-f9fddec55a1e
�[0m
�[91mgo: downloading google.golang.org/protobuf v1.24.0
�[0m
�[91mgo: downloading github.com/beorn7/perks v1.0.1
�[0m
�[91mgo: downloading golang.org/x/text v0.3.3
�[0m
�[91mgo: downloading github.com/matttproud/golang_protobuf_extensions v1.0.1
�[0m
�[91m2021/02/28 06:02:58 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -d -v github.com/caddy-dns/cloudflare
�[0m
�[91mgo: downloading github.com/caddy-dns/cloudflare v0.0.0-20210227191100-728f5b67d095
�[0m
�[91mgo: github.com/caddy-dns/cloudflare upgrade => v0.0.0-20210227191100-728f5b67d095
�[0m
�[91mgo: downloading github.com/libdns/cloudflare v0.1.0
�[0m
�[91mgo: downloading github.com/caddyserver/caddy/v2 v2.4.0-beta.1
�[0m
�[91mgo: downloading github.com/libdns/libdns v0.2.0
�[0m
�[91mgo: downloading github.com/caddyserver/certmagic v0.12.1-0.20210211020017-ebb8d8b435b4
�[0m
�[91mgo: downloading github.com/mholt/acmez v0.1.3
�[0m
�[91m2021/02/28 06:03:00 [INFO] Build environment ready
�[0m
�[91m2021/02/28 06:03:00 [INFO] Building Caddy
�[0m
�[91m2021/02/28 06:03:00 [INFO] exec (timeout=0s): /usr/local/go/bin/go mod tidy
�[0m
�[91mgo: downloading github.com/smallstep/certificates v0.15.4
�[0m
�[91mgo: downloading github.com/klauspost/cpuid/v2 v2.0.1
�[0m
�[91mgo: downloading gopkg.in/yaml.v2 v2.3.0
�[0m
�[91mgo: downloading github.com/yuin/goldmark-highlighting v0.0.0-20200307114337-60d527fdb691
�[0m
�[91mgo: downloading github.com/alecthomas/chroma v0.8.2
�[0m
�[91mgo: downloading gopkg.in/natefinch/lumberjack.v2 v2.0.0
�[0m
�[91mgo: downloading github.com/yuin/goldmark v1.2.1
�[0m
�[91mgo: downloading github.com/smallstep/nosql v0.3.0
�[0m
�[91mgo: downloading github.com/dgraph-io/badger v1.5.3
�[0m
�[91mgo: downloading github.com/dustin/go-humanize v1.0.1-0.20200219035652-afde56e7acac
�[0m
�[91mgo: downloading github.com/klauspost/compress v1.11.3
�[0m
�[91mgo: downloading github.com/smallstep/assert v0.0.0-20200723003110-82e2b9b3b262
�[0m
�[91mgo: downloading github.com/Masterminds/sprig/v3 v3.1.0
�[0m
�[91mgo: downloading github.com/go-chi/chi v4.1.2+incompatible
�[0m
�[91mgo: downloading github.com/imdario/mergo v0.3.8
�[0m
�[91mgo: downloading github.com/huandu/xstrings v1.3.1
�[0m
�[91mgo: downloading github.com/dgraph-io/badger/v2 v2.0.1-rc1.0.20200413122845-09dd2e1a4195
�[0m
�[91mgo: downloading github.com/pkg/errors v0.9.1
�[0m
�[91mgo: downloading github.com/google/go-cmp v0.4.0
�[0m
�[91mgo: downloading github.com/smallstep/truststore v0.9.6
�[0m
�[91mgo: downloading github.com/stretchr/testify v1.5.1
�[0m
�[91mgo: downloading gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15
�[0m
�[91mgo: downloading github.com/google/cel-go v0.6.0
�[0m
�[91mgo: downloading github.com/kr/pretty v0.1.0
�[0m
�[91mgo: downloading github.com/lucas-clemente/quic-go v0.19.3
�[0m
�[91mgo: downloading golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543
�[0m
�[91mgo: downloading google.golang.org/genproto v0.0.0-20200806141610-86f49bd18e98
�[0m
�[91mgo: downloading go.etcd.io/bbolt v1.3.3
�[0m
�[91mgo: downloading go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee
�[0m
�[91mgo: downloading github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2
�[0m
�[91mgo: downloading golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f
�[0m
�[91mgo: downloading github.com/smallstep/cli v0.15.2
�[0m
�[91mgo: downloading github.com/spf13/cast v1.3.1
�[0m
�[91mgo: downloading github.com/Masterminds/goutils v1.1.0
�[0m
�[91mgo: downloading github.com/mitchellh/copystructure v1.0.0
�[0m
�[91mgo: downloading howett.net/plist v0.0.0-20181124034731-591f970eefbb
�[0m
�[91mgo: downloading github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9
�[0m
�[91mgo: downloading github.com/pmezard/go-difflib v1.0.0
�[0m
�[91mgo: downloading github.com/onsi/gomega v1.10.1
�[0m
�[91mgo: downloading github.com/cheekybits/genny v1.0.0
�[0m
�[91mgo: downloading github.com/google/uuid v1.1.1
�[0m
�[91mgo: downloading golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e
�[0m
�[91mgo: downloading github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964
�[0m
�[91mgo: downloading github.com/go-sql-driver/mysql v1.5.0
�[0m
�[91mgo: downloading github.com/onsi/ginkgo v1.14.0
�[0m
�[91mgo: downloading go.step.sm/crypto v0.6.0
�[0m
�[91mgo: downloading honnef.co/go/tools v0.0.1-2019.2.3
�[0m
�[91mgo: downloading github.com/naoina/toml v0.1.1
�[0m
�[91mgo: downloading github.com/mitchellh/reflectwalk v1.0.0
�[0m
�[91mgo: downloading github.com/Masterminds/semver v1.4.2
�[0m
�[91mgo: downloading github.com/kr/text v0.1.0
�[0m
�[91mgo: downloading github.com/rs/xid v1.2.1
�[0m
�[91mgo: downloading github.com/marten-seemann/qtls v0.10.0
�[0m
�[91mgo: downloading github.com/Masterminds/semver/v3 v3.1.0
�[0m
�[91mgo: downloading github.com/dlclark/regexp2 v1.2.0
�[0m
�[91mgo: downloading gopkg.in/square/go-jose.v2 v2.5.1
�[0m
�[91mgo: downloading github.com/marten-seemann/qpack v0.2.1
�[0m
�[91mgo: downloading github.com/naoina/go-stringutil v0.1.0
�[0m
�[91mgo: downloading github.com/marten-seemann/qtls-go1-15 v0.1.1
�[0m
�[91mgo: downloading google.golang.org/grpc v1.27.1
�[0m
�[91mgo: downloading github.com/davecgh/go-spew v1.1.1
�[0m
�[91mgo: downloading github.com/nxadm/tail v1.4.4
�[0m
�[91mgo: downloading google.golang.org/api v0.15.0
�[0m
�[91mgo: downloading github.com/antlr/antlr4 v0.0.0-20200503195918-621b933c7a7f
�[0m
�[91mgo: downloading github.com/golang/mock v1.4.4
�[0m
�[91mgo: downloading gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7
�[0m
�[91mgo: downloading github.com/googleapis/gax-go v2.0.0+incompatible
�[0m
�[91mgo: downloading github.com/golang/snappy v0.0.1
�[0m
�[91mgo: downloading github.com/googleapis/gax-go/v2 v2.0.5
�[0m
�[91mgo: downloading github.com/aws/aws-sdk-go v1.30.29
�[0m
�[91mgo: downloading github.com/BurntSushi/toml v0.3.1
�[0m
�[91mgo: downloading github.com/urfave/cli v1.22.2
�[0m
�[91mgo: downloading github.com/kylelemons/godebug v1.1.0
�[0m
�[91mgo: downloading github.com/dgraph-io/ristretto v0.0.2-0.20200115201040-8f368f2f2ab3
�[0m
�[91mgo: downloading github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e
�[0m
�[91mgo: downloading github.com/manifoldco/promptui v0.3.1
�[0m
�[91mgo: downloading github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38
�[0m
�[91mgo: downloading golang.org/x/tools v0.0.0-20200106190116-7be0a674c9fc
�[0m
�[91mgo: downloading github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721
�[0m
�[91mgo: downloading github.com/mattn/go-isatty v0.0.12
�[0m
�[91mgo: downloading github.com/shurcooL/sanitized_anchor_name v1.0.0
�[0m
�[91mgo: downloading github.com/juju/ansiterm v0.0.0-20180109212912-720a0952cc2a
�[0m
�[91mgo: downloading github.com/sirupsen/logrus v1.6.0
�[0m
�[91mgo: downloading github.com/DataDog/zstd v1.4.1
�[0m
�[91mgo: downloading github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1
�[0m
�[91mgo: downloading cloud.google.com/go v0.51.0
�[0m
�[91mgo: downloading github.com/cpuguy83/go-md2man v1.0.10
�[0m
�[91mgo: downloading github.com/cpuguy83/go-md2man/v2 v2.0.0
�[0m
�[91mgo: downloading github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897
�[0m
�[91mgo: downloading github.com/fsnotify/fsnotify v1.4.9
�[0m
�[91mgo: downloading github.com/sergi/go-diff v1.0.0
�[0m
�[91mgo: downloading github.com/samfoo/ansi v0.0.0-20160124022901-b6bd2ded7189
�[0m
�[91mgo: downloading github.com/chzyer/logex v1.1.10
�[0m
�[91mgo: downloading github.com/mattn/go-colorable v0.1.6
�[0m
�[91mgo: downloading github.com/lunixbochs/vtclean v1.0.0
�[0m
�[91mgo: downloading github.com/konsorten/go-windows-terminal-sequences v1.0.3
�[0m
�[91mgo: downloading github.com/OneOfOne/xxhash v1.2.2
�[0m
�[91mgo: downloading github.com/russross/blackfriday v1.5.2
�[0m
�[91mgo: downloading golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6
�[0m
�[91mgo: downloading google.golang.org/appengine v1.6.5
�[0m
�[91mgo: downloading go.opencensus.io v0.22.2
�[0m
�[91mgo: downloading github.com/spaolacci/murmur3 v1.1.0
�[0m
�[91mgo: downloading github.com/russross/blackfriday/v2 v2.0.1
�[0m
�[91mgo: downloading github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
�[0m
�[91mgo: downloading github.com/jmespath/go-jmespath v0.3.0
�[0m
�[91mgo: downloading github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7
�[0m
�[91m2021/02/28 06:03:20 [INFO] exec (timeout=0s): /usr/local/go/bin/go build -o /usr/bin/caddy -ldflags -w -s -trimpath
�[0m
�[91m2021/02/28 06:06:06 [INFO] Build complete: ./caddy
2021/02/28 06:06:06 [INFO] Skipping cleanup as requested; leaving folder intact: /tmp/buildenv_2021-02-28-0602.668232625
�[0m
Removing intermediate container 08bdf6993cbf
---> 1d11c1fc1d3e
Step 3/8 : FROM caddy:2-alpine
---> 2160ea65c1af
Step 4/8 : COPY --from=builder /usr/bin/caddy /usr/bin/caddy
---> 9d1120c947ec
Step 5/8 : ENV CLOUDFLARE_API_TOKEN=${CLOUDFLARE_API_TOKEN}
---> Running in dfa739e6e3cc
Removing intermediate container dfa739e6e3cc
---> c7c07bb98a6b
Step 6/8 : ENV ACMEEMAIL=${ACMEEMAIL}
---> Running in 6ba9e544a88b
Removing intermediate container 6ba9e544a88b
---> 0aabf3f89b89
Step 7/8 : ENV ASAK=${ASAK}
---> Running in c4b089f93336
Removing intermediate container c4b089f93336
---> 74a34bb1e661
Step 8/8 : ENV XADMIN=${XADMIN}
---> Running in 892c8cc0881d
Removing intermediate container 892c8cc0881d
---> ebbb00d89fe7
Successfully built ebbb00d89fe7
Successfully tagged xnaas/caddy:latest
Pushing index.docker.io/xnaas/caddy:latest...
Done!
Build finished

Same problem. I'm getting a beta build, not v2.3.0.

can we have a Docker Hub image?

I'm finally starting to play with the acme modules, and to get started, am using the following Dockerfile (with all sorts of extra bits to help me).

The main not-so-good thing, is that i'm guessing what version of go I should use, and then will have to update it

# docker build --target xcaddy --tag xcaddy .
FROM golang:1.14 as xcaddy

# get xcaddy
RUN go get -u github.com/caddyserver/xcaddy/cmd/xcaddy

# docker build --target dnsgandibuild --tag dnsgandibuild .
FROM xcaddy as dnsgandibuild
# https://caddy.community/t/how-to-use-dns-provider-modules-in-caddy-2/8148
RUN xcaddy build --with github.com/caddy-dns/gandi


# docker build --target dnsgandi --tag dnsgandi .
FROM caddy as dnsgandi
COPY --from=dnsgandibuild /go/caddy /usr/bin/caddy

ENV GANDIV5_API_KEY=
RUN echo "loc.alho.st {" > /etc/caddy/Caddyfile \
    && echo 'respond "Hello, world!"' >> /etc/caddy/Caddyfile \
    && echo "tls {" >> /etc/caddy/Caddyfile \
    && echo "dns gandi {env.GANDIV5_API_KEY}" >> /etc/caddy/Caddyfile \
    && echo "}" >> /etc/caddy/Caddyfile \
    && echo "}" >> /etc/caddy/Caddyfile

instead, I'd like to just use the correct go, with the correct caddy - all setup by "the caddy people" :)

FROM caddyserver/xcaddy as build
RUN xcaddy build --with github.com/caddy-dns/gandi

FROM caddy
COPY --from=build /go/caddy /usr/bin/caddy

Happy to make a PR with Dockerfile and .github action that looks like https://github.com/SvenDowideit/ruuvi-prometheus/blob/master/.github/workflows/dockerpublish.yml

Publish xcaddy builds for armv7

Without a handy package we can pull for building caddy on ARM, to build caddy I have to:

  1. Pull xcaddy code
  2. Build xcaddy
  3. Use xcaddy to build caddy

... Which seems a bit over the top ;)

The other option is to not use xcaddy at all - which might be a better option?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.