FROM golang:1.12.6-alpine3.9 AS build

WORKDIR /go/src/github.com/abh/geoipapi
ADD . /go/src/github.com/abh/geoipapi
RUN go install -v ./...

FROM quay.io/ntppool/dnsmapper:geoip-data-201906
USER root
RUN apk --no-cache add ca-certificates

RUN addgroup geoip && adduser -D -G geoip geoip
WORKDIR /geoip/
COPY --from=build /go/bin/geoipapi  /bin/

USER geoip

CMD ["/bin/geoipapi"]
