Switch to Go modules and script, bump to 1.0.0
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
Closes #3pull/5/head 1.0.0
parent
6da16d7546
commit
a44cf0f4a3
|
@ -0,0 +1,2 @@
|
||||||
|
caddy.go
|
||||||
|
go.sum
|
33
Dockerfile
33
Dockerfile
|
@ -1,38 +1,29 @@
|
||||||
#
|
#
|
||||||
# Build stage by @abiosoft https://github.com/abiosoft/caddy-docker
|
# Build stage
|
||||||
#
|
#
|
||||||
FROM golang:1.12-alpine as build
|
FROM golang:1.12-alpine as build
|
||||||
|
|
||||||
# args
|
# args
|
||||||
ARG version="0.11.5"
|
ARG version="1.0.0"
|
||||||
# add plugins here separated by commas
|
# add plugin import paths here separated by commas
|
||||||
ARG plugins=""
|
ARG plugins=""
|
||||||
|
ARG telemetry="true"
|
||||||
|
|
||||||
# deps
|
# deps
|
||||||
RUN apk add --no-cache git
|
RUN apk add --no-cache git
|
||||||
|
|
||||||
# source
|
# build root
|
||||||
RUN git clone https://github.com/mholt/caddy -b "v${version}" $GOPATH/src/github.com/mholt/caddy
|
RUN mkdir /build
|
||||||
WORKDIR $GOPATH/src/github.com/mholt/caddy
|
WORKDIR /build
|
||||||
RUN git checkout -b "v${version}"
|
ENV GO111MODULE=on
|
||||||
|
ENV CGO_ENABLED=0
|
||||||
# plugin helper
|
|
||||||
RUN go get -v github.com/abiosoft/caddyplug/caddyplug
|
|
||||||
|
|
||||||
# plugins
|
# plugins
|
||||||
RUN for plugin in $(echo $plugins | tr "," " "); do \
|
COPY go.mod plugger.go ./
|
||||||
go get -v $(caddyplug package $plugin); \
|
RUN go run plugger.go -plugins="${plugins}" -telemetry="${telemetry}"
|
||||||
printf "package caddyhttp\nimport _ \"$(caddyplug package $plugin)\"" > \
|
|
||||||
$GOPATH/src/github.com/mholt/caddy/caddyhttp/$plugin.go ; \
|
|
||||||
done
|
|
||||||
|
|
||||||
# builder dependency
|
|
||||||
RUN git clone https://github.com/caddyserver/builds $GOPATH/src/github.com/caddyserver/builds
|
|
||||||
|
|
||||||
# build
|
# build
|
||||||
WORKDIR $GOPATH/src/github.com/mholt/caddy/caddy
|
RUN go build
|
||||||
RUN git checkout -f
|
|
||||||
RUN go run build.go
|
|
||||||
RUN mv caddy /
|
RUN mv caddy /
|
||||||
|
|
||||||
|
|
||||||
|
|
15
README.md
15
README.md
|
@ -21,3 +21,18 @@ Persist `.caddy` to avoid hitting Let's Encrypt's rate limit:
|
||||||
```
|
```
|
||||||
docker run -it --rm -p 2015:2015 -v $PWD:/srv -v $PWD/Caddyfile:/etc/Caddyfile -v $HOME/.caddy:/etc/.caddy productionwentdown/caddy
|
docker run -it --rm -p 2015:2015 -v $PWD:/srv -v $PWD/Caddyfile:/etc/Caddyfile -v $HOME/.caddy:/etc/.caddy productionwentdown/caddy
|
||||||
```
|
```
|
||||||
|
|
||||||
|
# Build with plugins
|
||||||
|
|
||||||
|
Using `docker build` arguments:
|
||||||
|
```
|
||||||
|
docker build -t caddy --build-arg plugins=github.com/abiosoft/caddy-git,github.com/zikes/gopkg .
|
||||||
|
```
|
||||||
|
|
||||||
|
You can also fork and edit plugger.go for more advanced plugin configuration
|
||||||
|
|
||||||
|
# Build without telemetry
|
||||||
|
|
||||||
|
```
|
||||||
|
docker build -t caddy --build-arg telemetry=false
|
||||||
|
```
|
||||||
|
|
|
@ -0,0 +1,61 @@
|
||||||
|
// +build ignore
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"flag"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
"text/template"
|
||||||
|
)
|
||||||
|
|
||||||
|
var plugins string
|
||||||
|
var telemetry bool
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
flag.StringVar(&plugins, "plugins", "", "Specify plugins by full paths, seperated by commas")
|
||||||
|
flag.BoolVar(&telemetry, "telemetry", false, "Enable telemetry")
|
||||||
|
flag.Parse()
|
||||||
|
|
||||||
|
d := &data{
|
||||||
|
Plugins: strings.FieldsFunc(plugins, func(c rune) bool { return c == ',' }),
|
||||||
|
EnableTelemetry: telemetry,
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Printf("Additional plugins: %v", d.Plugins)
|
||||||
|
log.Printf("Enabled telemetry: %v", d.EnableTelemetry)
|
||||||
|
|
||||||
|
f, err := os.Create("caddy.go")
|
||||||
|
defer f.Close()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal("Unable to open file")
|
||||||
|
}
|
||||||
|
|
||||||
|
t := template.Must(template.New("caddy.go").Parse(caddyTemplate))
|
||||||
|
t.Execute(f, d)
|
||||||
|
}
|
||||||
|
|
||||||
|
type data struct {
|
||||||
|
Plugins []string
|
||||||
|
EnableTelemetry bool
|
||||||
|
}
|
||||||
|
|
||||||
|
var caddyTemplate = `
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/mholt/caddy/caddy/caddymain"
|
||||||
|
|
||||||
|
// plug in plugins here
|
||||||
|
{{range $plugin := .Plugins}}
|
||||||
|
_ "{{$plugin}}"
|
||||||
|
{{end}}
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
// optional: disable telemetry
|
||||||
|
caddymain.EnableTelemetry = {{.EnableTelemetry}}
|
||||||
|
caddymain.Run()
|
||||||
|
}
|
||||||
|
`
|
Loading…
Reference in New Issue