MikroTik Hotspot Monitor V3 by laksa19 inside container.
This image is using latest alpine for the base with PHP 7.4 as the runtime, executed by user www-data. The exposed port is 8080/tcp and the default volume is pointed at /var/www/html which is the source code located inside container. Hopefully, this will comply with any container orchestration platform like Kubernetes for the best practice of scaling and high availability.
Use any container tool such as docker or podman with simple command. Most easy way, since it's not using any web server to run.
docker pull trianwar/mikhmon
docker run --name mikhmon-app -d -p 80:8080 -v mikhmon-volume trianwar/mikhmonIf you want to access source code files inside the container storage, check the mounted volume on host at /var/lib/docker/volumes. You can backup or modify those files.
To force stop and remove container.
docker rm --force mikhmon-appThe YAML file contains object definition of Kubernetes resources (deployments, services, and ingress). Tested on GKE (Google Kubernetes Engine).
cd mikhmon-container/k8s-manifests
kubectl create namespace mikhmon-app
kubectl apply -f deployments.yml
kubectl apply -f services.yml
kubectl apply -f ingress.ymlScale the application manually with --replicas option. Adjust the N number.
kubectl scale deployments mikhmon-app --replicas=NDelete the resources from cluster.
kubectl delete all
kubectl delete namespace mikhmon-appEnter the docker-compose directory, and you will found two options to of using it.
- Caddy. Cool web server that automatically provision SSL (Let's Encrypt) for your site, port
80/tcpwill redirected to443/tcp. - Nginx. Run
80/tcpwithout SSL by default. But you can modifynginx.confto use certificates and open another port as you wish.
Change the owner to uid=82(www-data) gid=82(www-data), this is because the php:7.4-fpm-alpine seemly use that user by default, and I don't find other way to alter it yet. Also, don't forget to change the domain name of your server in Caddyfile.
cd mikhmon-container/docker-compose
rm -rvf mikhmonv3
git clone https://github.com/laksa19/mikhmonv3.git
sudo chown -R 82:82 mikhmonv3For caddy you may append Public IP of the VPS and FQDN to /etc/hosts configuration file. Bellow are example from my AWS EC2 server.
echo '108.136.227.206 mikhmon.init.web.id' | sudo tee -a /etc/hostsThen let's build and turn it up. Append -d to detach and keep it running in background.
docker network create net1 --driver bridge
docker compose -p mikhmon up --build --remove-orphans -d
docker compose ls
docker ps
As you can see the MikroTik Router is added successfully to MIKHMON, and we got one year valid SSL from Let's Encrypt.
To stop the container, you can turn it down.
docker compose -p mikhmon down --remove-orphansFeel free to modify and build the Dockerfile to fit with your needs.
docker build --no-cache -t mikhmon .Please check this #issue from the application side. Persistent Volume on Kubernetes unable to use due to Unspesific Location of Stateful files.
