Building Caddy on Digital Ocean (xcaddy)

1. Output of caddy version:

master

2. How I run Caddy:

Docker

a. System environment:

Digital Ocean Droplet

Docker: 20.10.18
OS: Debian GNU/Linux 11 (bullseye) x86_64
Host: Droplet 20171212
Kernel: 5.10.0-11-amd64
Shell: bash 5.1.4
CPU: DO-Regular (1) @ 2.294GHz
Memory: 163MiB / 473MiB

b. Command:

docker build .

c. Service/unit/compose file:

ARG CADDY_VERSION=2.5.2
FROM caddy:${CADDY_VERSION}-builder AS builder

RUN xcaddy build master \
    --with github.com/lucaslorentz/caddy-docker-proxy/plugin \
    --with github.com/caddy-dns/cloudflare

FROM caddy:${CADDY_VERSION}-alpine

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

CMD ["caddy", "docker-proxy"]

3. The problem I’m having:

Build fails when building on Digital Ocean droplet. Works fine on my desktop.

I’m testing my config on a DO droplet to see if I can reproduce the problems I’m having with Cloudflare tunnels/Docker Swarm (unsure if that’s a sensible thing to try), but I found that I could not successfully run a build on a droplet. I’m not particularly concerned about the issue as I can copy the image, but it would be slightly easier if there were an obvious quick fix.

Error messages and/or full log output:

docker@swarm:~/caddy/builder$ docker build .
Sending build context to Docker daemon  2.048kB
Step 1/6 : ARG CADDY_VERSION=2.5.2
Step 2/6 : FROM caddy:${CADDY_VERSION}-builder AS builder
2.5.2-builder: Pulling from library/caddy
213ec9aee27d: Already exists
5299e6f78605: Already exists
1cab0e43db0a: Already exists
548b71e657dc: Already exists
a0792f1a6db3: Already exists
bac41a3b93e7: Already exists
39a0d8604657: Already exists
00cf75964ac6: Already exists
Digest: sha256:1a8f153ebe56283c4d5168d92c049b00ae1c635248f99295c4c106ccfad3012f
Status: Downloaded newer image for caddy:2.5.2-builder
 ---> 446a17d6179d
Step 3/6 : RUN xcaddy build master     --with github.com/lucaslorentz/caddy-docker-proxy/plugin     --with github.com/caddy-dns/cloudflare
 ---> Running in 3d026fd8848b
2022/09/13 21:22:36 [INFO] Temporary folder: /tmp/buildenv_2022-09-13-2122.2677632811
2022/09/13 21:22:36 [INFO] Writing main module: /tmp/buildenv_2022-09-13-2122.2677632811/main.go
package main

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

        // plug in Caddy modules here
        _ "github.com/caddyserver/caddy/v2/modules/standard"
        _ "github.com/lucaslorentz/caddy-docker-proxy/plugin"
        _ "github.com/caddy-dns/cloudflare"
)

func main() {
        caddycmd.Main()
}
2022/09/13 21:22:36 [INFO] Initializing Go module
2022/09/13 21:22:36 [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
2022/09/13 21:22:36 [INFO] Pinning versions
2022/09/13 21:22:36 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -d -v github.com/caddyserver/caddy/v2@master
go: downloading github.com/caddyserver/caddy/v2 v2.6.0-beta.3.0.20220913194321-754fe4f7b4dd
go: downloading github.com/caddyserver/caddy v1.0.6-0.20200303163406-891446d06340
go: downloading github.com/caddyserver/certmagic v0.17.1
go: downloading github.com/google/uuid v1.3.0
go: downloading github.com/lucas-clemente/quic-go v0.28.2-0.20220813150001-9957668d4301
go: downloading github.com/prometheus/client_golang v1.12.2
go: downloading go.uber.org/zap v1.21.0
go: downloading golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10
go: downloading golang.org/x/term v0.0.0-20210927222741-03fcf44c2211
go: downloading github.com/klauspost/cpuid/v2 v2.1.0
go: downloading github.com/libdns/libdns v0.2.1
go: downloading github.com/mholt/acmez v1.0.4
go: downloading github.com/miekg/dns v1.1.50
go: downloading golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa
go: downloading golang.org/x/net v0.0.0-20220812165438-1d4ff48094d1
go: downloading github.com/golang/mock v1.6.0
go: downloading github.com/onsi/ginkgo v1.16.4
go: downloading github.com/marten-seemann/qpack v0.2.1
go: downloading github.com/beorn7/perks v1.0.1
go: downloading github.com/cespare/xxhash/v2 v2.1.2
go: downloading github.com/cespare/xxhash v1.1.0
go: downloading github.com/golang/protobuf v1.5.2
go: downloading github.com/prometheus/client_model v0.2.0
go: downloading github.com/prometheus/common v0.32.1
go: downloading github.com/prometheus/procfs v0.7.3
go: downloading google.golang.org/protobuf v1.28.0
go: downloading go.uber.org/atomic v1.9.0
go: downloading go.uber.org/multierr v1.6.0
go: downloading golang.org/x/tools v0.1.10
go: downloading golang.org/x/text v0.3.8-0.20211004125949-5bd84dd9b33b
go: downloading golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3
go: downloading golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e
go: downloading github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0
go: downloading github.com/marten-seemann/qtls-go1-18 v0.1.2
go: downloading github.com/marten-seemann/qtls-go1-19 v0.1.0
go: downloading github.com/matttproud/golang_protobuf_extensions v1.0.1
go: downloading golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
go: downloading github.com/nxadm/tail v1.4.8
go: downloading gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7
go: downloading github.com/fsnotify/fsnotify v1.5.1
go: added github.com/beorn7/perks v1.0.1
go: added github.com/caddyserver/caddy/v2 v2.6.0-beta.3.0.20220913194321-754fe4f7b4dd
go: added github.com/caddyserver/certmagic v0.17.1
go: added github.com/cespare/xxhash/v2 v2.1.2
go: added github.com/fsnotify/fsnotify v1.5.1
go: added github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0
go: added github.com/golang/mock v1.6.0
go: added github.com/golang/protobuf v1.5.2
go: added github.com/google/uuid v1.3.0
go: added github.com/klauspost/cpuid/v2 v2.1.0
go: added github.com/libdns/libdns v0.2.1
go: added github.com/lucas-clemente/quic-go v0.28.2-0.20220813150001-9957668d4301
go: added github.com/marten-seemann/qpack v0.2.1
go: added github.com/marten-seemann/qtls-go1-18 v0.1.2
go: added github.com/marten-seemann/qtls-go1-19 v0.1.0
go: added github.com/matttproud/golang_protobuf_extensions v1.0.1
go: added github.com/mholt/acmez v1.0.4
go: added github.com/miekg/dns v1.1.50
go: added github.com/nxadm/tail v1.4.8
go: added github.com/onsi/ginkgo v1.16.4
go: added github.com/prometheus/client_golang v1.12.2
go: added github.com/prometheus/client_model v0.2.0
go: added github.com/prometheus/common v0.32.1
go: added github.com/prometheus/procfs v0.7.3
go: added go.uber.org/atomic v1.9.0
go: added go.uber.org/multierr v1.6.0
go: added go.uber.org/zap v1.21.0
go: added golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa
go: added golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e
go: added golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3
go: added golang.org/x/net v0.0.0-20220812165438-1d4ff48094d1
go: added golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10
go: added golang.org/x/term v0.0.0-20210927222741-03fcf44c2211
go: added golang.org/x/text v0.3.8-0.20211004125949-5bd84dd9b33b
go: added golang.org/x/tools v0.1.10
go: added golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
go: added google.golang.org/protobuf v1.28.0
go: added gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7
2022/09/13 21:23:15 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -d -v github.com/lucaslorentz/caddy-docker-proxy/plugin github.com/caddyserver/caddy/v2@master
go: downloading github.com/lucaslorentz/caddy-docker-proxy v0.3.6
go: downloading github.com/lucaslorentz/caddy-docker-proxy/plugin v0.0.0-20220518223657-500809a26c5d
go: downloading github.com/docker/docker v20.10.14+incompatible
go: downloading github.com/aryann/difflib v0.0.0-20210328193216-ff5ff6dc229b
go: downloading github.com/spf13/cobra v1.1.3
go: downloading github.com/spf13/pflag v1.0.5
go: downloading github.com/docker/go-connections v0.4.0
go: downloading github.com/docker/go-units v0.4.0
go: downloading github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799
go: downloading github.com/containerd/containerd v1.6.3
go: downloading github.com/docker/distribution v2.8.1+incompatible
go: downloading github.com/opencontainers/go-digest v1.0.0
go: downloading github.com/pkg/errors v0.9.1
go: downloading github.com/inconshreveable/mousetrap v1.0.0
go: downloading github.com/cpuguy83/go-md2man/v2 v2.0.1
go: downloading gopkg.in/yaml.v2 v2.4.0
go: downloading github.com/sirupsen/logrus v1.8.1
go: downloading google.golang.org/grpc v1.46.0
go: downloading github.com/Microsoft/go-winio v0.5.1
go: downloading github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369
go: downloading github.com/russross/blackfriday/v2 v2.1.0
go: downloading github.com/gogo/protobuf v1.3.2
go: downloading google.golang.org/genproto v0.0.0-20220502173005-c8bf987b8c21
go: downloading github.com/smallstep/certificates v0.21.0
go: downloading github.com/smallstep/cli v0.21.0
go: downloading github.com/smallstep/truststore v0.12.0
go: downloading github.com/go-chi/chi v4.1.2+incompatible
go: downloading github.com/smallstep/nosql v0.4.0
go: downloading github.com/tailscale/tscert v0.0.0-20220316030059-54bbcb9f74e2
go: downloading github.com/dustin/go-humanize v1.0.1-0.20200219035652-afde56e7acac
go: downloading gopkg.in/natefinch/lumberjack.v2 v2.0.0
go: downloading github.com/google/cel-go v0.12.4
go: downloading github.com/klauspost/compress v1.15.9
go: downloading github.com/BurntSushi/toml v1.2.0
go: downloading github.com/Masterminds/sprig/v3 v3.2.2
go: downloading github.com/alecthomas/chroma v0.10.0
go: downloading github.com/yuin/goldmark v1.4.13
go: downloading github.com/yuin/goldmark-highlighting v0.0.0-20220208100518-594be1970594
go: downloading gopkg.in/yaml.v3 v3.0.1
go: downloading go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.34.0
go: downloading go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.4.0
go: downloading go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.4.0
go: downloading go.opentelemetry.io/otel v1.9.0
go: downloading go.opentelemetry.io/otel/sdk v1.4.0
go: downloading go.step.sm/cli-utils v0.7.3
go: downloading go.step.sm/crypto v0.16.2
go: downloading go.step.sm/linkedca v0.16.1
go: downloading gopkg.in/square/go-jose.v2 v2.6.0
go: downloading howett.net/plist v1.0.0
go: downloading github.com/slackhq/nebula v1.5.2
go: downloading github.com/stoewer/go-strcase v1.2.0
go: downloading github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20220418222510-f25a4f6275ed
go: downloading github.com/antlr/antlr4 v0.0.0-20200503195918-621b933c7a7f
go: downloading github.com/Masterminds/goutils v1.1.1
go: downloading github.com/Masterminds/semver/v3 v3.1.1
go: downloading github.com/huandu/xstrings v1.3.2
go: downloading github.com/imdario/mergo v0.3.12
go: downloading github.com/mitchellh/copystructure v1.2.0
go: downloading github.com/shopspring/decimal v1.2.0
go: downloading github.com/spf13/cast v1.4.1
go: downloading github.com/felixge/httpsnoop v1.0.3
go: downloading go.opentelemetry.io/otel/metric v0.31.0
go: downloading go.opentelemetry.io/otel/trace v1.9.0
go: downloading go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.4.0
go: downloading go.opentelemetry.io/proto/otlp v0.12.0
go: downloading github.com/micromdm/scep/v2 v2.1.0
go: downloading go.mozilla.org/pkcs7 v0.0.0-20210826202110-33d05740a352
go: downloading github.com/urfave/cli v1.22.5
go: downloading github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e
go: downloading github.com/manifoldco/promptui v0.9.0
go: downloading github.com/rs/xid v1.2.1
go: downloading filippo.io/edwards25519 v1.0.0-rc.1
go: downloading github.com/dgraph-io/badger v1.6.2
go: downloading github.com/dgraph-io/badger/v2 v2.2007.4
go: downloading go.etcd.io/bbolt v1.3.6
go: downloading github.com/go-sql-driver/mysql v1.6.0
go: downloading github.com/jackc/pgx/v4 v4.14.0
go: downloading github.com/mitchellh/go-ps v1.0.0
go: downloading github.com/mitchellh/reflectwalk v1.0.2
go: downloading github.com/dlclark/regexp2 v1.4.0
go: downloading github.com/go-logr/logr v1.2.3
go: downloading github.com/cenkalti/backoff/v4 v4.1.2
go: downloading github.com/grpc-ecosystem/grpc-gateway v1.16.0
go: downloading github.com/go-logr/stdr v1.2.2
go: downloading github.com/go-kit/kit v0.10.0
go: downloading github.com/dgraph-io/ristretto v0.0.4-0.20200906165740-41ebdbffecfd
go: downloading github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13
go: downloading github.com/jackc/pgconn v1.10.1
go: downloading github.com/jackc/pgio v1.0.0
go: downloading github.com/jackc/pgproto3/v2 v2.2.0
go: downloading github.com/jackc/pgtype v1.9.0
go: downloading github.com/go-logfmt/logfmt v0.5.0
go: downloading github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d
go: downloading github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96
go: downloading github.com/golang/snappy v0.0.4
go: downloading github.com/jackc/chunkreader/v2 v2.0.1
go: downloading github.com/jackc/pgpassfile v1.0.0
go: downloading github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b
go: downloading github.com/mattn/go-colorable v0.1.8
go: downloading github.com/shurcooL/sanitized_anchor_name v1.0.0
go: downloading github.com/mattn/go-isatty v0.0.13
go: downloading github.com/antlr/antlr4/runtime/Go/antlr v1.4.10
go: downloading github.com/antlr/antlr4 v4.11.1+incompatible
go: added github.com/Microsoft/go-winio v0.5.1
go: upgraded github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20220418222510-f25a4f6275ed => v1.4.10
go: added github.com/containerd/containerd v1.6.3
go: added github.com/docker/distribution v2.8.1+incompatible
go: added github.com/docker/docker v20.10.14+incompatible
go: added github.com/docker/go-connections v0.4.0
go: added github.com/docker/go-units v0.4.0
go: upgraded github.com/gogo/protobuf v1.1.1 => v1.3.2
go: added github.com/lucaslorentz/caddy-docker-proxy/plugin v0.0.0-20220518223657-500809a26c5d
go: upgraded github.com/matttproud/golang_protobuf_extensions v1.0.1 => v1.0.2-0.20181231171920-c182affec369
go: added github.com/opencontainers/go-digest v1.0.0
go: added github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799
2022/09/13 21:24:23 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -d -v github.com/caddy-dns/cloudflare github.com/caddyserver/caddy/v2@master
go: downloading github.com/caddy-dns/cloudflare v0.0.0-20210607183747-91cf700356a1
go: downloading github.com/libdns/cloudflare v0.1.0
go: added github.com/caddy-dns/cloudflare v0.0.0-20210607183747-91cf700356a1
go: added github.com/libdns/cloudflare v0.1.0
2022/09/13 21:24:37 [INFO] exec (timeout=0s): /usr/local/go/bin/go get -d -v
2022/09/13 21:24:45 [INFO] Build environment ready
2022/09/13 21:24:45 [INFO] Building Caddy
2022/09/13 21:24:45 [INFO] exec (timeout=0s): /usr/local/go/bin/go mod tidy
go: downloading github.com/stretchr/testify v1.8.0
go: downloading go.uber.org/goleak v1.1.12
go: downloading gotest.tools/v3 v3.2.0
go: downloading github.com/onsi/gomega v1.15.0
go: downloading golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
go: downloading gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c
go: downloading github.com/davecgh/go-spew v1.1.1
go: downloading github.com/pmezard/go-difflib v1.0.0
go: downloading github.com/benbjohnson/clock v1.1.0
go: downloading github.com/smallstep/assert v0.0.0-20200723003110-82e2b9b3b262
go: downloading github.com/google/go-cmp v0.5.8
go: downloading github.com/gorilla/mux v1.7.3
go: downloading github.com/kr/pretty v0.2.1
go: downloading github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6
go: downloading github.com/morikuni/aec v1.0.0
go: downloading github.com/kr/text v0.2.0
go: downloading github.com/aws/aws-sdk-go v1.37.0
go: downloading cloud.google.com/go/kms v1.4.0
go: downloading cloud.google.com/go v0.100.2
go: downloading github.com/googleapis/gax-go/v2 v2.1.1
go: downloading github.com/googleapis/gax-go v2.0.0+incompatible
go: downloading google.golang.org/api v0.70.0
go: downloading github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1
go: downloading github.com/cockroachdb/apd v1.1.0
go: downloading github.com/gofrs/uuid v4.0.0+incompatible
go: downloading cloud.google.com/go/iam v0.1.0
go: downloading golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8
go: downloading github.com/go-stack/stack v1.8.0
go: downloading github.com/chzyer/logex v1.1.10
go: downloading github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65
go: downloading github.com/lib/pq v1.10.2
go: downloading golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac
go: downloading github.com/jmespath/go-jmespath v0.4.0
go: downloading cloud.google.com/go/compute v1.3.0
go: downloading go.opencensus.io v0.23.0
go: downloading google.golang.org/appengine v1.6.7
go: downloading github.com/OneOfOne/xxhash v1.2.2
go: downloading github.com/spaolacci/murmur3 v1.1.0
go: downloading github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da
go: finding module for package github.com/Azure/go-ansiterm
go: downloading github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1
go: finding module for package github.com/Azure/go-ansiterm/winterm
go: found github.com/Azure/go-ansiterm in github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1
go: found github.com/Azure/go-ansiterm/winterm in github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1
2022/09/13 21:25:06 [INFO] exec (timeout=0s): /usr/local/go/bin/go build -o /usr/bin/caddy -ldflags -w -s -trimpath
go build github.com/yuin/goldmark/util: /usr/local/go/pkg/tool/linux_amd64/compile: signal: killed
2022/09/13 21:31:05 [INFO] Skipping cleanup as requested; leaving folder intact: /tmp/buildenv_2022-09-13-2122.2677632811
2022/09/13 21:31:05 [FATAL] exit status 1
The command '/bin/sh -c xcaddy build master     --with github.com/lucaslorentz/caddy-docker-proxy/plugin     --with github.com/caddy-dns/cloudflare' returned a non-zero code: 1

Something killed the process. Did you run out of memory? (check dmesg)

1 Like

Doh! I should have caught that. Sorry for the noise. I’m getting old: my mind is not as agile and flexible as it used to be. Thank you.

2 Likes