diff --git a/builder/builder.sh b/builder/builder.sh index d98db9c..fde2cf4 100644 --- a/builder/builder.sh +++ b/builder/builder.sh @@ -4,53 +4,126 @@ VERSION=${VERSION:-"0.11.5"} TELEMETRY=${ENABLE_TELEMETRY:-"true"} # add `v` prefix for version numbers -checkout_tag=false -[ "$(echo $VERSION | cut -c1)" -ge 0 ] 2>/dev/null && VERSION="v$VERSION" && checkout_tag=true +[ "$(echo $VERSION | cut -c1)" -ge 0 ] 2>/dev/null && VERSION="v$VERSION" -# caddy -git clone https://github.com/mholt/caddy -b "$VERSION" /go/src/github.com/mholt/caddy \ - && cd /go/src/github.com/mholt/caddy \ - && $checkout_tag && git checkout -b "$VERSION" +stage() { + STAGE="$1" + echo -------- + echo Stage: $STAGE + echo -------- +} -# plugin helper -GOOS=linux GOARCH=amd64 go get -v github.com/abiosoft/caddyplug/caddyplug -alias caddyplug='GO111MODULE=off GOOS=linux GOARCH=amd64 caddyplug' +end_stage() { + if [ $? -ne 0 ]; then + >&2 echo error at \'$STAGE\' + exit 1 + fi +} -# check for modules support -go_mod=false -[ -f /go/src/github.com/mholt/caddy/go.mod ] && export GO111MODULE=on && go_mod=true +get_package() { + GO111MODULE=off GOOS=linux GOARCH=amd64 caddyplug package $1 +} + +plugins() { + mkdir -p /plugins + for plugin in $(echo $PLUGINS | tr "," " "); do \ + import_package=$(get_package $plugin) + $go_mod || go get -v "$import_package" ; # not needed for modules + $go_mod && package="main" || package="caddyhttp" + printf "package $package\nimport _ \"$import_package\"" > \ + /plugins/$plugin.go ; \ + done +} -# telemetry -run_file="/go/src/github.com/mholt/caddy/caddy/caddymain/run.go" -if [ "$TELEMETRY" = "false" ]; then - cat > "$run_file.disablestats.go" < main.go < \ - /go/src/github.com/mholt/caddy/caddyhttp/$plugin.go ; \ -done +legacy() { + cd /go/src/github.com/mholt/caddy/caddy # build dir -# builder dependency, not needed for modules -$go_mod || git clone https://github.com/caddyserver/builds /go/src/github.com/caddyserver/builds + # plugins + cp -r /plugins/. ../caddyhttp + + # telemetry + run_file="/go/src/github.com/mholt/caddy/caddy/caddymain/run.go" + if [ "$TELEMETRY" = "false" ]; then + cat > "$run_file.disablestats.go" <