# syntax=docker/dockerfile:1

FROM golang:1.19

WORKDIR /app

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

COPY . .

RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /app/app ./cmd/app

# Second stage: use a minimal image
FROM alpine:latest

WORKDIR /

RUN apk add --no-cache ca-certificates

COPY --from=builder /app/app /app

EXPOSE 8080

ENTRYPOINT ["/app"]