# syntax=docker/dockerfile:1

FROM golang:1.25-alpine AS build
RUN apk add --no-cache build-base
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY . .
# goolm = pure-Go olm; sqlite needs cgo for the device/crypto stores.
ENV CGO_ENABLED=1
RUN go build -tags goolm -trimpath -ldflags="-s -w" -o /out/bellhop ./

FROM alpine:3.21
RUN apk add --no-cache ca-certificates tzdata
RUN addgroup -S bellhop && adduser -S -G bellhop bellhop
WORKDIR /app
COPY --from=build /out/bellhop /usr/local/bin/bellhop
USER bellhop
VOLUME ["/app/data"]
ENTRYPOINT ["/usr/local/bin/bellhop"]
CMD ["-config", "/app/config.toml"]
