# M/Monit Production Docker Image
# This Dockerfile builds a production-ready M/Monit container. The user's
# license.xml and server.xml are not part of the image, they are collected
# and generated by build.sh, which seeds them into the 'mmonit-conf' named
# volume mounted at /opt/mmonit/conf at runtime.

# Use Alpine Linux for minimal footprint
# Platform is explicitly set to x86_64 as M/Monit binary is compiled for this architecture
FROM --platform=linux/amd64 alpine:3.24

LABEL org.opencontainers.image.title="M/Monit" \
      org.opencontainers.image.description="M/Monit - Easy, proactive monitoring of Unix systems, network and cloud services" \
      org.opencontainers.image.version="4.4.0" \
      org.opencontainers.image.vendor="Tildeslash Ltd" \
      org.opencontainers.image.authors="support@mmonit.com" \
      org.opencontainers.image.url="https://mmonit.com" \
      org.opencontainers.image.documentation="https://mmonit.com/documentation/" \
      org.opencontainers.image.source="https://mmonit.com/dist/" \
      org.opencontainers.image.licenses="LicenseRef-Proprietary"

WORKDIR /opt

# Install curl, required by the bundled M/Monit alert service scripts
# (Slack, Discord, PagerDuty, Teams, Telegram) and user-defined webhooks
RUN apk add --no-cache curl

# Copy and extract M/Monit
COPY mmonit-4.4.0-alpine-x64.tar.gz .
RUN tar xzf mmonit-4.4.0-alpine-x64.tar.gz && \
    mv mmonit-4.4.0 mmonit && \
    rm mmonit-4.4.0-alpine-x64.tar.gz

RUN rm /opt/mmonit/conf/server.xml && rm -f /opt/mmonit/conf/license.xml

# Set working directory to M/Monit home
WORKDIR /opt/mmonit

# Expose M/Monit web interface port.
EXPOSE 8080

# Start M/Monit directly.
CMD ["./bin/mmonit", "-iu"]
