FROM golang:1.25-alpine AS builder

RUN apk add --no-cache git ca-certificates sqlite-dev gcc musl-dev

WORKDIR /build
COPY . .

# Build the basic example
RUN cd examples/basic && \
    go mod tidy && \
    CGO_ENABLED=1 go build -o relayer-basic .

FROM alpine:latest
RUN apk --no-cache add ca-certificates sqlite wget
WORKDIR /app
COPY --from=builder /build/examples/basic/relayer-basic /app/
RUN mkdir -p /data
EXPOSE 7447
ENV DATABASE_PATH=/data/relayer.db
# PORT env is not used by relayer-basic; it always binds to 7447 in code.
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
  CMD wget --quiet --tries=1 --spider http://localhost:7447 || exit 1
CMD ["/app/relayer-basic"]
