FROM golang:1.22-alpine AS builder

WORKDIR /app

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

COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -o proto-gen ./cmd/server

FROM alpine:3.19

RUN apk add --no-cache git ca-certificates

WORKDIR /app

COPY --from=builder /app/proto-gen .
COPY --from=builder /app/internal/static ./internal/static

EXPOSE 8080

ENTRYPOINT ["./proto-gen"]
CMD ["--config", "/etc/proto-gen/config.yaml"]
