# Cache dependency
FROM golang:1.26-alpine AS go-mod-cache

WORKDIR /app

COPY go.mod go.sum ./

RUN go mod download

# BUILD
FROM go-mod-cache AS build

WORKDIR /app

COPY . .

RUN go build -o ipinfo .

# RUN IMAGE
FROM alpine

RUN apk update && apk upgrade && \
    apk add --no-cache tzdata

WORKDIR /app
COPY --from=build /app/ipinfo .
COPY mmdbmeld.yml .

CMD ["./ipinfo"]