anwareset / mikhmon-container

MikroTik Hotspot Monitor V3 by laksa19 as container image.

Home Page:https://mikhmon.init.web.id

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MIKHMON CONTAINER

MikroTik Hotspot Monitor V3 by laksa19 inside container.

Description

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.

Usages

Docker

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/mikhmon

If 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-app

Kubernetes

The 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.yml

Scale the application manually with --replicas option. Adjust the N number.

kubectl scale deployments mikhmon-app --replicas=N

Delete the resources from cluster.

kubectl delete all
kubectl delete namespace mikhmon-app

Docker Compose

Enter the docker-compose directory, and you will found two options to of using it.

  1. Caddy. Cool web server that automatically provision SSL (Let's Encrypt) for your site, port 80/tcp will redirected to 443/tcp.
  2. Nginx. Run 80/tcp without SSL by default. But you can modify nginx.conf to 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 mikhmonv3

For 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/hosts

Then 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

Container Running List

Add Router 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-orphans

Testing

Dockerfile

Feel free to modify and build the Dockerfile to fit with your needs.

docker build --no-cache -t mikhmon .

Shortage

Please check this #issue from the application side. Persistent Volume on Kubernetes unable to use due to Unspesific Location of Stateful files.


References

About

MikroTik Hotspot Monitor V3 by laksa19 as container image.

https://mikhmon.init.web.id


Languages

Language:Dockerfile 100.0%