FROM golang:1.24.3 AS builder

WORKDIR /app

COPY go.mod ./
COPY go.sum ./
RUN go mod download

COPY . .


RUN CGO_ENABLED=0 GOOS=linux go build -o gateway ./cmd/gateway/main.go

FROM alpine:latest

RUN adduser -HD server

WORKDIR /app

COPY --from=builder /app/gateway /app/
COPY ./configs /app/configs
COPY ./geodb /app/geodb
COPY ./.env /app/

RUN chown -R server:server /app
USER server

EXPOSE 5150
CMD ["/app/gateway"]
