FROM golang:1.23-alpine AS builder

# Install tzdata dan dependencies build
RUN apk add --no-cache tzdata build-base

# Set timezone ke Asia/Jakarta
ENV TZ=Asia/Jakarta

WORKDIR /app

COPY go.mod go.sum ./

RUN go mod tidy

COPY . .

RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main .
# RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app .

FROM alpine:latest
RUN apk --no-cache add ca-certificates

WORKDIR /root/

COPY --from=builder /app/main .
COPY --from=builder /app/.env .
EXPOSE 8082
CMD  ["./main"]