FROM golang:1.24 AS builder

ARG APP_VERSION="dev"
ENV CGO_ENABLED=0 GOOS=linux GOARCH=amd64

WORKDIR /src
COPY . .
RUN go build -trimpath -ldflags="-s -w" -o /out/chatapp3-golang ./cmd/api

FROM alpine:3.20

ARG APP_VERSION="dev"
RUN apk add --no-cache ca-certificates wget

WORKDIR /application
COPY --from=builder /out/chatapp3-golang /application/service

LABEL org.opencontainers.image.version="${APP_VERSION}"

RUN chmod +x /application/service

ENTRYPOINT ["/application/service"]
