Skip to content

Commit 2d61049

Browse files
committed
adding debug flag to supress output. prepping releases
1 parent 114e767 commit 2d61049

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

Dockerfile

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,31 @@
11
ARG VERSION="0.0.0-docker"
22

3-
ARG GO_VERSION=1.12
4-
ARG ALPINE_VERSION=3.9
3+
ARG GO_VERSION=1.13
54

6-
FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS builder
5+
FROM golang:${GO_VERSION}-alpine AS builder
76
WORKDIR /go/src/github.com/syntaqx/serve
87

98
RUN apk add --no-cache git ca-certificates
109
ENV CGO_ENABLED=0 GO111MODULE=on
1110

12-
ADD go.mod go.sum ./
11+
COPY go.* ./
1312
RUN go mod download
1413

1514
COPY . /go/src/github.com/syntaqx/serve
16-
RUN go build -installsuffix cgo -ldflags '-s -w -X main.version=$VERSION' -o ./bin/serve ./cmd/serve
15+
RUN go install -ldflags "-X main.version=$VERSION" ./cmd/...
1716

18-
FROM alpine:${ALPINE_VERSION}
17+
FROM alpine:3
1918
LABEL maintainer="Chase Pierce <[email protected]>"
2019

21-
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
22-
COPY --from=builder /go/src/github.com/syntaqx/serve/bin/serve /usr/bin/
20+
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
2321
COPY --from=builder /go/src/github.com/syntaqx/serve/static /var/www
22+
COPY --from=builder /go/bin/serve /usr/bin/
2423

2524
RUN addgroup -S serve \
2625
&& adduser -D -S -s /sbin/nologin -G serve serve
2726
USER serve
2827

2928
VOLUME ["/var/www"]
3029

31-
CMD ["serve", "-dir", "/var/www"]
3230
EXPOSE 8080
31+
CMD ["serve", "-dir", "/var/www"]

cmd/serve/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ var version = "0.0.0-develop"
1414

1515
func main() {
1616
var opt config.Flags
17+
flag.BoolVar(&opt.Debug, "debug", false, "enable debug output")
1718
flag.StringVar(&opt.Host, "host", "", "host address to bind to")
1819
flag.StringVar(&opt.Port, "port", "8080", "listening port")
1920
flag.BoolVar(&opt.EnableSSL, "ssl", false, "enable https")

internal/commands/server.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ func Server(log *log.Logger, opt config.Flags, dir string) error {
6767
if err != nil {
6868
log.Fatalf("unable to open users file %s", opt.UsersFile)
6969
}
70-
} else {
71-
log.Printf("%s does not exist, no authentication required", opt.UsersFile)
70+
} else if opt.Debug {
71+
log.Printf("%s does not exist, authentication skipped", opt.UsersFile)
7272
}
7373

7474
fs.Use(

internal/config/flags.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ var getwd = os.Getwd
99

1010
// Flags are the expose configuration flags available to the serve binary.
1111
type Flags struct {
12+
Debug bool
1213
Host string
1314
Port string
1415
EnableSSL bool

0 commit comments

Comments
 (0)