Skip to content

Commit

Permalink
adding debug flag to supress output. prepping releases
Browse files Browse the repository at this point in the history
  • Loading branch information
syntaqx committed Jul 3, 2020
1 parent 114e767 commit 2d61049
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
17 changes: 8 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
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 <syntaqx@gmail.com>"

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
USER serve

VOLUME ["/var/www"]

CMD ["serve", "-dir", "/var/www"]
EXPOSE 8080
CMD ["serve", "-dir", "/var/www"]
1 change: 1 addition & 0 deletions cmd/serve/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions internal/commands/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions internal/config/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2d61049

Please sign in to comment.