FROM golang:1.22.0-alpine3.19 AS builder

WORKDIR /twhelp

COPY go.mod go.sum ./
RUN go mod download && apk --no-cache add make

COPY . .
RUN make generate
ARG CI_COMMIT_TAG="development"
RUN CGO_ENABLED=0 go build -ldflags "-X main.version=${CI_COMMIT_TAG##v}" -trimpath -o twhelp ./cmd/twhelp

######## Start a new stage from scratch #######
FROM alpine:3.19

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

COPY --from=builder /twhelp/twhelp /usr/bin/

EXPOSE 9234/tcp

ENTRYPOINT ["twhelp"]
