FROM golang:1.22-alpine AS builder

# Install build dependencies (for sqlite)
RUN apk add --no-cache gcc musl-dev

WORKDIR /app

# Copy go mod files
COPY go.mod go.sum ./
RUN go mod download

# Copy source
COPY . .

# Build with CGO enabled (required for sqlite)
RUN CGO_ENABLED=1 go build -o tracker .

# Runtime image
FROM alpine:3.19

RUN apk add --no-cache ca-certificates tzdata curl

WORKDIR /app

COPY --from=builder /app/tracker .

# Config is mounted at runtime via docker-compose volume
# Default config path: /app/config.yaml

ENTRYPOINT ["./tracker"]
CMD ["-config", "/app/config.yaml"]
