# Build context: repo root (../../..)
# docker build -f deployments/docker/template-service/Dockerfile -t template-service .

FROM golang:1.25-alpine AS builder

RUN apk add --no-cache git

WORKDIR /src

COPY go.work go.work.sum ./
COPY framework ./framework
COPY services/omnix-broadcast ./services/omnix-broadcast
COPY services/template-service ./services/template-service

WORKDIR /src/services/template-service
RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" -o /out/template-service .

FROM alpine:3.20

RUN apk add --no-cache ca-certificates tzdata && \
    adduser -D -u 10001 app
USER app

WORKDIR /app
COPY --from=builder /out/template-service .
COPY services/template-service/migrations ./migrations

EXPOSE 8080
ENTRYPOINT ["./template-service"]
