diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..28e68c3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM golang:alpine + +LABEL maintainer "Knut Ahlers " + +ADD . /go/src/github.com/Luzifer/share +WORKDIR /go/src/github.com/Luzifer/share + +RUN set -ex \ + && apk add --update git ca-certificates \ + && go install -ldflags "-X main.version=$(git describe --tags || git rev-parse --short HEAD || echo dev)" \ + && apk del --purge git + +EXPOSE 3000 + +ENTRYPOINT ["/go/bin/share"] +CMD ["--"] diff --git a/main.go b/main.go index 41e5dca..8f8ea7e 100644 --- a/main.go +++ b/main.go @@ -14,11 +14,11 @@ import ( var ( cfg = struct { - BaseURL string `flag:"base-url" default:"" description:"URL to prepend before filename"` - BasePath string `flag:"base-path" default:"file/{{ printf \"%.2s\" .Hash }}/{{.Hash}}" description:"Path to upload the file to"` + BaseURL string `flag:"base-url" env:"BASE_URL" default:"" description:"URL to prepend before filename"` + BasePath string `flag:"base-path" env:"BASE_PATH" default:"file/{{ printf \"%.2s\" .Hash }}/{{.Hash}}" description:"Path to upload the file to"` Bootstrap bool `flag:"bootstrap" default:"false" description:"Upload frontend files into bucket"` - Bucket string `flag:"bucket" default:"" description:"S3 bucket to upload files to" validate:"nonzero"` - Listen string `flag:"listen" default:"" description:"Enable HTTP server if set to IP/Port (e.g. ':3000')"` + Bucket string `flag:"bucket" env:"BUCKET" default:"" description:"S3 bucket to upload files to" validate:"nonzero"` + Listen string `flag:"listen" env:"LISTEN" default:"" description:"Enable HTTP server if set to IP/Port (e.g. ':3000')"` VersionAndExit bool `flag:"version" default:"false" description:"Prints current version and exits"` }{}