diff --git a/Dockerfile b/Dockerfile index 1705e7a..8987432 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,26 +1,25 @@ ARG VERSION="0.0.0-docker" -ARG GO_VERSION=1.12 -ARG ALPINE_VERSION=3.9 +ARG GO_VERSION=1.13 -FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS builder +FROM golang:${GO_VERSION}-alpine AS builder WORKDIR /go/src/github.com/syntaqx/serve RUN apk add --no-cache git ca-certificates ENV CGO_ENABLED=0 GO111MODULE=on -ADD go.mod go.sum ./ +COPY go.* ./ RUN go mod download COPY . /go/src/github.com/syntaqx/serve -RUN go build -installsuffix cgo -ldflags '-s -w -X main.version=$VERSION' -o ./bin/serve ./cmd/serve +RUN go install -ldflags "-X main.version=$VERSION" ./cmd/... -FROM alpine:${ALPINE_VERSION} +FROM alpine:3 LABEL maintainer="Chase Pierce " -COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt -COPY --from=builder /go/src/github.com/syntaqx/serve/bin/serve /usr/bin/ +COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ COPY --from=builder /go/src/github.com/syntaqx/serve/static /var/www +COPY --from=builder /go/bin/serve /usr/bin/ RUN addgroup -S serve \ && adduser -D -S -s /sbin/nologin -G serve serve @@ -28,5 +27,5 @@ USER serve VOLUME ["/var/www"] -CMD ["serve", "-dir", "/var/www"] EXPOSE 8080 +CMD ["serve", "-dir", "/var/www"] diff --git a/cmd/serve/main.go b/cmd/serve/main.go index cc39d02..0caee14 100644 --- a/cmd/serve/main.go +++ b/cmd/serve/main.go @@ -14,6 +14,7 @@ var version = "0.0.0-develop" func main() { var opt config.Flags + flag.BoolVar(&opt.Debug, "debug", false, "enable debug output") flag.StringVar(&opt.Host, "host", "", "host address to bind to") flag.StringVar(&opt.Port, "port", "8080", "listening port") flag.BoolVar(&opt.EnableSSL, "ssl", false, "enable https") diff --git a/internal/commands/server.go b/internal/commands/server.go index 1f2c3ac..8cd99a6 100644 --- a/internal/commands/server.go +++ b/internal/commands/server.go @@ -67,8 +67,8 @@ func Server(log *log.Logger, opt config.Flags, dir string) error { if err != nil { log.Fatalf("unable to open users file %s", opt.UsersFile) } - } else { - log.Printf("%s does not exist, no authentication required", opt.UsersFile) + } else if opt.Debug { + log.Printf("%s does not exist, authentication skipped", opt.UsersFile) } fs.Use( diff --git a/internal/config/flags.go b/internal/config/flags.go index 7c9bbc5..f9a8017 100644 --- a/internal/config/flags.go +++ b/internal/config/flags.go @@ -9,6 +9,7 @@ var getwd = os.Getwd // Flags are the expose configuration flags available to the serve binary. type Flags struct { + Debug bool Host string Port string EnableSSL bool