FROM golang:1.22-alpine AS builder

WORKDIR /app
RUN apk add --no-cache git

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

COPY . .
RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /panel ./cmd/panel
RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /install ./cmd/install

FROM alpine:3.20

RUN apk add --no-cache ca-certificates tzdata
WORKDIR /app

COPY --from=builder /panel /app/panel
COPY --from=builder /install /app/install

EXPOSE 8080
CMD ["/app/panel"]
