mirror of
https://github.com/mje-nz/zerotier-dns.git
synced 2024-05-11 05:55:15 +00:00
Log times in local timezone, run as unprivileged user in Docker image, shrink Docker image
This commit is contained in:
+11
-5
@@ -1,6 +1,8 @@
|
||||
ARG GO_VERSION=1.13
|
||||
FROM golang:${GO_VERSION} AS builder
|
||||
|
||||
RUN useradd ztdns
|
||||
|
||||
WORKDIR /go/src/github.com/mje-nz/ztdns
|
||||
|
||||
# Fetch and cache dependencies
|
||||
@@ -9,18 +11,22 @@ RUN go mod download
|
||||
|
||||
# Build static binary
|
||||
COPY . .
|
||||
RUN CGO_ENABLED=0 GOOS=linux go install
|
||||
RUN CGO_ENABLED=0 GOOS=linux go install -ldflags="-w -s"
|
||||
|
||||
|
||||
FROM alpine:3.10
|
||||
FROM scratch
|
||||
|
||||
# We need to add ca-certificates in order to make HTTPS API calls
|
||||
RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/*
|
||||
# We need ca-certificates for HTTPS, /etc/passwd to log in, and zoneinfo for
|
||||
# time zones
|
||||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||
COPY --from=builder /etc/passwd /etc/passwd
|
||||
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
|
||||
|
||||
WORKDIR /app
|
||||
# Copy binary
|
||||
COPY --from=builder /go/bin/ztdns .
|
||||
|
||||
USER ztdns
|
||||
|
||||
ENTRYPOINT ["./ztdns"]
|
||||
CMD ["server"]
|
||||
EXPOSE 53/udp
|
||||
|
||||
@@ -75,6 +75,10 @@ var serverCmd = &cobra.Command{
|
||||
}
|
||||
|
||||
func init() {
|
||||
log.SetFormatter(&log.TextFormatter{
|
||||
TimestampFormat: "2006-01-02 15:04:05 -07:00",
|
||||
})
|
||||
|
||||
RootCmd.AddCommand(serverCmd)
|
||||
serverCmd.Flags().String("interface", "zt0", "network interface to bind to")
|
||||
serverCmd.Flags().Int("port", 53, "port to listen on")
|
||||
|
||||
Reference in New Issue
Block a user