# First Stage: Build the binary using golang base image
FROM golang:1.25

RUN mkdir /app
ADD . /app/
WORKDIR /app
RUN CGO_ENABLED=0 GOOS=linux go build -o server .

# Second Stage: Run the compiled binary inside alpine
FROM alpine

# Fix: Alpine needs ca-certificates to verify SSL certificates
RUN apk add --no-cache ca-certificates

# Copy from first stage
COPY --from=0 /app/server /app/server

WORKDIR /app

# Default startup command
CMD ["./server"]
