# gsc-shell-api — runtime chrome data API.
#
# Build context is the project root (no monorepo file: deps).
#   podman build -f Dockerfile -t gsc-shell-api .

FROM golang:1.23-alpine AS builder
RUN apk add --no-cache git ca-certificates
WORKDIR /src

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

COPY . .
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
    go build -ldflags="-w -s" -o /out/gsc-shell-api ./cmd/server

# ----- runtime -----
FROM alpine:3.19
RUN apk add --no-cache ca-certificates tzdata && \
    addgroup -S shell && adduser -S shell -G shell
WORKDIR /app
COPY --from=builder /out/gsc-shell-api /app/gsc-shell-api
USER shell
EXPOSE 8080
ENTRYPOINT ["/app/gsc-shell-api"]
