diff --git a/Dockerfile b/Dockerfile index 07e17cc6..c1b6ca50 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,22 +4,22 @@ ARG VERSION WORKDIR /build COPY . . -RUN apk add git -RUN CGO_ENABLED=0 go build -ldflags="-s -w -X 'github.com/prometheus/common/version.Version=$VERSION'" +RUN apk add git \ + && CGO_ENABLED=0 go build -ldflags="-s -w -X 'github.com/prometheus/common/version.Version=$VERSION'" FROM alpine:3.18.4 -RUN apk add --no-cache tzdata -RUN mkdir -p /etc/dnscollector/ /var/dnscollector/ +RUN apk add --no-cache tzdata \ + && mkdir -p /etc/dnscollector/ /var/dnscollector/ \ + && addgroup -g 1000 dnscollector && adduser -D -H -G dnscollector -u 1000 -S dnscollector \ + && chown dnscollector:dnscollector /var/dnscollector /etc/dnscollector + +USER dnscollector COPY --from=builder /build/go-dnscollector /bin/go-dnscollector COPY --from=builder /build/config.yml ./etc/dnscollector/config.yml -RUN addgroup -g 1000 dnscollector && adduser -D -H -G dnscollector -u 1000 -S dnscollector -RUN chown dnscollector:dnscollector /var/dnscollector /etc/dnscollector -USER dnscollector - EXPOSE 6000/tcp 8080/tcp ENTRYPOINT ["/bin/go-dnscollector"]