
FROM golang:alpine AS builder
ARG TARGETARCH
ARG version=not-set
ARG SHORTSHA=not-set
WORKDIR /app
COPY . .
# https://stackoverflow.com/questions/70369368/check-architecture-in-dockerfile-to-get-amd-arm
RUN go build -o bin/tgbuser \
    -ldflags "-X main.Shortsha=${SHORTSHA} \
    -X main.Version=${version} \
    -X main.Aarch=${TARGETARCH}" ./cmd

FROM alpine AS runner
COPY --from=builder /app/bin/tgbuser /usr/bin/
WORKDIR /app
ENTRYPOINT /usr/bin/tgbuser
