Build a comprehensive website monitoring application with ReasonML, OCaml, and server-reason-react.
Features:
- Real-time website monitoring with HTTP status checks
- Email and webhook alerting system
- Beautiful admin dashboard with Tailwind CSS
- Complete REST API for CRUD operations
- Background monitoring scheduler
- Multi-container Docker setup with 1-core CPU constraint
- PostgreSQL database with Caqti
- Full documentation and setup guides
Tech Stack:
- OCaml 5.0+ with ReasonML
- Dream web framework
- server-reason-react for UI
- PostgreSQL 16 database
- Docker & Docker Compose
Files:
- 9 OCaml source files (1961 LOC)
- 6 documentation files (1603 LOC)
- Complete Docker configuration
- Comprehensive API documentation
💘 Generated with Crush
65 lines
1.6 KiB
Docker
65 lines
1.6 KiB
Docker
# Base stage
|
|
FROM ocaml/opam:debian-12-ocaml-5.2 as base
|
|
WORKDIR /home/opam/website_monitor
|
|
|
|
# Install system dependencies
|
|
RUN sudo apt-get update && sudo apt-get install -y \
|
|
pkg-config \
|
|
libssl-dev \
|
|
ca-certificates \
|
|
m4 \
|
|
postgresql-client \
|
|
&& sudo rm -rf /var/lib/apt/lists/*
|
|
|
|
# Copy project files
|
|
COPY --chown=opam:opam dune-project ./
|
|
COPY --chown=opam:opam website_monitor.opam ./
|
|
|
|
# Install dependencies
|
|
RUN opam install . --deps-only --with-test
|
|
|
|
# Build stage (CPU constrained)
|
|
FROM base as build
|
|
ENV OPAMJOBS=1
|
|
ENV OCAMLPARAM=_,_threadsafe
|
|
|
|
# Copy source code
|
|
COPY --chown=opam:opam . .
|
|
|
|
# Build with CPU constraint
|
|
RUN opam exec -- dune build --root . --profile release
|
|
|
|
# Runtime stage
|
|
FROM debian:12-slim as runtime
|
|
WORKDIR /app
|
|
|
|
# Install runtime dependencies
|
|
RUN apt-get update && apt-get install -y \
|
|
libssl3 \
|
|
ca-certificates \
|
|
tzdata \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Copy binaries from build stage
|
|
COPY --from=build /home/opam/website_monitor/_build/default/bin/main.exe /app/website_monitor
|
|
COPY --from=build /home/opam/website_monitor/_build/default/bin/init_db.exe /app/website_monitor_init_db
|
|
|
|
# Copy entrypoint script
|
|
COPY --chown=monitor:monitor docker-entrypoint.sh /app/docker-entrypoint.sh
|
|
RUN chmod +x /app/docker-entrypoint.sh
|
|
|
|
# Create non-root user
|
|
RUN useradd -m -u 1000 monitor && chown -R monitor:monitor /app
|
|
USER monitor
|
|
|
|
# Expose port
|
|
EXPOSE 8080
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
|
|
CMD wget --no-verbose --tries=1 --spider http://localhost:8080/health || exit 1
|
|
|
|
# Run application
|
|
ENTRYPOINT ["/app/docker-entrypoint.sh"]
|
|
CMD []
|