Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration from openenergymonitor/emoncms image #29

Open
Leen15 opened this issue Dec 5, 2024 · 7 comments
Open

Migration from openenergymonitor/emoncms image #29

Leen15 opened this issue Dec 5, 2024 · 7 comments

Comments

@Leen15
Copy link

Leen15 commented Dec 5, 2024

Hello,
I'm currently running openenergymonitor/emoncms:11.3.24 on a kubernetes cluster, with separated containers for external services (like mysql).
It looks like the image I'm using is no longer supported and emoncms suggests to move to this one.
Is it something I can do just using this new docker image without changing my setup?

Thanks.

This is my conf:

# MySQL database
MYSQL_HOST=[redacted]
MYSQL_PORT=3306
MYSQL_DATABASE=emoncms
MYSQL_INITDB_SKIP_TZINFO=true
MYSQL_USER=[redacted]
MYSQL_PASSWORD=[redacted]
# Redis
REDIS_ENABLED=false
# MQTT
MQTT_ENABLED=false
# Feed
PHPFINA_DIR=/var/opt/emoncms/phpfina/
PHPTIMESERIES_DIR=/var/opt/emoncms/phptimeseries/

PRODUCTION=true
@alexandrecuer
Copy link
Contributor

Hello

No, you have to change your setup but. I did not use the initial openenergymonitor/emoncms image, I dont know if it is complex or not.

In my mind, it is possible to migrate manually, even it is not a one-to-one replacement, as the architectures and design choices are different

One possibility would be to create a backup and to restore it within a container running the alexjunk/emoncms image
I guess you dont have the backup module working so you have to create it manually :

  • you have to dump your database. Connect to the database through mysql in command line and run something like that, replacing all the $ with your parameters : mysqldump -u${username} -p${password} emoncms > ${backup_location}/emoncms.sql
  • then make a tar.gz with inside the timeseries folders : phpfina, phptimeseries, phpfiwa plus at the root the sql file and your settings file

image

You will also have to adjust the way you post your datas, but if you use an external mqtt broker and want to keep it, the alexjunk/emoncms image can be configured for it, even if it ships its internal broker.... see the env vars in the dockerfile :

ENV \

You can give a try without stopping your original setup.

Best

@Leen15
Copy link
Author

Leen15 commented Dec 6, 2024

Thank you for your answer.
is there a way to run this image with a separated mysql host so I dont have to dump & restore the database?
I prefer to have it separately because it has already what is required to be backed up etc in my current setup and I prefer containers separated for each service.

My IoT device still uses HTTP requests so mqtt is not required too.
I would just to use your image for emoncms only so I can have the last version running.
Is there a way?

Thanks!

@alexandrecuer
Copy link
Contributor

alexandrecuer commented Dec 6, 2024

You can try to adapt the emoncms_pre.sh file, replace localhost by the address of your mysql container and also add the port, altough it may not be necessary if both containers run on the same network
Happy if you make a pr for that with the mysql adress as an env var in the dockerfile.....but it has to be tested....

echo "server = 'localhost'"

@alexandrecuer
Copy link
Contributor

I prefer containers separated for each service.

Why ? There is nothing bad running more than one service in a container when it is correctly done, like here with s6-overlay. This image is here to simplify your life while installing and running emoncms and it sticks to the original design of emoncms, it was not the case with the openenergymonitor/emoncms image

Other users are making the jump and feedback is good :
See : https://community.openenergymonitor.org/t/up-to-date-docker-container-image/27198/6

More on s6-overlay :

https://github.com/just-containers/s6-overlay

@Leen15
Copy link
Author

Leen15 commented Dec 8, 2024

Thank you for your help Alexandre.
While I understand the appeal of bundling services for convenience, running multiple services in one container doesn’t align well with containerization best practices, especially in Kubernetes. Keeping services isolated allows for better scalability, resilience, and easier observability, all of which are critical in production-grade setups (and I'm used to them, also in my own homelab 😊 ).

I ended up using the original openenergymonitor/emoncms image and updating it to the latest version to separate the services as needed.
I believe offering an option to disable bundled services could make your image more flexible for users in similar environments while still catering to simpler use cases.
Thank you again for the work on this image.

@alexandrecuer
Copy link
Contributor

Of thanks for the feedback. As you updated to a new version, could you open a PR in https://github.com/emoncms/emoncms-docker/blob/master/web/Dockerfile or just tell me your changes so i can echo them on the emoncms/emoncms-docker

As you can see, the openenergymonitor image uses supervisord :
https://github.com/emoncms/emoncms-docker/blob/e143cfe6b709357cba0a9bd0a68c3ba1dd8a5e85/web/Dockerfile#L64
is it ok with the k8s best practises ?

disabling the services is not possible with s6-overlay i think. They will run in the background but you will not use...at the end, it is a lot of ressources lost because if you dont use redis, mosquitto and mysql which are embedded, it is a pity, so would be better to update the original emoncms dockerfile with the minimum vital....
I think they lack of an automatic workflow but this i can arrange....

@Leen15
Copy link
Author

Leen15 commented Dec 8, 2024

Of thanks for the feedback. As you updated to a new version, could you open a PR in https://github.com/emoncms/emoncms-docker/blob/master/web/Dockerfile or just tell me your changes so i can echo them on the emoncms/emoncms-docker

As you can see, the openenergymonitor image uses supervisord : https://github.com/emoncms/emoncms-docker/blob/e143cfe6b709357cba0a9bd0a68c3ba1dd8a5e85/web/Dockerfile#L64 is it ok with the k8s best practises ?

disabling the services is not possible with s6-overlay i think. They will run in the background but you will not use...at the end, it is a lot of ressources lost because if you dont use redis, mosquitto and mysql which are embedded, it is a pity, so would be better to update the original emoncms dockerfile with the minimum vital.... I think they lack of an automatic workflow but this i can arrange....

Yeah it would be better to run just the apache service on pid 0, but I didn't want to change too much because I needed that to have it working asap, compatible with last home assistant version (it requires the new UUID identifier).
Here you can find my mods:
emoncms/emoncms-docker@master...Leen15:emoncms-docker:master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants