# syntax=docker/dockerfile:1.7

FROM golang:1.25.7-alpine AS base

WORKDIR /app

RUN apk add --no-cache ca-certificates curl git tzdata && update-ca-certificates

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

FROM base AS development

RUN curl -fsSL https://raw.githubusercontent.com/air-verse/air/master/install.sh | sh -s -- -b /usr/local/bin

COPY . .

CMD ["air", "-c", ".air.api.toml"]

FROM base AS builder

COPY . .

RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /out/api ./cmd/api

FROM alpine:3.22 AS runtime

RUN apk add --no-cache ca-certificates tzdata && update-ca-certificates

WORKDIR /app

COPY --from=builder /out/api /usr/local/bin/api

CMD ["/usr/local/bin/api"]
